Commit graph

76 commits

Author SHA1 Message Date
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
Aleksey Kladov
bd4d375a64 Make code more readable 2020-11-17 15:25:58 +01:00
Aleksey Kladov
a0c4dbc399 Minor 2020-11-17 15:25:58 +01:00
Aleksey Kladov
0d19ee1d70 Simplify 2020-11-17 15:25:57 +01:00
Aleksey Kladov
0dc1742187 Remove needless alloc 2020-11-17 11:52:28 +01:00
Aleksey Kladov
e4927d52e2 Compress code 2020-11-17 11:52:28 +01:00
Aleksey Kladov
a6960fb3b8 simplify 2020-11-17 11:31:40 +01:00
Aleksey Kladov
b1377363df Remove dead code 2020-11-13 17:53:48 +01:00
Aleksey Kladov
4dfda64b39 Cleanup workspace loading a tiny bit 2020-11-13 17:38:26 +01:00
Aleksey Kladov
aeda30e301 Move tricky workspace logic to a separate module 2020-11-13 16:44:48 +01:00
Xavier Denis
89ce6b6664 Address review comments 2020-11-12 18:49:22 +01:00
Xavier Denis
16443760a3 Reorder rustc_private loading 2020-11-11 13:04:27 +01:00
Xavier Denis
8716087919 Add support for loading rustc private crates 2020-11-11 12:45:40 +01:00
Aleksey Kladov
85db47ac76 Ignore RUST_SRC_PATH if it is set to invalid value
Folks report a ton of hard-to-diagnose issues, the solution for which
is "unset RUST_SRC_PATH". Let's just ignore RUST_SRC_PATH when it
won't work anyway!
2020-11-06 11:30:57 +01:00
Aleksey Kladov
ba8d6d1e4e Remove more unreachable pubs 2020-11-02 16:58:33 +01:00