Commit graph

27678 commits

Author SHA1 Message Date
David Barsky
c246a93046 completions: speed up completions by filtering non-applicable traits 2024-02-26 12:49:11 -05:00
bors
9f0495761a Auto merge of #16616 - Veykril:build-script-fix, r=Veykril
fix: server hanging up on build script task

This should fix https://github.com/rust-lang/rust-analyzer/issues/16614, can't say for certain since it might be not 100% reproducible... We really need to replace the current workspace fetching logic, it is completely unreadable and incredibly difficult to follow. I don't really understand how the server even got to hang here honestly (I would expect it to loop re-fetching build scripts, but not hang).
2024-02-20 14:58:03 +00:00
Lukas Wirth
9dee352da0 fix: server hanging up on build script task 2024-02-20 15:55:17 +01:00
bors
c8887241f9 Auto merge of #16606 - Veykril:hover-extern, r=Veykril
internal: Render assoc item owner in hover for items other than functions

Closes https://github.com/rust-lang/rust-analyzer/issues/16603
2024-02-20 13:51:47 +00:00
Lukas Wirth
85203d9721 Render assoc item owner in hover for items other than functions 2024-02-20 13:16:12 +01:00
bors
26a16c4d9b Auto merge of #16612 - Veykril:detached-files, r=Veykril
internal: Fetch toolchain and datalayout for DetachedFiles

My changes broke the rustc test runs since we use detached files for that, this should fix that. Also addresses some new nightly warnings wrt to unnecessary imports
2024-02-20 09:48:33 +00:00
Lukas Wirth
d93096ecc0 internal: Fetch toolchain and datalayout for DetachedFiles 2024-02-20 10:40:39 +01:00
Lukas Wirth
a822291a02 Infallible definition hovers 2024-02-19 18:16:02 +01:00
bors
2223b4fa71 Auto merge of #13112 - lowr:patch/auto-trait-bounds, r=Veykril
Setup infra for handling auto trait bounds disabled due to perf problems

This patch updates some of the partially-implemented functions of `ChalkContext as RustIrDatabase`, namely `adt_datum()` and `impl_provided_for()`. With those, we can now correctly work with auto trait bounds and distinguish methods based on them.

Resolves #7856 (the second code; the first one is resolved by #13074)

**IMPORTANT**: I don't think we want to merge this until #7637 is resolved. Currently this patch introduces A LOT of unknown types and type mismtaches as shown below. This is because we cannot resolve items like `hashbrown::HashMap` in `std` modules, leading to auto trait bounds on them and their dependents unprovable.

|crate (from `rustc-perf@c52ee6` except for r-a)|e3dc5a588f07d6f1d3a0f33051d4af26190abe9e|HEAD of this branch|
|---|---|---|
|rust-analyzer @ e3dc5a588f |exprs: 417528, ??ty: 907 (0%), ?ty: 114 (0%), !ty: 1|exprs: 417528, ??ty: 1704 (0%), ?ty: 403 (0%), !ty: 20|
|ripgrep|exprs: 62120, ??ty: 2 (0%), ?ty: 0 (0%), !ty: 0|exprs: 62120, ??ty: 132 (0%), ?ty: 58 (0%), !ty: 11|
|webrender/webrender|exprs: 94355, ??ty: 49 (0%), ?ty: 16 (0%), !ty: 2|exprs: 94355, ??ty: 429 (0%), ?ty: 130 (0%), !ty: 7|
|diesel|exprs: 132591, ??ty: 401 (0%), ?ty: 5129 (3%), !ty: 31|exprs: 132591, ??ty: 401 (0%), ?ty: 5129 (3%), !ty: 31|
2024-02-19 16:45:59 +00:00
Lukas Wirth
d2b27d09ea Don't populate rust_ir::AdtVariantDatum::fields for now due to perf 2024-02-19 17:38:03 +01:00
bors
bbb781ec1e Auto merge of #16589 - rosefromthedead:unresolved-ident, r=Veykril
feat: add unresolved-ident diagnostic

This should cover missing local variables and missing unit structs and the like. It's conservatively marked experimental
2024-02-19 15:27:41 +00:00
Lukas Wirth
1e448f84c3 Clippy 2024-02-19 16:26:22 +01:00
Rose Hudson
a492d9d164 feat: add unresolved-ident diagnostic 2024-02-19 14:12:18 +01:00
Rose Hudson
d818b531c9 internal: make check_diagnostics_with_disabled more ergonomic 2024-02-19 14:12:18 +01:00
bors
e6b96dba56 Auto merge of #16590 - davidsemakula:unnecessary-else-diagnostic-fix, r=Veykril
fix: Fix false positives for "unnecessary else" diagnostic

Completes https://github.com/rust-lang/rust-analyzer/pull/16567 by `@ShoyuVanilla` (see https://github.com/rust-lang/rust-analyzer/pull/16567#discussion_r1492700667)
Fixes #16556
2024-02-19 12:49:08 +00:00
davidsemakula
f2218e7278 refactor: remove body parameter for "unnecessary else" diagnostic 2024-02-19 15:35:47 +03:00
davidsemakula
7dfeb2cdcc refactor "unnecessary else" diagnostic test 2024-02-19 15:24:45 +03:00
davidsemakula
ff70310086 fix: only emit "unnecessary else" diagnostic for expr stmts 2024-02-19 15:24:45 +03:00
Shoyu Vanilla
1205853c36 Apply indent fix in #16575 2024-02-19 15:24:45 +03:00
Shoyu Vanilla
8f6e2127c3 Fix the remove unnecessary else action to preserve block tail expr 2024-02-19 15:24:45 +03:00
Shoyu Vanilla
21f4ff0351 Check for let expr ancestors instead of tail expr 2024-02-19 15:24:45 +03:00
Shoyu Vanilla
d14b22863b Handle cases for else if 2024-02-19 15:19:27 +03:00
Shoyu Vanilla
e9c80a9c25 fix: False positive diagnostic for necessary else 2024-02-19 15:19:27 +03:00
bors
ac1029fac3 Auto merge of #16489 - UserIsntAvailable:feat/use-import-alias, r=Veykril
feat!: create alias when renaming an import.

![gif](https://github.com/rust-lang/rust-analyzer/assets/57047985/c593d9a8-b8a0-4e13-9e50-a69c7d0d8749)

Closes #15858

Implemented:
- [x] - Prevent using `reserved` keywords (e.g self) and `_`.
- [x] - Rename other modules that might be referencing the import.
- [x] - Fix "broken" tests.
- [ ] - Rename **only** "direct" references.
- [ ] - Test more cases.

Future possibilities:
1. Also support `extern crate <name>` syntax.
2. Allow aliasing `self` when it is inside an `UseTreeList`.
~3. If import path already has an alias, "rename" the alias.~
~[4. Create alias even if path is not the last path segment.](https://github.com/rust-lang/rust-analyzer/pull/16489#issuecomment-1930541697)~
2024-02-19 12:03:31 +00:00
bors
ff8fe522e8 Auto merge of #16303 - rosefromthedead:non-exhaustive-let, r=Veykril
feat: add non-exhaustive-let diagnostic

I want this to have a quickfix to add an else branch but I couldn't figure out how to do that, so here's the diagnostic on its own. It pretends a `let` is a match with one arm, and asks the match checking whether that match would be exhaustive.

Previously the pattern was checked based on its own type, but that was causing a panic in `match_check` (while processing e.g. `crates/hir/src/lib.rs`) so I changed it to use the initialiser's type instead, to align with the checking of actual match expressions. I think the panic can still happen, but I hear that `match_check` is going to be updated to a new version from rustc, so I'm posting this now in the hopes that the panic will magically go away when that happens.
2024-02-19 11:51:06 +00:00
bors
d8c8ccc380 Auto merge of #16358 - krobelus:fix-redundant-references-with-macros, r=Veykril
Deduplicate references when some of them are in macro expansions

EDIT: I wonder if this is a regression, I'll try to investigate.

Commit 6a06f6f72 (Deduplicate reference search results, 2022-11-07)
deduplicates references within each definition.

Apparently our descend_into_macros() stanza returns
one definition for each time a name is used in a macro.
Each of those definitions has the same set of references.
We return them all, leading to many redundant references.

Work around this by deduplicating definitions as well.  Perhaps there
is a better fix to not produce duplicate definitions in the first
place.

I discovered this working with the "bitflags" macro from the crate
of the same name.

Fixes #16357
2024-02-19 11:38:14 +00:00
UserIsntAvailable
6dd5dc10ef test: fix disallow_renaming_for_non_local_definition to follow PR changes. 2024-02-19 12:38:00 +01:00
Rose Hudson
5390e4ce9b feat: add non-exhaustive-let diagnostic 2024-02-19 12:36:30 +01:00
Rose Hudson
69c25327f4 internal: reduce body lookups in expr diagnostics 2024-02-19 12:34:06 +01:00
UserIsntAvailable
6e16edb3bf feat: append as <name> when renaming inside an "UseTree".
test: include `rename_path_inside_use_tree`.

Keeps tracks the progress of the changes. 3 other tests broke with the changes
of this.

feat: rename all other usages within the current file.

feat: fix most of the implementation problems.

test: `rename_path_inside_use_tree` tests a more complicated scenario.
2024-02-19 12:24:36 +01:00
Lukas Wirth
91a8f34aee Deduplicate lsp locations 2024-02-19 12:23:59 +01:00
Johannes Altmanninger
30b992e95a Deduplicate references to macro argument
Commit 6a06f6f72 (Deduplicate reference search results, 2022-11-07) deduplicates references
within each definition.

There is an edge case when requesting references of a macro argument.  Apparently, our
descend_into_macros() stanza in references.rs produces a cartesian product of
- references inside the macro times
- times references outside the macro.

Since the above deduplication only applies to the references within a single definition, we
return them all, leading to many redundant references.

Work around this by deduplicating definitions as well.  Perhaps there is a better fix to not
produce this cartesian product in the first place; but I think at least for definitions the
problem would remain; a macro can contain multiple definitions of the same name, but since the
navigation target will be the unresolved location, it's the same for all of them.

We can't use unique() because we don't want to drop references that don't have a declaration
(though I dont' have an example for this case).

I discovered this working with the "bitflags" macro from the crate of the same name.

Fixes #16357
2024-02-19 12:23:59 +01:00
bors
60982dc8fc Auto merge of #16475 - DropDemBits:native-vscode-snippet-text-edit, r=Veykril
feat: Support multiple tab stops for completions in VSCode

Uses the native VSCode support for `SnippetTextEdit`s. Fixes #13229 and fixes #8531.

https://github.com/rust-lang/rust-analyzer/assets/13354275/a2d2c033-bb30-4f34-92ca-bf3f4f744cdc

This is done in a slightly hacky way, as `vscode-languageclient` can't convert RA's `SnippetTextEdit`s into vscode `SnippetTextEdit`s and will appear to use a [different format](295aaa393f/types/src/main.ts (L1501-L1516)) in the future.

---

~~Marked as draft since as-is, this will cause completions to double-indent any multi-line code generated.~~
**Update:** This also fixes up edits so that any multi-line code won't be double-indented.
2024-02-19 10:58:44 +00:00
bors
e7c9a76cb2 Auto merge of #16601 - Young-Flash:fix_typo_ci, r=Veykril
fix: checkout repo before run typos

I see some typos at lastest master :(
2024-02-19 10:45:51 +00:00
Young-Flash
f3d84e86c8 minor: fix typo 2024-02-19 18:12:08 +08:00
Young-Flash
af174b9428 internal: checkout repo before run typos 2024-02-19 18:09:33 +08:00
bors
68c506fd62 Auto merge of #16600 - lnicola:fix-release-3, r=lnicola
internal: Also downgrade node to 16

🙄
2024-02-19 07:27:01 +00:00
Laurențiu Nicola
8544e729f1 Also downgrade node to 16 2024-02-19 09:25:25 +02:00
bors
5390dbaa39 Auto merge of #16599 - lnicola:fix-release-2, r=lnicola
internal: Also downgrade actions/setup-node
2024-02-19 06:58:28 +00:00
Laurențiu Nicola
8ca834c86b Also downgrade actions/setup-node 2024-02-19 08:55:37 +02:00
bors
f71049bfb1 Auto merge of #16598 - lnicola:fix-release, r=lnicola
internal: Downgrade actions/checkout in release workflow
2024-02-19 06:34:06 +00:00
Laurențiu Nicola
591356738d Downgrade actions/checkout in release workflow 2024-02-19 08:32:33 +02:00
bors
14924b03ce Auto merge of #16597 - lnicola:sync-from-rust, r=lnicola
internal: Sync from downstream
2024-02-18 17:13:20 +00:00
Laurențiu Nicola
3aaaa1409f Merge branch 'master' into sync-from-rust 2024-02-18 19:10:56 +02:00
Laurențiu Nicola
6b17dba68c Merge commit 'ac998a74b3c8ff4b81c3eeb9a18811d4cc76226d' into sync-from-ra 2024-02-18 09:41:20 +02:00
bors
ac998a74b3 Auto merge of #16579 - DropDemBits:structured-snippet-fix-with-escaped-bits-and-cr, r=Veykril
fix: Fix snippets being placed leftwards of where they should be

Snippet bits were being escaped before placing snippets, shifting snippets leftwards. Snippets were also being shifted leftwards on files with CRLF line endings since they were placed done after the Unix -> DOS line ending conversion.

Hoping this fixes all of the little bugs related to snippet rendering 😅
2024-02-16 18:45:43 +00:00
bors
0932f89586 Auto merge of #16588 - compiler-errors:async-and-const-bounds, r=Veykril
internal: Parse (nightly) `const` and `async` trait bounds

Both of these bound modifiers were added recently:

* `const` trait bounds: https://github.com/rust-lang/rust/pull/119099
* `async` trait bounds: https://github.com/rust-lang/rust/pull/120392

The latter will certainly will not do the right thing; namely, `async Fn` needs to be mapped to the `AsyncFn` trait. IDK how to do that, so advice would be appreciated, though perhaps we could land this first so the parser isn't complaining about these bounds?
2024-02-16 16:25:22 +00:00
Michael Goulet
36020bb512 Update grammar
Bounds are CONSTNESS ASYNCNESS POLARITY
2024-02-16 16:16:37 +00:00
bors
25d12673db Auto merge of #16586 - Veykril:crate-graph-side-table, r=Veykril
fix: Remove cargo knowledge from `CrateData`

Fixes https://github.com/rust-lang/rust-analyzer/issues/16170, Fixes https://github.com/rust-lang/rust-analyzer/issues/15656
2024-02-16 16:04:14 +00:00
Michael Goulet
3e4deab3d8 Add support for const and async trait bounds 2024-02-16 16:00:04 +00:00