Commit Graph

2025 Commits

Author SHA1 Message Date
Lukas Wirth
31db1fc75f internal: Refine CrateOrigin variants 2023-03-31 10:36:13 +02:00
Lukas Wirth
e244942209 internal: Set Durability to HIGH for enable_proc_attr_macros input 2023-03-30 15:11:22 +02:00
bors
fc8c5139fa Auto merge of #14410 - Veykril:query-lru-capacities, r=Veykril
internal: Add config to specifiy lru capacities for all queries

Might help figuring out what queries should be limited by LRU by default, as currently we only limit `parse`, `parse_macro_expansion` and `macro_expand`.
2023-03-30 12:20:24 +00:00
Lukas Wirth
5616d91b73 internal: Add config to specifiy lru capacities for all queries 2023-03-30 12:52:28 +02:00
bors
b915eb32fa Auto merge of #14427 - davidbarsky:davidbarsky/allow-subsequent-workspaces-to-have-proc-macros, r=Veykril
fix: allow new, subsequent `rust-project.json`-based workspaces to get proc macro expansion

As detailed in https://github.com/rust-lang/rust-analyzer/issues/14417#issuecomment-1485336174, `rust-project.json` workspaces added after the initial `rust-project.json`-based workspace was already indexed by rust-analyzer would not receive procedural macro expansion despite `config.expand_proc_macros` returning true. To fix this issue:
1. I changed `reload.rs` to check which workspaces are newly added.
2. Spawned new procedural macro expansion servers based on the _new_ workspaces.
    1. This is to prevent spawning duplicate procedural macro expansion servers for already existing workspaces. While the overall memory usage of duplicate procedural macro servers is minimal, this is more about the _principle_ of not leaking processes 😅.
3. Launched procedural macro expansion if any workspaces are `rust-project.json`-based _or_ `same_workspaces` is true. `same_workspaces` being true (and reachable) indicates that that build scripts have finished building (in Cargo-based projects), while the build scripts in `rust-project.json`-based projects have _already been built_ by the build system that produced the `rust-project.json`.

I couldn't really think of structuring this code in a better way without engaging with https://github.com/rust-lang/rust-analyzer/issues/7444.
2023-03-30 07:50:27 +00:00
David Barsky
25c59b8e92 address PR comments 2023-03-29 15:29:32 -04:00
bors
7a98e24777 Auto merge of #14431 - Veykril:simplify, r=Veykril
minor: Simplify
2023-03-29 07:28:42 +00:00
Lukas Wirth
8ea1afce28 Simplify 2023-03-28 16:32:26 +02:00
David Barsky
e5bfd7ef0a it, uh, turns out that we should be spawning for new servers. oops. 2023-03-28 09:56:01 -04:00
David Barsky
6a42d7f627 fix: allow new, subsequent rust-project.json-based workspaces to get
proc macro expansion.
2023-03-28 09:17:16 -04:00
Eclips4
0a2a50a663 Fix typo 2023-03-28 12:32:51 +03:00
bors
5bba438c9c Auto merge of #14366 - Veykril:linked-proj, r=Veykril
feat: Pop a notification prompting the user to add a Cargo.toml of unlinked file to the linkedProjects

cc https://github.com/rust-lang/rust-analyzer/issues/13226 https://github.com/rust-lang/rust-analyzer/issues/9661
2023-03-28 07:05:43 +00:00
Daniil Kolesnichenko
be17eab08b fix(rustdoc): don't escape double hashes outside of Rust code blocks
Fixes #14376
2023-03-28 05:32:59 +07:00
Lukas Wirth
ee02213e65 Handle proc macro fetching via OpQueue 2023-03-26 09:33:41 +02:00
Lukas Wirth
e5f24a6d7c Set proc_macros input when creating the RootDatabase 2023-03-25 18:20:42 +01:00
Lukas Wirth
607375dc20 Load proc-macros asynchronously 2023-03-25 18:06:06 +01:00
Lukas Wirth
e9fb2ffe45 Add lsp command for rebuilding proc macros 2023-03-25 16:50:31 +01:00
Lukas Wirth
d154ea88f9 Split out proc-macros from the CrateGraph 2023-03-25 16:46:44 +01:00
bors
71b23360e7 Auto merge of #14404 - Veykril:proc-macro-loading, r=Veykril
Remove client side proc-macro version check

The server already verifies versions due to ABI picking now so there shouldn't be a need for the client side check anymore
2023-03-25 14:44:53 +00:00
Lukas Wirth
3ae9bfe266 Remove client side proc-macro version check 2023-03-25 15:43:58 +01:00
bors
992a0fc074 Auto merge of #14403 - Veykril:dependencies, r=Veykril
internal: Bump Cargo.lock
2023-03-25 14:15:10 +00:00
Lukas Wirth
39e86e78c3 Bump Cargo.lock 2023-03-25 15:12:39 +01:00
hkalbasi
1b85b43e6f add mir-stats to analysis-stats 2023-03-17 13:08:35 +03:30
Lukas Wirth
66636939a6 feat: Pop a notification prompting the user to add a Cargo.toml of unlinked file to the linkedProjects 2023-03-16 16:26:19 +01:00
bors
adbda94303 Auto merge of #14359 - Veykril:opt-out-retry, r=Veykril
fix: Do not retry inlay hint requests

Should close https://github.com/rust-lang/rust-analyzer/issues/13372, retrying the way its currently implemented is not ideal as we do not adjust offsets in the requests, but doing that is a major PITA, so this should at least work around one of the more annoying issues stemming from it.
2023-03-15 11:44:29 +00:00
Lukas Wirth
74e08cb60d fix: Do not retry inlay hint requests 2023-03-15 12:44:11 +01:00
bors
1787c14e72 Auto merge of #14358 - Veykril:err-reporting, r=Veykril
Report sysroot and rustc crate loading errors

Also aggregates the warnings and errors so we don't discard previous ones.
cc https://github.com/rust-lang/rust-analyzer/issues/14327
2023-03-15 10:36:50 +00:00
Lukas Wirth
d9c7d28e0d Report sysroot and rustc crate loading errors 2023-03-15 11:35:34 +01:00
Lukas Wirth
e2ab0ff124 Aggregate errors and warnings in the status message 2023-03-15 11:28:37 +01:00
bors
c15335c8b0 Auto merge of #14307 - davidbarsky:davidbarsky/add-cargo-style-project-discovery-for-buck-and-bazel-sickos, r=Veykril
Add Cargo-style project discovery for Buck and Bazel Users

This feature requires the user to add a command that generates a `rust-project.json` from a set of files. Project discovery can be invoked in two ways:

1. At extension activation time, which includes the generated `rust-project.json` as part of the linkedProjects argument in `InitializeParams`.
2. Through a new command titled "rust-analyzer: Add current file to workspace", which makes use of a new, rust-analyzer-specific LSP request that adds the workspace without erasing any existing workspaces. Note that there is no mechanism to _remove_ workspaces other than "quit the rust-analyzer server".

Few notes:
-  I think that the command-running functionality _could_ merit being placed into its own extension (and expose it via extension contribution points) to provide build-system idiomatic progress reporting and status handling, but I haven't (yet) made an extension that does this nor does Buck expose this sort of functionality.
-  This approach would _just work_ for Bazel. I'll try and get the tool that's responsible for Buck integration open-sourced soon.
- On the testing side of things, I've used this in around my employer's Buck-powered monorepo and it's a nice experience. That being said, I can't think of an open-source repository where this can be tested in public, so you might need to trust me on this one.

I'd love to get feedback on:
- Naming of LSP extensions/new commands. I'm not too pleased with how "rust-analyzer: Add current file to workspace" is named, in that it's creating a _new_ workspace. I think that this command being added should be gated on `rust-analyzer.discoverProjectCommand` on being set, so I can add this in sequent commits.
- My Typescript. It's not particularly good.
- Suggestions on handling folders with _both_ Cargo and non-Cargo build systems and if I make activation a bit better.

(I previously tried to add this functionality entirely within rust-analyzer-the-LSP server itself, but matklad was right—an extension side approach is much, much easier.)
2023-03-14 17:48:49 +00:00
bors
6a98e961f8 Auto merge of #14340 - Veykril:expand, r=lnicola
internal: Rename AstDatabase to ExpandDatabase
2023-03-14 09:37:54 +00:00
David Barsky
677c0eeccb Add path of workspace root folders to status output 2023-03-13 14:45:41 -04:00
David Barsky
56273b3cf5 Remove rust-analyzer/addProject in favor of notifying r-a that configuration has changed 2023-03-13 13:30:19 -04:00
David Barsky
7a6e1119af Update crates/rust-analyzer/src/handlers.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2023-03-13 13:30:19 -04:00
David Barsky
8af3d6367e This commit add Cargo-style project discovery for Buck and Bazel users.
This feature requires the user to add a command that generates a
`rust-project.json` from a set of files. Project discovery can be invoked
in two ways:

1. At extension activation time, which includes the generated
   `rust-project.json` as part of the linkedProjects argument in
    InitializeParams
2. Through a new command titled "Add current file to workspace", which
   makes use of a new, rust-analyzer specific LSP request that adds
   the workspace without erasing any existing workspaces.

I think that the command-running functionality _could_ merit being
placed into its own extension (and expose it via extension contribution
points), if only provide build-system idiomatic progress reporting and
status handling, but I haven't (yet) made an extension that does this.
2023-03-13 13:30:18 -04:00
Lukas Wirth
9fb9ee3b6a internal: Rename AstDatabase to ExpandDatabase 2023-03-13 16:35:41 +01:00
Laurențiu Nicola
c3864eb511 Add and use rust-analyzer.cargo.extraArgs setting 2023-03-12 13:04:24 +02:00
Laurențiu Nicola
cfc9d5cd3b Pass flycheck extra args when running build scripts 2023-03-11 19:28:02 +02:00
Dan Johnson
2691143a67 Fix overlap deduping infinite loop
Fixes: 14276
2023-03-10 17:01:21 -08:00
Lukas Wirth
c03775e477 Fix is_quiescent reporting 2023-03-10 10:26:02 +01:00
Lukas Wirth
0d19ccb3df Make project loading errors less intrusive 2023-03-10 09:49:37 +01:00
Lukas Wirth
116775bc83 Don't attempt to calculate diagnostics in library crates 2023-03-10 09:08:20 +01:00
Lukas Wirth
b4bd27be90 Don't send error notifications for workspace failures if server status is supported 2023-03-08 13:18:44 +01:00
hkalbasi
ac04bfd7a7 Add View Mir command and fix some bugs 2023-03-06 21:09:09 +03:30
Lukas Wirth
800ab650ac split expression and pattern metrics 2023-03-04 09:21:17 +01:00
Lukas Wirth
c12fac698f Report type metrics for patterns 2023-03-03 21:08:45 +01:00
bors
6756294aa0 Auto merge of #14184 - lowr:feat/trait-alias-def, r=Veykril
Handle trait alias definitions

Part of #2773

This PR adds a bunch of structs and enum variants for trait aliases. Trait aliases should be handled as an independent item because they are semantically distinct from traits.

I basically started by adding `TraitAlias{Id, Loc}` to `hir_def::item_tree` and iterated adding necessary stuffs until compiler stopped complaining what's missing. Let me know if there's still anything I need to add.

I'm opening up this PR for early review and stuff. I'm planning to add tests for IDE functionalities in this PR, but not type-related support, for which I put FIXME notes.
2023-03-03 15:45:18 +00:00
Ryo Yoshida
29c957f973
Lower and handle trait aliases in HIR 2023-03-04 00:24:07 +09:00
Lukas Wirth
80ddfb89a2 fix: Load the sysroot in all CLI commands 2023-03-03 11:21:27 +01:00
bors
1d07c5bc25 Auto merge of #14218 - Veykril:root-dedup, r=Veykril
Deduplicate source roots that have overlapping include paths

Fixes flycheck not working for the rustc workspace when using `linkedProjects`
2023-02-28 11:09:27 +00:00