Commit graph

147 commits

Author SHA1 Message Date
Lukas Wirth
c01ba4a310 Reject symlinks in project-json 2023-03-25 14:22:05 +01:00
Lukas Wirth
d9c7d28e0d Report sysroot and rustc crate loading errors 2023-03-15 11:35:34 +01:00
Lukas Wirth
8b8cd04825 fix: Don't pass feature flags to rustc private crates metadata invocation 2023-03-15 10:52:50 +01:00
bors
6f297b9076 Auto merge of #14348 - Veykril:rustc-proc, r=Veykril
fix: Fix rustc proc-macro handling being broken on the rustc workspace itself

Also addresses https://github.com/rust-lang/rust-analyzer/issues/13591#issuecomment-1466966952
2023-03-14 10:34:23 +00:00
Lukas Wirth
88f0fe784f fix: Fix rustc proc-macro handling being broken on the rustc workspace itself 2023-03-14 11:33:40 +01:00
David Barsky
677c0eeccb Add path of workspace root folders to status output 2023-03-13 14:45:41 -04:00
Laurențiu Nicola
cfc9d5cd3b Pass flycheck extra args when running build scripts 2023-03-11 19:28:02 +02:00
Lukas Wirth
d8c80e7d95 Add core lib to proc_macro dependencies 2023-03-09 12:58:07 +01:00
Lukas Wirth
4ee2abaf38 minor: Fixup dylib extensions for rustc_private proc-macro loading 2023-03-08 14:45:47 +01:00
Lukas Wirth
c9786484c5 Load proc-macros for rustc_private crates 2023-03-08 12:41:38 +01:00
Lukas Wirth
88f2abb8f7 Don't drop rustc crates in the rustc workspace 2023-03-02 12:55:41 +01:00
Lukas Wirth
47a567b833 Deduplicate source roots that have overlapping include paths 2023-02-28 12:08:23 +01:00
bors
1d32a7b7c6 Auto merge of #14094 - HKalbasi:layout, r=flodiebold
Reuse fetching target data layout from rustc function

fix https://github.com/rust-lang/rust-analyzer/pull/14087?notification_referrer_id=NT_kwDOArGpCLM1NTEyMDQ5MjU3OjQ1MTk3NTc2#discussion_r1097850915
2023-02-06 22:35:37 +00:00
hkalbasi
40cf8b45ac reuse fetching target data layout from rustc function 2023-02-06 23:48:20 +03:30
Lukas Wirth
cb9a5b9549 Support sysroot library source being defined inside the workspace 2023-02-06 12:07:33 +01:00
Maybe Waffle
249ea9502d Set "current" edition to 2021 2023-01-31 10:51:43 +00:00
Lukas Wirth
b2598f4801 Don't fail workspace loading if sysroot can't be found 2023-01-27 13:49:28 +01:00
Lukas Wirth
1535881836 Replace SmolStr usage with lang item enum for lang items 2023-01-21 17:55:45 +01:00
Lukas Wirth
384fa4b84a fix: Fix target-data-layout fetching incorrectly passing 'rustc' to rustc 2023-01-19 21:31:08 +01:00
bors
fa874627f0 Auto merge of #13969 - Veykril:workspace.dependencies, r=Veykril
Use workspace.dependencies to declare local dependencies
2023-01-17 10:29:27 +00:00
Lukas Wirth
bed4db3c62 Use workspace.dependencies to declare local dependencies 2023-01-17 10:52:26 +01:00
Lukas Wirth
e4858fe480 Specify authors, edition and license via workspace.package 2023-01-16 16:44:00 +01:00
Lukas Wirth
679df2adf1 Specify rust-version via workspace.package 2023-01-16 16:33:01 +01:00
Alex Kladov
bd350085f6
Update crates/project-model/src/project_json.rs
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2023-01-13 12:01:04 +00:00
Alex Kladov
87315ef5c3
Apply suggestions from code review
Co-authored-by: Laurențiu Nicola <lnicola@users.noreply.github.com>
2023-01-13 11:57:02 +00:00
Aleksey Kladov
aa73366b0b internal: explain the idea behind rust-project.json 2023-01-13 11:44:02 +00:00
Daniel Eades
5b1cd8245f fixup 2023-01-10 19:44:19 +00:00
Daniel Eades
ac3844a0bb a number of code simplifications 2023-01-10 18:48:51 +00:00
Daniel Eades
4f8ffd0ba4 remove unnecessary lifetimes that can be elided 2023-01-02 15:02:54 +00:00
Daniel Eades
ed128872eb remove needless borrows 2023-01-02 14:52:32 +00:00
Daniel Eades
77051679d7 use inline format args 2023-01-02 14:52:32 +00:00
Yuri Astrakhan
e16c76e3c3 Inline all format arguments where possible
This makes code more readale and concise,
moving all format arguments like `format!("{}", foo)`
into the more compact `format!("{foo}")` form.

The change was automatically created with, so there are far less change
of an accidental typo.

```
cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args
```
2022-12-24 14:36:10 -05:00
Yuri Astrakhan
e341e996f7 Clippy-fix explicit auto-deref
Seems like these can be safely fixed. With one, I was particularly
surprised -- `Some(pats) => &**pats,` in body.rs?

```
cargo clippy --fix -- -A clippy::all -D clippy::explicit_auto_deref
```
2022-12-23 02:52:14 -05:00
Lukas Wirth
a694c342fa Fix tests not using appropriate target data 2022-12-21 20:23:43 +01:00
Lukas Wirth
33591cd3f4 Calculate the TargetDataLayout correctly for the selected target 2022-12-21 15:11:24 +01:00
bors
81d26e730e Auto merge of #13667 - Veykril:detached-files-sysroot, r=Veykril
Handle sysroot config in detached-files workspaces
2022-11-24 09:21:44 +00:00
Lukas Wirth
2300c9de83 Handle sysroot config in detached-files workspaces 2022-11-24 10:21:19 +01:00
bors
38fa47fd79 Auto merge of #13290 - poliorcetics:multiple-targets, r=Veykril
Support multiple targets for checkOnSave (in conjunction with cargo 1.64.0+)

This PR adds support for the ability to pass multiple `--target` flags when using
`cargo` 1.64.0+.

## Questions

I needed to change the type of two configurations options, but I did not plurialize the names to
avoid too much churn, should I ?

## Zulip thread

https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Issue.2013282.20.28supporting.20multiple.20targets.20with.201.2E64.2B.29

## Example

To see it working, on a macOS machine:

```sh
$ cd /tmp
$ cargo new cargo-multiple-targets-support-ra-test
$ cd !$
$ mkdir .cargo
$ echo '
[build]
target = [
    "aarch64-apple-darwin",
    "x86_64-apple-darwin",
]
' > .cargo/config.toml
$ echo '
fn main() {
    #[cfg(all(target_arch = "aarch64", target_os = "macos"))]
    {
        let a = std::fs::read_to_string("/tmp/test-read");
    }

    #[cfg(all(target_arch = "x86_64", target_os = "macos"))]
    {
        let a = std::fs::read_to_string("/tmp/test-read");
    }

    #[cfg(all(target_arch = "x86_64", target_os = "windows"))]
    {
        let a = std::fs::read_to_string("/tmp/test-read");
    }
}
' > src/main.rs
# launch your favorite editor with the version of RA from this PR
#
# You should see warnings under the first two `let a = ...` but not the third
```

## Screen

![Two panes of a terminal emulator, on the left pane is the main.rs file described above, with warnings for the first two let a = declaration, on the right pane is a display of the .cargo/config.toml, an ls of the current files in the directory and a call to cargo build to show the same warnings as in the editor on the left pane](https://user-images.githubusercontent.com/7951708/192122707-7a00606a-e581-4534-b9d5-b81c92694e8e.png)

Helps with #13282
2022-11-19 13:09:37 +00:00
Lukas Wirth
52bc15fc1f fix: Fix proc-macro-srv search paths for Arch Linux 2022-11-18 23:32:26 +01:00
Alexis (Poliorcetics) Bourget
0d4737adb6 feat: Support passing multiple targets to cargo (for Rust 1.64.0+) 2022-11-11 14:36:07 +01:00
Lukas Wirth
3c35d44f55 Add proc-macro dependency to rustc_private crates 2022-11-09 20:50:18 +01:00
Lukas Wirth
ffd7bf8bf9 Bump Cargo rust-version fields to latest stable 2022-11-07 12:59:51 +01:00
Lukas Wirth
8ad4a1d118 Update sysroot crates 2022-11-07 12:01:12 +01:00
Lukas Wirth
859f5594ac Handle multiple projects sharing dependency correctly in once strategy 2022-10-23 18:01:35 +02:00
Lukas Wirth
0f8904ec9c Implement invocation location config 2022-10-22 23:33:03 +02:00
bors
a77ac93b2a Auto merge of #13128 - Veykril:invocation-strategy, r=Veykril
Implement invocation strategy config

Fixes https://github.com/rust-lang/rust-analyzer/issues/10793

This allows to change how we run build scripts (and `checkOnSave`), exposing two configs:
- `once`: run the specified command once in the project root (the working dir of the server)
- `per_workspace`: run the specified command per workspace in the corresponding workspace

This also applies to `checkOnSave` likewise, though `once_in_root` is useless there currently, due to https://github.com/rust-lang/cargo/issues/11007
2022-10-19 21:53:19 +00:00
Lukas Wirth
46732369f4 Remove simplistic interpolation for manifest-path 2022-10-19 23:53:00 +02:00
Lukas Wirth
7db50294a3 {manifest-path} interpolation 2022-10-19 23:21:34 +02:00
Lukas Wirth
7e2c41dbd6 Implement invocation strategy config for build scripts 2022-10-19 23:21:29 +02:00
Lukas Wirth
653dafa7b1 Add some sysroot logging 2022-10-19 22:26:44 +02:00
Lukas Wirth
9d3e616f82 Simplify 2022-10-19 21:17:11 +02:00
bors
855cd5c280 Auto merge of #13418 - lnicola:bump-deps, r=lnicola
Bump deps
2022-10-15 11:27:12 +00:00
Laurențiu Nicola
cbce0cda08 Bump anyhow, arbitrary, itertools, semver, serde 2022-10-15 12:52:34 +03:00
Lukas Wirth
fd9cd8476b Don't report build-scripts and proc-macros are metadata progress 2022-10-10 15:41:32 +02:00
Lukas Wirth
e0c9e28d1f
Revert "Add proc-macro dependency to rustc crates" 2022-10-04 08:18:01 +02:00
Lukas Wirth
870825b376 Add proc-macro dependency to rustc crates 2022-10-01 21:29:14 +02:00
Lukas Wirth
5424c51158 Add config for supplying sysroot path 2022-10-01 21:17:06 +02:00
Noah Santschi-Cooney
60b432b7e9
fix model tests 2022-09-26 18:18:12 +01:00
Noah Santschi-Cooney
aa093f5a58
Fix PackageInformation having the crate name instead of package name 2022-09-26 17:31:38 +01:00
Lukas Wirth
7e8eac3fd7 Simplify 2022-09-20 14:33:18 +02:00
Lukas Wirth
a6c067c06d Simplify 2022-09-19 17:31:08 +02:00
Lukas Wirth
d9f5709609 Simplify feature representation in CargoConfig 2022-09-19 16:52:44 +02:00
Daniel Paoliello
c407cc554e Add cargo.extraEnv setting 2022-09-13 11:29:14 -07:00
Lukas Wirth
5b6aefe565 Update test fixtures 2022-08-25 21:07:24 +02:00
Lukas Wirth
d025c5d8d6 Make use of NoHash hashing for FileId and CrateId 2022-08-25 20:41:49 +02:00
Dezhi Wu
23747419ca fix: a bunch of typos
This PR will fix some typos detected by [typos].

There are also some other typos in the function names, variable names, and file
names, which I leave as they are. I'm more certain that typos in comments
should be fixed.

[typos]: https://github.com/crate-ci/typos
2022-08-17 21:44:58 +08:00
Lukas Wirth
25d4fbe9da Re-try build script building with --keep-going 2022-08-10 10:23:46 +02:00
Lukas Wirth
950de7c3c3 Use --keep-going cargo flag when building build scripts 2022-08-09 14:31:17 +02:00
Jonas Schievink
bd7dfac5eb Fix r-a spelling in some places 2022-08-01 13:47:09 +02:00
Amos Wenger
2c2520fbb4 Allow specifying sysroot OR sysroot_src 2022-07-25 17:52:38 +02:00
Amos Wenger
696775153d Fix mix up in comments 2022-07-25 16:59:10 +02:00
Amos Wenger
dadb83282d Remember the difference between 'sysroot root' and 'sysroot src root', start looking in there for a rust-analyzer-proc-macro-srv binary 2022-07-25 16:07:41 +02:00
Amos Wenger
23d25a3094 Enable extra warnings required by rust-lang/rust 2022-07-20 15:00:17 +02:00
Amos Wenger
1b416473a3 Upgrade to expect-test@1.4.0
cf. https://github.com/rust-analyzer/expect-test/issues/33
cf. https://github.com/rust-lang/rust/pull/99444#issuecomment-1188844202
2022-07-19 13:00:45 +02:00
TonalidadeHidrica
f0649f2c19 Fix rustcSource -> rustc_source
This only fixes the comments in the internal source,
     which is not mandatory at all
2022-07-11 16:50:20 +09:00
Jonas Schievink
6c6ae965ba Update remaining GitHub URLs 2022-07-08 15:44:49 +02:00
Laurențiu Nicola
9e7ca80c82 Bump cargo_metadata 2022-07-03 10:09:35 +03:00
Florian Diebold
8b3ec12aac fix: Report proc macro errors in expressions correctly as well
They didn't have a krate before, resulting in the generic "proc macro
not found" error.

Also improve error messages a bit more.
2022-06-28 10:43:22 +02:00
bors
5bb123d970 Auto merge of #12520 - Veykril:flycheck-cancel, r=Veykril
internal: Bring back JodChild into flychecking for cancellation

cc https://github.com/rust-lang/rust-analyzer/pull/10517/files#r895241975
2022-06-24 17:42:00 +00:00
Florian Diebold
c80c34867f Improve proc macro errors a bit
Distinguish between
 - there is no build data (for some reason?)
 - there is build data, but the cargo package didn't build a proc macro dylib
 - there is a proc macro dylib, but it didn't contain the proc macro we expected
 - the name did not resolve to any macro (this is now an
 unresolved_macro_call even for attributes)

I changed the handling of disabled attribute macro expansion to
immediately ignore the macro and report an unresolved_proc_macro,
because otherwise they would now result in loud unresolved_macro_call
errors. I hope this doesn't break anything.

Also try to improve error ranges for unresolved_macro_call / macro_error
by reusing the code for unresolved_proc_macro. It's not perfect but
probably better than before.
2022-06-24 13:45:19 +02:00
Florian Diebold
07d78b67cb Fix test 2022-06-20 20:34:08 +02:00
Florian Diebold
05ca0a2377 Refactor a bit 2022-06-20 20:21:30 +02:00
Florian Diebold
98a58114a4 Only apply cfg(test) for local crates
Don't analyze dependencies with `test`; this should fix various cases
where crates use `cfg(not(test))` and so we didn't find things.

"Local" here currently means anything that's not from the registry, so
anything inside the workspace, but also path dependencies. So this isn't
perfect, and users might still need to use
`rust-analyzer.cargo.unsetTest` for these in some cases.
2022-06-20 20:10:25 +02:00
Lukas Wirth
1dd2c50298 Update test outputs 2022-06-15 18:07:37 +02:00
Lukas Wirth
7d51fc4640 Show proc-macro loading errors in unresolved-proc-macro diagnostics 2022-06-15 17:34:01 +02:00
Lukas Wirth
6438ef9aa3 internal: Bring back JodChild into flychecking for cancellation 2022-06-13 13:51:10 +02:00
Lukas Wirth
10e9f47dce fix: Pass the build data to rustc_private crates 2022-06-12 19:29:45 +02:00
bors
e9d3fe0484 Auto merge of #12502 - Veykril:deps, r=Veykril
internal: Bump Dependencies
2022-06-10 19:51:04 +00:00
Lukas Wirth
76ae5434fa internal: Bump Dependencies 2022-06-10 17:30:02 +02:00
KOLANICH
b3d2012659 Remove the unneeded destructuring assignment in run in project-model/src/build_scripts.rs 2022-06-06 14:02:34 +03:00
Lukas Wirth
62fede212a Only record build script outputs when the output has been changed 2022-06-04 15:04:56 +02:00
Lukas Wirth
d0e3114441 internal: Don't log default build script outputs 2022-06-03 16:46:16 +02:00
Lukas Wirth
7274a48657 minor: log build script invocations 2022-05-24 22:56:49 +02:00
Jonas Schievink
33939a3db1 Don't swallow build script errors 2022-05-20 17:28:39 +02:00
Jonas Schievink
b2779111b4 simplify 2022-05-19 15:29:35 +02:00
Aleksey Kladov
57cb65bb7a internal: vendor lsp-server 2022-05-14 21:15:43 +01:00
Peh
1f011fa4a3 style: rename crates to kebab case 2022-05-01 10:48:58 +00:00