-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #103636 - chenyukang:yukang/fix-103587-sugg-if-let, r=j…
…ackh276,davidtwco Recover from common if let syntax mistakes/typos Fixes #103587
- Loading branch information
Showing
11 changed files
with
184 additions
and
4 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
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,12 @@ | ||
fn main() { | ||
let x = Some(123); | ||
|
||
if let Some(_) == x {} | ||
//~^ ERROR expected `=`, found `==` | ||
|
||
if Some(_) = x {} | ||
//~^ ERROR mismatched types | ||
|
||
if None = x { } | ||
//~^ ERROR mismatched types | ||
} |
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,40 @@ | ||
error: expected `=`, found `==` | ||
--> $DIR/issue-103587.rs:4:20 | ||
| | ||
LL | if let Some(_) == x {} | ||
| ^^ | ||
| | ||
help: consider using `=` here | ||
| | ||
LL | if let Some(_) = x {} | ||
| ~ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-103587.rs:7:8 | ||
| | ||
LL | if Some(_) = x {} | ||
| ^^^^^^^^^^^ expected `bool`, found `()` | ||
| | ||
help: consider adding `let` | ||
| | ||
LL | if let Some(_) = x {} | ||
| +++ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-103587.rs:10:8 | ||
| | ||
LL | if None = x { } | ||
| ^^^^^^^^ expected `bool`, found `()` | ||
| | ||
help: you might have meant to use pattern matching | ||
| | ||
LL | if let None = x { } | ||
| +++ | ||
help: you might have meant to compare for equality | ||
| | ||
LL | if None == x { } | ||
| + | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
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