forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix rust-lang#101880: suggest let for assignment, and some code refactor
- Loading branch information
1 parent
dcb3761
commit eb68e27
Showing
6 changed files
with
165 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// run-rustfix | ||
|
||
fn main() { | ||
let demo = 1; //~ ERROR cannot find value `demo` in this scope | ||
dbg!(demo); //~ ERROR cannot find value `demo` in this scope | ||
|
||
let x = "x"; //~ ERROR cannot find value `x` in this scope | ||
println!("x: {}", x); //~ ERROR cannot find value `x` in this scope | ||
|
||
if x == "x" { | ||
//~^ ERROR cannot find value `x` in this scope | ||
println!("x is 1"); | ||
} | ||
|
||
let y = 1 + 2; //~ ERROR cannot find value `y` in this scope | ||
println!("y: {}", y); //~ ERROR cannot find value `y` in this scope | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// run-rustfix | ||
|
||
fn main() { | ||
demo = 1; //~ ERROR cannot find value `demo` in this scope | ||
dbg!(demo); //~ ERROR cannot find value `demo` in this scope | ||
|
||
x = "x"; //~ ERROR cannot find value `x` in this scope | ||
println!("x: {}", x); //~ ERROR cannot find value `x` in this scope | ||
|
||
if x == "x" { | ||
//~^ ERROR cannot find value `x` in this scope | ||
println!("x is 1"); | ||
} | ||
|
||
y = 1 + 2; //~ ERROR cannot find value `y` in this scope | ||
println!("y: {}", y); //~ ERROR cannot find value `y` in this scope | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
error[E0425]: cannot find value `demo` in this scope | ||
--> $DIR/suggest-let-for-assignment.rs:4:5 | ||
| | ||
LL | demo = 1; | ||
| ^^^^ | ||
| | ||
help: you might have meant to introduce a new binding | ||
| | ||
LL | let demo = 1; | ||
| +++ | ||
|
||
error[E0425]: cannot find value `demo` in this scope | ||
--> $DIR/suggest-let-for-assignment.rs:5:10 | ||
| | ||
LL | dbg!(demo); | ||
| ^^^^ not found in this scope | ||
|
||
error[E0425]: cannot find value `x` in this scope | ||
--> $DIR/suggest-let-for-assignment.rs:7:5 | ||
| | ||
LL | x = "x"; | ||
| ^ | ||
| | ||
help: you might have meant to introduce a new binding | ||
| | ||
LL | let x = "x"; | ||
| +++ | ||
|
||
error[E0425]: cannot find value `x` in this scope | ||
--> $DIR/suggest-let-for-assignment.rs:8:23 | ||
| | ||
LL | println!("x: {}", x); | ||
| ^ not found in this scope | ||
|
||
error[E0425]: cannot find value `x` in this scope | ||
--> $DIR/suggest-let-for-assignment.rs:10: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 | ||
| | ||
LL | y = 1 + 2; | ||
| ^ | ||
| | ||
help: you might have meant to introduce a new binding | ||
| | ||
LL | let y = 1 + 2; | ||
| +++ | ||
|
||
error[E0425]: cannot find value `y` in this scope | ||
--> $DIR/suggest-let-for-assignment.rs:16:23 | ||
| | ||
LL | println!("y: {}", y); | ||
| ^ not found in this scope | ||
|
||
error: aborting due to 7 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0425`. |