rust-analyzer/crates
bors 5ece16cf17 Auto merge of #17588 - CamWass:more-rename, r=Veykril
feat: Add incorrect case diagnostics for enum variant fields and all variables/params

Updates the incorrect case diagnostic to check:

1. Fields of enum variants. Example:
```rust
enum Foo {
    Variant { nonSnake: u8 }
}
```
2. All variable bindings, instead of just let bindings and certain match arm patters. Examples:
```rust
match 1 { nonSnake => () }
match 1 { nonSnake @ 1 => () }
match 1 { nonSnake1 @ nonSnake2 => () } // slightly cursed, but these both introduce new
                                        // bindings that are bound to the same value.

const ONE: i32 = 1;
match 1 { nonSnake @ ONE } //  ONE is ignored since it is not a binding

match Some(1) { Some(nonSnake) => () }

struct Foo { field: u8 }
match (Foo { field: 1 } ) {
    Foo { field: nonSnake } => ();
}

struct Foo { nonSnake: u8 } // diagnostic here, at definition
match (Foo { nonSnake: 1 } ) { // no diagnostic here...
    Foo { nonSnake } => ();    // ...or here, since these are not where the name is introduced
}

for nonSnake in [] {}

struct Foo(u8);
for Foo(nonSnake) in [] {}
```
3. All parameter bindings, instead of just top-level binding identifiers. Examples:
```rust
fn func(nonSnake: u8) {} // worked before

struct Foo { field: u8 }
fn func(Foo { field: nonSnake }: Foo) {} // now get diagnostic for nonSnake
```

This is accomplished by changing the way binding identifier patterns are filtered:
- Previously, all binding idents were skipped, except a few classes of "good" binding locations that were checked.
- Now, all binding idents are checked, except field shorthands which are skipped.

Moving from a whitelist to a blacklist potentially makes the analysis more brittle:
If new pattern types are added in the future where ident pats don't introduce new names, then they may incorrectly create diagnostics.

But the benefit of the blacklist approach is simplicity: I think a whitelist approach would need to recursively visit patterns to collect renaming candidates?
2024-07-15 10:07:37 +00:00
..
base-db Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00
cfg Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00
flycheck Add --keep-going to the check command 2024-07-07 18:37:02 +02:00
hir Use statics + clone instead of const until const can access statics 2024-07-14 17:52:59 +02:00
hir-def Fix stable iteration ordering for Map<Name, ...> usages 2024-07-15 11:25:46 +02:00
hir-expand Use statics + clone instead of const until const can access statics 2024-07-14 17:52:59 +02:00
hir-ty Auto merge of #17588 - CamWass:more-rename, r=Veykril 2024-07-15 10:07:37 +00:00
ide Auto merge of #17587 - joshka:jm/edit-name-after-refactor, r=Veykril 2024-07-15 09:53:39 +00:00
ide-assists Auto merge of #17587 - joshka:jm/edit-name-after-refactor, r=Veykril 2024-07-15 09:53:39 +00:00
ide-completion Fix stable iteration ordering for Map<Name, ...> usages 2024-07-15 11:25:46 +02:00
ide-db Auto merge of #17587 - joshka:jm/edit-name-after-refactor, r=Veykril 2024-07-15 09:53:39 +00:00
ide-diagnostics Auto merge of #17588 - CamWass:more-rename, r=Veykril 2024-07-15 10:07:37 +00:00
ide-ssr Auto merge of #17555 - Veykril:grammar-inline, r=Veykril 2024-07-07 09:21:04 +00:00
intern Fix stable iteration ordering for Map<Name, ...> usages 2024-07-15 11:25:46 +02:00
limit Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00
load-cargo fix: ensure there are no cycles in the source_root_parent_map 2024-06-20 13:46:14 +08:00
mbe Fix up the syntax tree for macro 2.0 2024-07-03 10:41:19 +02:00
parser Run codegen commands as tests if their results are commited 2024-07-07 09:14:50 +02:00
paths Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00
proc-macro-api Improve error message when the proc-macro server unexpectedly exits 2024-07-01 14:30:21 +02:00
proc-macro-srv Improve error message when the proc-macro server unexpectedly exits 2024-07-01 14:30:21 +02:00
proc-macro-srv-cli Abstract proc-macro-srv protocol format 2024-06-30 16:56:30 +02:00
profile Fix stop_watch on linux 2024-07-07 08:40:41 +02:00
project-model Remove version check before using --keep-going 2024-07-08 16:41:12 +02:00
rust-analyzer Address feedback from @DropDemBits 2024-07-13 19:33:35 -07:00
salsa Improve dead code analysis 2024-07-04 22:05:00 +08:00
span internal: Fix rustdoc warnings 2024-06-13 17:29:10 -07:00
stdx Merge from rust-lang/rust 2024-07-11 20:06:05 +03:00
syntax Add f16 and f128 support 2024-07-10 10:43:14 +01:00
test-fixture style: simplify string interpolation 2024-05-30 16:18:49 -07:00
test-utils Add f16 and f128 support 2024-07-10 10:43:14 +01:00
text-edit Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00
toolchain Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00
tt Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00
vfs Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00
vfs-notify Remove inline rust_2018_idioms, unused_lifetimes lint warn, Cargo.toml already enforces this 2024-06-30 15:23:54 +02:00