diff options
| author | bors <bors@rust-lang.org> | 2023-11-24 15:26:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-11-24 15:26:04 +0000 |
| commit | 4fd68eb47bad1c121417ac4450b2f0456150db86 (patch) | |
| tree | 3070883b9fd1824ad327f04f7be6b1a5e3fdc8a2 /tests | |
| parent | beebcdeb6fc778c2d082d545554b08183121b42e (diff) | |
| parent | c710db8ea7fb59ef90d854d2e1a5d9d93464b074 (diff) | |
| download | rust-4fd68eb47bad1c121417ac4450b2f0456150db86.tar.gz rust-4fd68eb47bad1c121417ac4450b2f0456150db86.zip | |
Auto merge of #117934 - Young-Flash:dev, r=petrochenkov
feat: make `let_binding_suggestion` more reasonable This is my first PR for rustc, which trying to fix https://github.com/rust-lang/rust/issues/117894, I am not familiar with some internal api so maybe some modification here isn't the way to go, appreciated for any review suggestion.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/suggestions/suggest-let-for-assignment.fixed | 6 | ||||
| -rw-r--r-- | tests/ui/suggestions/suggest-let-for-assignment.rs | 6 | ||||
| -rw-r--r-- | tests/ui/suggestions/suggest-let-for-assignment.stderr | 42 |
3 files changed, 50 insertions, 4 deletions
diff --git a/tests/ui/suggestions/suggest-let-for-assignment.fixed b/tests/ui/suggestions/suggest-let-for-assignment.fixed index 3a25e25eede..76dc1dad80a 100644 --- a/tests/ui/suggestions/suggest-let-for-assignment.fixed +++ b/tests/ui/suggestions/suggest-let-for-assignment.fixed @@ -7,6 +7,12 @@ fn main() { let x = "x"; //~ ERROR cannot find value `x` in this scope println!("x: {}", x); //~ ERROR cannot find value `x` in this scope + let some_variable = 6; //~ cannot find value `let_some_variable` in this scope + println!("some_variable: {}", some_variable); //~ ERROR cannot find value `some_variable` in this scope + + let other_variable = 6; //~ cannot find value `letother_variable` in this scope + println!("other_variable: {}", other_variable); //~ ERROR cannot find value `other_variable` in this scope + if x == "x" { //~^ ERROR cannot find value `x` in this scope println!("x is 1"); diff --git a/tests/ui/suggestions/suggest-let-for-assignment.rs b/tests/ui/suggestions/suggest-let-for-assignment.rs index 67705fe063a..f1edf65a726 100644 --- a/tests/ui/suggestions/suggest-let-for-assignment.rs +++ b/tests/ui/suggestions/suggest-let-for-assignment.rs @@ -7,6 +7,12 @@ fn main() { x = "x"; //~ ERROR cannot find value `x` in this scope println!("x: {}", x); //~ ERROR cannot find value `x` in this scope + let_some_variable = 6; //~ cannot find value `let_some_variable` in this scope + println!("some_variable: {}", some_variable); //~ ERROR cannot find value `some_variable` in this scope + + letother_variable = 6; //~ cannot find value `letother_variable` in this scope + println!("other_variable: {}", other_variable); //~ ERROR cannot find value `other_variable` in this scope + if x == "x" { //~^ ERROR cannot find value `x` in this scope println!("x is 1"); diff --git a/tests/ui/suggestions/suggest-let-for-assignment.stderr b/tests/ui/suggestions/suggest-let-for-assignment.stderr index 3f6a3da4be2..8d97dbeb14a 100644 --- a/tests/ui/suggestions/suggest-let-for-assignment.stderr +++ b/tests/ui/suggestions/suggest-let-for-assignment.stderr @@ -32,14 +32,48 @@ error[E0425]: cannot find value `x` in this scope LL | println!("x: {}", x); | ^ not found in this scope +error[E0425]: cannot find value `let_some_variable` in this scope + --> $DIR/suggest-let-for-assignment.rs:10:5 + | +LL | let_some_variable = 6; + | ^^^^^^^^^^^^^^^^^ + | +help: you might have meant to introduce a new binding + | +LL | let some_variable = 6; + | ~~~~~~~~~~~~~~~~~ + +error[E0425]: cannot find value `some_variable` in this scope + --> $DIR/suggest-let-for-assignment.rs:11:35 + | +LL | println!("some_variable: {}", some_variable); + | ^^^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find value `letother_variable` in this scope + --> $DIR/suggest-let-for-assignment.rs:13:5 + | +LL | letother_variable = 6; + | ^^^^^^^^^^^^^^^^^ + | +help: you might have meant to introduce a new binding + | +LL | let other_variable = 6; + | ~~~~~~~~~~~~~~~~~~ + +error[E0425]: cannot find value `other_variable` in this scope + --> $DIR/suggest-let-for-assignment.rs:14:36 + | +LL | println!("other_variable: {}", other_variable); + | ^^^^^^^^^^^^^^ not found in this scope + error[E0425]: cannot find value `x` in this scope - --> $DIR/suggest-let-for-assignment.rs:10:8 + --> $DIR/suggest-let-for-assignment.rs:16:8 | LL | if x == "x" { | ^ not found in this scope error[E0425]: cannot find value `y` in this scope - --> $DIR/suggest-let-for-assignment.rs:15:5 + --> $DIR/suggest-let-for-assignment.rs:21:5 | LL | y = 1 + 2; | ^ @@ -50,11 +84,11 @@ LL | let y = 1 + 2; | +++ error[E0425]: cannot find value `y` in this scope - --> $DIR/suggest-let-for-assignment.rs:16:23 + --> $DIR/suggest-let-for-assignment.rs:22:23 | LL | println!("y: {}", y); | ^ not found in this scope -error: aborting due to 7 previous errors +error: aborting due to 11 previous errors For more information about this error, try `rustc --explain E0425`. |
