Commit graph

90 commits

Author SHA1 Message Date
Daniel McNab
d0a51d710e Never run cargo check on the rustc source 2021-03-08 16:42:18 +00:00
Daniel McNab
d5d406fa78 Only show directory name 2021-03-08 16:41:40 +00:00
Daniel McNab
bbecea03fd Revert "Support disabling rustc build scripts"
This reverts commit ddce6bb282.
2021-03-08 16:37:52 +00:00
Daniel McNab
ddce6bb282 Support disabling rustc build scripts 2021-03-08 09:05:19 +00:00
Daniel McNab
877f745551 Fix the comment
It's worse than I thought...
2021-03-07 13:13:54 +00:00
Daniel McNab
419b5a1bee Extract the large nested block into a function
Also add some more detailed comments
Extract into function deleted the previous comments
2021-03-07 12:59:15 +00:00
Daniel McNab
9246df669a Require opt in to rustc_private
This gives the advantage that

A future extension would be to check for `feature(rustc_private)` instead
2021-03-07 12:24:20 +00:00
Daniel McNab
71a254c1a1 Don't double analyse the same crate 2021-03-07 11:17:14 +00:00
Daniel McNab
b46605cfcd Update crate graph to only use subcrates of rustc_driver 2021-03-07 10:18:01 +00:00
Daniel McNab
7513867aa2 If a manual dependency exists, don't overwrite
This is a hack to work around miri being included in
our analysis of rustc-dev
Really, we should probably use an include set of the actual root libraries

I'm not sure how those are determined however
2021-03-06 13:56:42 +00:00
Daniel McNab
1076d21fc0 Implement opt-in (and opt-out) rustc_private 2021-03-06 12:17:22 +00:00
Laurențiu Nicola
b20708f6ee Bump cargo_metadata 2021-03-02 14:27:29 +02:00
kjeremy
f9bb398cc5 Fix a few clippy::perf warnings 2021-02-16 10:55:34 -05:00
Benjamin Bouvier
4a6e602c94 Allow automatically detect the rustc-src directory (fixes #3517).
If the configured rustcSource is set to "discover", try to automatically
detect a source from the sysroot rustc directory.
2021-02-13 18:20:46 +01:00
Edwin Cheng
9358eecc04 Async Loading outdir and proc-macro 2021-01-29 01:04:14 +08:00
Aleksey Kladov
4b59c3a538 Make logger-based debugging more pleasant 2021-01-28 17:07:53 +03:00
Jonas Schievink
481a74eda7 Export CARGO for proc. macros 2021-01-27 14:25:51 +01:00
Edwin Cheng
eb2cb6b01f Use AbsPath 2021-01-22 19:51:14 +08:00
Edwin Cheng
6bdb6786ba Refactor build script data 2021-01-22 19:11:01 +08:00
Edwin Cheng
ac3ec18f4b Added defined_features in PackageData 2021-01-21 19:12:19 +08:00
Aleksey Kladov
add87f5424 Avoid blocking the main loop when editing Cargo.toml
I've noticed a bunch of "main loop too long" warnings in console when
typing in Cargo.toml. Profiling showed that the culprit is `rustc
--print cfg` call.

I moved it to the background project loading phase, where it belongs.
This highlighted a problem: we generally use single `cfg`, while it
really should be per crate.
2021-01-18 14:52:12 +03:00
Aleksey Kladov
cc963d2b11 Add profile call 2021-01-18 14:01:52 +03:00
Aleksey Kladov
e13065b8ac Add profile call 2021-01-18 13:30:12 +03:00
Aleksey Kladov
1c8feac01f ⬆️ arena 2021-01-17 11:43:04 +03:00
Aramis Razzaghipour
709034d123
Depend on local copy of la-arena instead of crates.io’s 2021-01-17 17:52:57 +11:00
Aleksey Kladov
4c4e54ac8a prepare to publish el libro de arena 2021-01-14 19:06:02 +03:00
Chinedu Francis Nwafili
47c5ec4b94
Use --workspace when loading extern resources
https://github.com/rust-analyzer/rust-analyzer/issues/5040#issuecomment-759853153
2021-01-14 06:03:41 -05:00
kjeremy
1da68e87af Unfreeze cargo_metadata
It now pulls in a newer version of semver-parser.
2021-01-11 08:27:16 -05:00
Edwin Cheng
2b2d699b35 Report progress for cargo metadata and output-dir 2021-01-08 01:18:58 +08:00
Arnaud
ef636ba346 Document project_model::TargetData
This adds a description for `TargetData` and all its fields.
2021-01-06 17:26:21 +01:00
Arnaud
0abe487f1c Document project_model::PackageData
This adds a description for `PackageData` and all its fields.
2021-01-06 17:26:15 +01:00
Arnaud
7c3e163e90 Make PackageData, TargetData and PackageDependency public
This makes them discoverable through documentation.
They were already publicly accessible through `Package` and `Target`.
2021-01-06 16:33:29 +01:00
Aleksey Kladov
f7a15b5cd1 More maintainable config
Rather than eagerly converting JSON, we losslessly keep it as is, and
change the shape of user-submitted data at the last moment.

This also allows us to remove a bunch of wrong Defaults
2021-01-06 15:39:28 +03:00
Mara Bos
4833972067 Add support for Rust 2021. 2021-01-01 17:22:23 +01:00
bors[bot]
a485c9b21d
Merge #7071
7071: Pass --all-targets to "cargo check" when discovering external resources r=matklad a=WasabiFan

There is a repro case and background in the linked issue.

In short, the goal of this MR is to allow rust-analyzer to discover proc-macros which come from your tests (including, most importantly, dev-dependencies).

By default, `cargo check` implies the equivalent of `--lib --bins`, meaning it'll check your libraries and binaries -- but not tests! This means proc-macros (or, I guess, build scripts as well) weren't discovered by rust-analyzer if they came from tests.

One solution would be to manually add `--lib --bins --tests` (i.e., just augment the effective options to include tests). However, in this MR, I threw in `--all-targets`, which [according to the docs](https://doc.rust-lang.org/cargo/commands/cargo-check.html#target-selection) implies `--benches --examples` too. I have absolutely no idea what repercussions that will have on rust-analyzer for other projects, nor do I know if it's a problem that build scripts will now be discovered for tests/examples/benches. But I am not aware of a reason you _wouldn't_ want to discover these things in your examples too.

I think the main drawback of this change is that it will likely slow down the `cargo check`. At a minimum, it'll now be checking your tests _and_ their dependencies. The `cargo check` docs also say that including `--tests` as I have here may cause your lib crate to be built _twice_, once for the normal target and again for unit tests. My reading of that caveat suggests that "building twice" means it's built once for the tests _inside_ your lib, with a test profile, and again for any consumers of your lib, now using a normal release profile or similar. This doesn't seem surprising.

Very minor caveat: `--tests`  will not include tests within a binary if it has `test = false` set in `Cargo.toml`. (I discovered this manually by trial-and-error, but hey, it actually says that in the docs!) This is likely not an issue, but _does_ mean that if you are -- for whatever reason -- disabling tests like that and then manually specifying `cargo test --package <...> --bin <...>` to run them, rust-analyzer will remain unaware of proc-macros in your tests.

I have confirmed this fixes the original issue in my sandbox example linked in #7034 and in my own project in which I originally discovered this. I've left it configured as my default RA language server and will report back if I notice any unexpected side-effects.

Fixes #7034


Co-authored-by: Kaelin Laundry <wasabifan@outlook.com>
2020-12-31 15:29:26 +00:00
lf-
27a0fd23d8 add working dir to cargo metadata fail messages 2020-12-31 04:42:59 -08:00
kjeremy
dc1396eec7 Update crates 2020-12-30 10:39:50 -05:00
Kaelin Laundry
7b3b0bad1f Pass --all-targets to "cargo check" 2020-12-28 19:33:16 -08:00
Jon Gjengset
faed47b3d3 Fun times with rustfmt 2020-12-17 10:24:58 -08:00
Jon Gjengset
71478e067b
Update crates/project_model/src/cargo_workspace.rs
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-12-17 13:18:23 -05:00
Jon Gjengset
9802c0ccd0 Default to host platform for cargo metadata
This modifies the logic for calling cargo metadata so that it will use
the host platform if no explicit target platform is given. This is
needed since cargo metadata defaults to outputting information for _all_
targets.

Fixes #6908.
2020-12-16 17:38:37 -08:00
Florian Diebold
7d7949b315 Change recommendation when source can't be loaded from sysroot
Since we just tried running `rustup component add`, it doesn't make sense to me
to recommend trying that again. If we're reaching this case, it's probably more
likely that rustc was installed via package manager, in which case the source
should be installed the same way (e.g. if you install the rust-src package on
Ubuntu it will install a symlink in the right place to make our sysroot
detection work).
2020-12-13 13:04:50 +01:00
Jeremy Kolb
26a1675764 Remove some redundant allocations 2020-12-12 12:27:09 -05:00
Jonas Schievink
4d4b91117a Use itertools 2020-12-10 19:29:11 +01:00
Jonas Schievink
41d73d1312 Replicate Cargo environment variables 2020-12-10 18:51:39 +01:00
Jonas Schievink
eeeacc4727 Apply environment set by build scripts 2020-12-07 20:52:31 +01:00
Jonas Schievink
a69996933a Pass --target when loading out dirs from check 2020-12-07 20:39:29 +01:00
Jonas Schievink
2b2318e695 Remove dummy ProcMacroClient in favor of Option 2020-12-07 17:16:50 +01:00
kjeremy
9a3142664b Pin cargo_metadata 2020-11-25 10:11:53 -05:00
Aleksey Kladov
e88b5fe916 Simplify 2020-11-17 15:25:58 +01:00