Commit Graph

24503 Commits

Author SHA1 Message Date
Zachary S
6746a08b44 fix: Fix return type of async closures.
(rebased onto 6dfd8ae)
2023-03-15 13:10:00 +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
579797f0ec Auto merge of #14357 - Veykril:rustc-priv, r=Veykril
fix: Don't pass feature flags to rustc private crates metadata invocation

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

Better error reporting I'll do in a follow up
2023-03-15 10:00:23 +00: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
e611fbe6ab Auto merge of #14355 - Veykril:completion-ref-strip, r=Veykril
fix: Fix reference completions being emitted in places other than argument lists

Fixes https://github.com/rust-lang/rust-analyzer/issues/14331
2023-03-15 09:47:20 +00:00
Lukas Wirth
82ed68c95e fix: Fix reference completions being emitted in places other than argument lists 2023-03-15 10:41:17 +01:00
bors
1a318965fe Auto merge of #14353 - lowr:fix/inline-call-bad-ast, r=Veykril
fix: don't replace `SyntaxToken` with `SyntaxNode`

Fixes #14339

When we inline method calls, we replace the `self` parameter with a local variable `this`. We have been replacing the `self` **tokens** with `NameRef` **nodes**, which makes the AST malformed. This leads to crash when we apply path transformation after the replacement (which only takes place when the method is generic and such scenario was not tested).
2023-03-15 09:32:34 +00:00
bors
05f95cbb0c Auto merge of #14354 - Veykril:sighelp, r=Veykril
feat: Add signature help for record and tuple struct patterns
2023-03-15 09:19:13 +00:00
Lukas Wirth
55120b3d83 Add signature help for tuple struct patterns 2023-03-15 10:17:30 +01:00
Ryo Yoshida
01bf0725b1
fix: don't replace SyntaxToken with SyntaxNode 2023-03-15 17:18:09 +09:00
bors
60548db111 Auto merge of #14281 - XFFXFF:fix_missing_unsafe, r=Veykril
feat: add an autofix for inserting an unsafe block to missing unsafe diagnostic

close #14241
2023-03-15 07:00:38 +00:00
XFFXFF
0c935732bc do not offer fixit for macro expansions and refactor the code 2023-03-15 09:12:40 +08:00
XFFXFF
bf0322cd0c pick the best ancestor expr of unsafe expr to add unsafe block. Thanks! @Veykril 2023-03-15 09:07:11 +08:00
XFFXFF
82780d8caf feat: add an autofix for inserting an unsafe block to missing unsafe diagnostic 2023-03-15 09:07:11 +08:00
Lukas Wirth
03a6ab0b62 Add signature help for record struct patterns 2023-03-14 21:55:03 +01:00
bors
b4d7ea0692 Auto merge of #13994 - Veykril:incoherent-impl, r=Veykril
lint incoherent inherent impls
2023-03-14 19:57:01 +00:00
Lukas Wirth
510e4b4029 Simplify 2023-03-14 20:22:11 +01:00
Lukas Wirth
610a94c421 Add fundamental attributes to data 2023-03-14 20:16:41 +01:00
Lukas Wirth
2c364f6e5a Fix tests 2023-03-14 19:55:20 +01:00
Lukas Wirth
f34b2469bd lint incoherent inherent impls 2023-03-14 19:20:44 +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
David Barsky
6e7bc07cdf fix: don't override linkedProjects if no workspace was discovered. 2023-03-14 13:36:21 -04:00
David Barsky
bd545a1c10 Address review comments 2023-03-14 12:49:35 -04:00
bors
ad91622d11 Auto merge of #14338 - Veykril:inlay-adjust, r=Veykril
fix: Only skip adjustment hints for block, if and match expressions for reborrows

cc https://github.com/rust-lang/rust-analyzer/pull/13749
2023-03-14 14:16:51 +00:00
bors
74303a3774 Auto merge of #14349 - Veykril:vis-res, r=Veykril
fix: Fix visibility resolution not respecting parent blocks

Fixes https://github.com/rust-lang/rust-analyzer/issues/14047
2023-03-14 12:43:11 +00:00
Lukas Wirth
1a9fbf0a6d fix: Fix visibility resolution not respecting parent blocks 2023-03-14 13:42:08 +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
bors
6a98e961f8 Auto merge of #14340 - Veykril:expand, r=lnicola
internal: Rename AstDatabase to ExpandDatabase
2023-03-14 09:37:54 +00:00
bors
def4dbb520 Auto merge of #14336 - swarnimarun:remove-slice, r=lnicola
internal: add `as_slice` to `hir::Type`

~`remove_slice`~ `as_slice` is same as `remove_ref` but for slices.

Though there is `as_array` which I believe was named such because it also gets the length of the array, maybe. I am still shaky on the names feel free to suggest corrections.
2023-03-14 09:20:58 +00:00
bors
57803753b0 Auto merge of #14347 - HKalbasi:dev, r=lnicola
Add storage dead for let bindings without initializer

fix #14344
2023-03-14 09:05:36 +00:00
hkalbasi
d7da9e64d1 Add storage dead for let bindings without initializer 2023-03-14 12:15:16 +03:30
bors
4cbb940cc4 Auto merge of #14337 - Veykril:vscode-status, r=lnicola
internal: Allow the status bar item to be clicked again

And give that the most useful action for the given state.
2023-03-14 07:23:17 +00:00
bors
057857ec23 Auto merge of #14334 - swarnimarun:is-float-char, r=lnicola
feat: add `is_float` & `is_char` to `hir::Type`

Some useful functions we didn't have on `Type` (were present on `BuiltinType`).

Also, I am considering exposing `TyKind` with `get_kind`, let me know if that's a better idea than implementing these API extensions incrementally.
2023-03-14 06:56:46 +00:00
bors
3ba7501dd0 Auto merge of #14342 - davidbarsky:davidbarsky/add-workspace-source-to-status, r=lnicola
Add path of workspace root folders to status output

Hi folks! Just a quick addition to the status output. There are some colleagues of mine who use a mix of Buck and Cargo. A person spent a bit of time this past week trying to figure out there the `rust-project.json` was coming from and pointed out that `rust-analyzer: Status` could be a good place to put this information. rust-analyzer doesn't seem to record the full path of the `Cargo.toml` or the `rust-project.json`, just the root directory. While not perfect, this should be enough for people to unblock themselves on. Here's an example of `rust-analyzer: Status` on the rust-analyzer repo:

```
Workspaces:
Loaded 192 packages across 1 workspace.
Workspace roots: [AbsPath("/Users/dbarsky/Developer/rust-analyzer")]
Analysis:
57mb of files
0b of index symbols (0)
2514 trees, 128 preserved
29535 trees, 128 preserved (Macros)
0b in total

File info:
Crate: rust_analyzer(CrateId(131))
Dependencies: proc_macro=CrateId(5), core=CrateId(2), alloc=CrateId(0), std=CrateId(7), test=CrateId(9), always_assert=CrateId(12), anyhow=CrateId(13), cfg=CrateId(25), crossbeam_channel=CrateId(35), dissimilar=CrateId(41), expect_test=CrateId(46), flycheck=CrateId(50), hir=CrateId(56), hir_def=CrateId(57), hir_ty=CrateId(59), ide=CrateId(63), ide_db=CrateId(66), ide_ssr=CrateId(68), itertools=CrateId(73), jod_thread=CrateId(75), lsp_server=CrateId(83), lsp_types=CrateId(85), mbe=CrateId(87), num_cpus=CrateId(96), oorandom=CrateId(99), parking_lot=CrateId(102), proc_macro_api=CrateId(110), proc_macro_srv=CrateId(111), profile=CrateId(118), project_model=CrateId(119), rayon=CrateId(125), rustc_hash=CrateId(136), scip=CrateId(141), serde=CrateId(145), serde_json=CrateId(147), sourcegen=CrateId(153), stdx=CrateId(155), syntax=CrateId(158), test_utils=CrateId(159), threadpool=CrateId(165), toolchain=CrateId(170), tracing=CrateId(171), tracing_log=CrateId(174), tracing_subscriber=CrateId(175), tracing_tree=CrateId(176), tt=CrateId(177), vfs=CrateId(188), vfs_notify=CrateId(189), xflags=CrateId(192), xshell=CrateId(194)
```
2023-03-14 06:43:45 +00:00
bors
ce4f79f327 Auto merge of #14345 - lnicola:sync-from-rust, r=lnicola
minor: Sync from downstream
2023-03-14 06:17:40 +00:00
Laurențiu Nicola
3b6db2246b Merge branch 'master' into sync-from-rust 2023-03-14 08:16:40 +02:00
David Barsky
78aed305e1 rename "addProject" command 2023-03-13 15:37:58 -04:00
David Barsky
677c0eeccb Add path of workspace root folders to status output 2023-03-13 14:45:41 -04:00
David Barsky
cb93c12c31 fmt 2023-03-13 13:33:39 -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
8d9bff0c74 Add a workspace config-based approach to reloading discovered projects. 2023-03-13 13:30:19 -04:00
David Barsky
91371494ee move rust-analyzer.discoverProjectCommand above $generated-start to avoid failing tests 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
68d3eaead4 fix typo in package.json. 2023-03-13 13:30:19 -04:00
David Barsky
1f5c535089 remove errant -- in executeDiscoverProject 2023-03-13 13:30:19 -04:00
David Barsky
46e022098f fmt 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