Commit Graph

24693 Commits

Author SHA1 Message Date
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
feniljain
a10372dac6 fix: use compute_type_match correctly and update tests accordingly 2023-03-14 11:41:25 +05:30
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
bors
544b4cfe4d Auto merge of #109069 - lnicola:rust-analyzer-2023-03-13, r=lnicola
⬆️ `rust-analyzer`

r? `@ghost`
2023-03-13 16:54:43 +00:00
Lukas Wirth
aaf08bdcc5 Shrink ProcMacroExpander size 2023-03-13 16:49:38 +01:00
Lukas Wirth
9fb9ee3b6a internal: Rename AstDatabase to ExpandDatabase 2023-03-13 16:35:41 +01:00
Lukas Wirth
228b44cb18 fix: Only skip adjustment hints for block, if and match expressions for reborrows 2023-03-13 16:10:49 +01:00
Swarnim Arun
cfbdf62344
fix: as suggested change remove_slice to as_slice 2023-03-13 17:28:37 +05:30
Lukas Wirth
cf95322541 Allow the status bar item to be clicked again 2023-03-13 12:32:53 +01:00
Swarnim Arun
34e3ea8cc8
feat: add remove_slice to hir::Type 2023-03-13 16:49:24 +05:30
Swarnim Arun
fe82649e77
feat: add is_float & is_char to hir::Type 2023-03-13 15:47:50 +05:30
Laurențiu Nicola
b2f6fd4f96 ⬆️ rust-analyzer 2023-03-13 10:42:24 +02:00
bors
9549753352 Auto merge of #14333 - lnicola:sync-from-rust, r=lnicola
minor: sync from downstream
2023-03-13 08:25:23 +00:00
Laurențiu Nicola
bdbd2a59b0 Merge branch 'master' into sync-from-rust 2023-03-13 10:21:53 +02:00
bors
f1e51afa45 Auto merge of #14328 - lnicola:build-scripts-extra-args, r=Veykril
fix: Pass flycheck extra args when running build scripts

Closes #14315

Not sure if we want to do it like this or to add an extra config key, though.
2023-03-12 15:19:29 +00:00