Commit graph

170 commits

Author SHA1 Message Date
Lukas Wirth
9cb13b6efb Allow navigation targets to be duplicated when the focus range lies in the macro definition site 2023-12-06 12:38:19 +01:00
Igor Matuszewski
a7224c998d Don't explicitly warn against semicolon_in_expressions_from_macros
This has been warn-by-default for two years now and has already been
added to the future-incompat lints in 1.68.
2023-12-05 11:35:09 +01:00
Ali Bektas
ba1b080805 Precede paths with $ROOT$ 2023-11-23 12:34:38 +01:00
Ali Bektas
736994f026 Make test cases simpler 2023-11-23 11:52:22 +01:00
Ali Bektas
74d8fdc8fe Update test data for crate deduping
Make data reflect a case where dev deps are existent.
base-db::CrateGraph::extend now adds dev dependencies for a crate
in case of its upgrading from a CrateOrigin::Lib kind of a crate to a
CrateOrigin::Local one.
2023-11-23 02:15:47 +01:00
Ali Bektas
7e4aad5ba5 v2 2023-11-23 02:15:47 +01:00
Ali Bektas
886eaa0a7d Relaxation for crate graph mergin
Partially fixes #15656 . When a crate graph is extended which is the case when new workspaces are added to the project
the rules for deduplication were too strict. One problem that arises from this is that in certain conditions
when we see the same crate having different `CrateOrigin`s the first form would be maintained. This approach however
results in some unwanted results such as making renaming forbidden as this has been recently only made available for
local crates. The given example in #15656 can still not be resolved with this PR as that involves taking inconsistencies
between dependencies into consideration. This will be addressed in a future PR.
2023-11-23 02:15:46 +01:00
Laurențiu Nicola
3ed27d21f2 Bump cargo_metadata 2023-11-15 21:18:49 +02:00
Laurențiu Nicola
f53368dd3f Bump tracing 2023-11-15 13:00:32 +02:00
Laurențiu Nicola
f66df10f87 Bump itertools 2023-11-15 12:53:56 +02:00
Laurențiu Nicola
dfc885e0fd Bump anyhow 2023-11-15 12:49:32 +02:00
Victor Song
53b6700594 Add dedicated target_dir field to CargoConfig and FlycheckConfig
Add dedicated field for `target_dir` in the configurations for Cargo
and Flycheck. Also change the directory to be a `PathBuf` as opposed to
a `String` to be more appropriate to the operating system.
2023-10-09 02:15:05 -05:00
bors
c405509f2e Auto merge of #15560 - davidbarsky:davidbarsky/use-sysroot-rustc-to-determine-cfgs, r=Veykril
project-model: when using `rust-project.json`, prefer the sysroot-defined rustc over discovery in `$PATH`

At the moment, rust-analyzer discovers `rustc` via the `$PATH` even if the `sysroot` field is defined in a `rust-project.json`. However, this does not work for users who do not have rustup installed, resulting in any `cfg`-based inference in rust-analzyer not working correctly. In my (decently naive!) opinion, it makes more sense to rely on the `sysroot` field in the `rust-project.json`.

One might ask "why not add `rustc` to the `$PATH`?" That is a reasonable question, but that doesn't work for my use case:
- The path to the sysroot in my employer's monorepo changes depending on which platform a user is on. For example, if they're on Linux, they'd want to use the sysroot defined at path `a`, whereas if they're on macOS, they'd want to use the sysroot at path `b` (I wrote the sysroot resolution functionality [here](765da4ca1e/integrations/rust-project/src/sysroot.rs (L39)), if you're curious).
- The location of the sysroot can (and does!) change, especially as people figure out how to make Rust run successfully on non-Linux platforms (e.g., iOS, Android, etc.) in a monorepo. Updating people's `$PATH` company-wide is hard while updating a config inside a CLI is pretty easy.

## Testing

I've created a `rust-project.json` using [rust-project](https://github.com/facebook/buck2/tree/main/integrations/rust-project) and was able to successfully load a project with and without the `sysroot`/`sysroot_src` fields—without those fields, rust-analyzer fell back to the `$PATH` based approach, as evidenced by `[DEBUG project_model::rustc_cfg] using rustc from env rustc="rustc"` showing up in the logs.
2023-09-08 18:14:25 +00:00
David Barsky
0bf6ffaf82
Update crates/project-model/src/rustc_cfg.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2023-09-08 14:07:59 -04:00
Lukas Wirth
fddef42e92 Only set rust-analyzer cfg for workspace members 2023-09-08 11:02:56 +02:00
Lukas Wirth
e9e2c1ae75 Update project-model test outputs 2023-09-08 10:49:15 +02:00
Lukas Wirth
ca6ddd8ea3 Enable rust_analyzer for cfgs when code is being analyzed by rust-analyzer 2023-09-08 10:49:12 +02:00
Ali Bektas
506a477acf Use cargo name as the CARGO_CRATE_NAME instead of package name 2023-09-08 01:41:00 +02:00
David Barsky
912b22fa07 add doc comment to rustc_cfg::RustcCfgConfig 2023-09-07 15:30:11 -04:00
David Barsky
fad3823a20 rename rustc_cfg::Config to rustc_cfg::RustcCfgConfig and import 2023-09-07 15:19:04 -04:00
David Barsky
553152e2d5 refactor rustc_cfg to be more inline with docs/dev/style.md 2023-09-07 15:06:51 -04:00
David Barsky
5b5bce8aaf project-model: when using rust-project.json, prefer the sysroot-defined rustc over an env-based one 2023-09-07 11:46:14 -04:00
Lukas Wirth
18b24f60d0 More error context when failing to invoke the rust toolchain 2023-08-09 14:09:37 +02:00
Ryo Yoshida
dfb32cdf10
Optimize DepKindInfo -> DepKind conversion
We don't need to allocate a `Vec`, nor do we need sorting.
2023-07-21 17:10:42 +09:00
hkalbasi
41b8b0b77d Enable cfg miri in analysis 2023-07-14 22:59:46 +03:30
David Lattimore
bea3a33d84 Change in-tree libs to workspace dependencies 2023-06-20 13:53:39 +10:00
Alex Kladov
6303551cb8 internal: use consistent style for error handling 2023-06-19 13:01:47 +01:00
Alex Kladov
49318bbae7 fix: ensure that ws loading error includes path to ws 2023-06-19 12:32:04 +01:00
hkalbasi
a481e004b0 Lower const params with a bad id 2023-06-11 00:39:28 +03:30
Lukas Wirth
ecb8616870 fix: Don't duplicate sysroot crates in rustc workspace 2023-05-31 15:37:35 +02:00
bors
e8dbb8e2e0 Auto merge of #14911 - Veykril:config-cfg, r=Veykril
Allow setting cfgs

Fixes https://github.com/rust-lang/rust-analyzer/issues/14365
2023-05-30 12:00:14 +00:00
Lukas Wirth
cea84427e0 Allow setting cfgs 2023-05-28 13:43:21 +02:00
Lukas Wirth
35b208aaa7 Filter out unused cargo features from config 2023-05-26 22:16:34 +02:00
Lukas Wirth
f47caa666e Add AbsPath::absolutize 2023-05-13 11:51:28 +02:00
Lukas Wirth
939ebb4454 Forbid canonicalization of paths and normalize all rust-project.json paths 2023-05-04 14:51:35 +02:00
Laurențiu Nicola
7197a27028 Use triomphe Arc 2023-05-02 20:02:43 +03:00
bors
a7168a8c6f Auto merge of #14712 - Veykril:metadata-extra-args, r=Veykril
fix: Only pass unstable flags to cargo metadata from extra args config
2023-05-02 16:34:39 +00:00
Lukas Wirth
16b3febcf5 Only pass unstable flags to cargo metadata from extra args config 2023-05-02 17:33:58 +02:00
Ddystopia
fc888b583d
Add target_directory path to CargoWorkspace 2023-05-02 17:06:31 +02:00
Bruno Ortiz
072f69e4c1 fixing ts linting and rust test 2023-05-02 11:01:53 -03:00
Bruno Ortiz
66fe84d936 accepting review suggestions 2023-05-02 11:01:41 -03:00
Bruno Ortiz
c372fb3495 fixing tests for windows 2023-05-02 10:59:31 -03:00
Bruno Ortiz
a3081a6774 Adding crate_root_path to crate_graph 2023-05-02 10:59:31 -03:00
wackbyte
01c59812ae
fix grammar 2023-04-28 23:04:08 -04:00
bors
797c2f1dde Auto merge of #14659 - Veykril:dedup-crates, r=Veykril
Deduplicate crates when extending crate graphs

This is quadratic in runtime per deduplication attempt, but I don't think that'll be a problem for the workload here. Don't be scared of the diff, the actual diff is +42 -22, the rest is tests and test data.
Fixes https://github.com/rust-lang/rust-analyzer/issues/14476
2023-04-26 09:44:27 +00:00
Lukas Wirth
968850d7bf Deduplicate crates when extending crate graphs 2023-04-26 11:44:11 +02:00
Lukas Wirth
c21860bd6a Remove proc-macro server command from the rust-analyzer binary 2023-04-26 08:19:28 +02:00
bors
943d2a8a1c Auto merge of #14642 - jakhh8:master, r=Veykril
minor: Use `CargoConfig.extra_args` for fetching metadata

Fixes #14510
2023-04-25 12:46:29 +00:00
Lukas Wirth
10d7d7304b
Revert "Handle dev-dependency cycles" 2023-04-25 14:29:26 +02:00
Lukas Wirth
e205af259d Prefer test duped crates for ide features 2023-04-25 11:39:58 +02:00