-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #74650 - estebank:ambiguous-expr-binop, r=eddyb
- Loading branch information
Showing
9 changed files
with
63 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// This is not autofixable because we give extra suggestions to end the first expression with `;`. | ||
fn foo(a: Option<u32>, b: Option<u32>) -> bool { | ||
if let Some(x) = a { true } else { false } | ||
//~^ ERROR mismatched types | ||
//~| ERROR mismatched types | ||
&& //~ ERROR mismatched types | ||
if let Some(y) = a { true } else { false } | ||
} | ||
|
||
fn main() {} |
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,33 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/expr-as-stmt-2.rs:3:26 | ||
| | ||
LL | if let Some(x) = a { true } else { false } | ||
| ---------------------^^^^------------------ help: consider using a semicolon here | ||
| | | | ||
| | expected `()`, found `bool` | ||
| expected this to be `()` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/expr-as-stmt-2.rs:3:40 | ||
| | ||
LL | if let Some(x) = a { true } else { false } | ||
| -----------------------------------^^^^^--- help: consider using a semicolon here | ||
| | | | ||
| | expected `()`, found `bool` | ||
| expected this to be `()` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/expr-as-stmt-2.rs:6:5 | ||
| | ||
LL | fn foo(a: Option<u32>, b: Option<u32>) -> bool { | ||
| ---- expected `bool` because of return type | ||
LL | if let Some(x) = a { true } else { false } | ||
| ------------------------------------------ help: parentheses are required to parse this as an expression: `(if let Some(x) = a { true } else { false })` | ||
... | ||
LL | / && | ||
LL | | if let Some(y) = a { true } else { false } | ||
| |______________________________________________^ expected `bool`, found `&&bool` | ||
|
||
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
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