Commit Graph

2001 Commits

Author SHA1 Message Date
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
Lukas Wirth
47a567b833 Deduplicate source roots that have overlapping include paths 2023-02-28 12:08:23 +01:00
bors
a0be16b0b2 Auto merge of #14040 - HKalbasi:mir, r=HKalbasi
Beginning of MIR

This pull request introduces the initial implementation of MIR lowering and interpreting in Rust Analyzer.

The implementation of MIR has potential to bring several benefits:
- Executing a unit test without compiling it: This is my main goal. It can be useful for quickly testing code changes and print-debugging unit tests without the need for a full compilation (ideally in almost zero time, similar to languages like python and js). There is a probability that it goes nowhere, it might become slower than rustc, or it might need some unreasonable amount of memory, or we may fail to support a common pattern/function that make it unusable for most of the codes.
- Constant evaluation: MIR allows for easier and more correct constant evaluation, on par with rustc. If r-a wants to fully support the type system, it needs full const eval, which means arbitrary code execution, which needs MIR or something similar.
- Supporting more diagnostics: MIR can be used to detect errors, most famously borrow checker and lifetime errors,  but also mutability errors and uninitialized variables, which can be difficult/impossible to detect in HIR.
- Lowering closures: With MIR we can find out closure capture modes, which is useful in detecting if a closure implements the `FnMut` or `Fn` traits, and calculating its size and data layout.

But the current PR implements no diagnostics and doesn't support closures. About const eval, I removed the old const eval code and it now uses the mir interpreter. Everything that is supported in stable rustc is either implemented or is super easy to implement. About interpreting unit tests, I added an experimental config, disabled by default, that shows a `pass` or `fail` on hover of unit tests (ideally it should be a button similar to `Run test` button, but I didn't figured out how to add them). Currently, no real world test works, due to missing features including closures, heap allocation, `dyn Trait` and ... so at this point it is only useful for me selecting what to implement next.

The implementation of MIR is based on the design of rustc, the data structures are almost copy paste (so it should be easy to migrate it to a possible future stable-mir), but the lowering and interpreting code is from me.
2023-02-28 09:12:19 +00:00
hkalbasi
cd67589f63 beginning of MIR 2023-02-27 23:45:54 +03:30
Laurențiu Nicola
563bd9c24a Try to improve the rustfmt.overrideCommand docs 2023-02-21 12:43:22 +02:00
Laurențiu Nicola
f40526b949 Remove file added by mistake 2023-02-21 09:05:19 +02:00
Lukas Wirth
404a51f26a internal: Make CompletionItem more POD-like 2023-02-16 09:29:55 +01:00
bors
a04054ac39 Auto merge of #14156 - Veykril:completion-pod, r=Veykril
internal: Don't reconstruct ref match completion in to_proto manually

cc https://github.com/rust-lang/rust-analyzer/issues/12571
2023-02-15 13:17:27 +00:00
Lukas Wirth
23fc596e40 Don't reconstruct ref match completion in to_proto manually 2023-02-15 14:15:22 +01:00
Laurențiu Nicola
6e5ec0b3ce Fix a pair of typos 2023-02-15 14:11:11 +02:00
Lukas Wirth
38144fd914 Bump lsp-types 2023-02-14 14:59:50 +01:00
Lukas Wirth
95fa278f30 Don't assume VSCode internal commands in the server 2023-02-14 14:45:48 +01:00
Aleksey Kladov
0da27376cf Support UTF-32 position encoding
Looks like this is a native encoding for Emacs at least!
2023-02-14 01:09:50 +00:00
bors
512a93ac94 Auto merge of #14100 - Veykril:load_cargo-proc-macro-srv-config, r=Veykril
Allow specifying what proc-macro server to run in rust_analyzer::load_cargo API

Closes https://github.com/rust-lang/rust-analyzer/issues/10516
2023-02-08 10:12:31 +00:00
Lukas Wirth
f03fb262f7 Allow specifying what proc-macro server to run in rust_analyzer::load_cargo API 2023-02-08 11:05:34 +01:00
bors
a05ce5a3e7 Auto merge of #13986 - MariaSolOs:limit-completions, r=Veykril
Add setting for limiting number of completions

For #13911.
2023-02-08 09:31:35 +00:00
Maria José Solano
064fcfa016 Sort and truncate final response 2023-02-07 18:41:28 -08:00
Pascal Kuthe
c7010eda1b
Support DidChangeWorkspaceFolders capability 2023-02-07 22:40:40 +01:00
Lukas Wirth
cb9a5b9549 Support sysroot library source being defined inside the workspace 2023-02-06 12:07:33 +01:00
Lukas Wirth
41a46a78f2 Make tt generic over the span data 2023-01-31 14:58:16 +01:00
bors
be76f357af Auto merge of #14034 - lnicola:tweak-change-collapsing, r=Veykril
internal: Tweak change collapsing

CC https://github.com/rust-lang/rust-analyzer/pull/14025#discussion_r1087946555.
2023-01-31 10:37:50 +00:00
Laurențiu Nicola
deff5f22f6 Tweak change collapsing 2023-01-29 17:20:22 +02: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
d712e52940 fix: Fix process-changes not deduplicating changes correctly 2023-01-25 15:01:15 +01:00
Ryo Yoshida
e9f14c505f
Remove TypeWalk and use TypeFlags instead 2023-01-24 19:44:58 +09:00