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.
Add regression test for rust-lang#94176
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Issue #94176: wrong span for the error message of a mismatched type error, | ||
// if the function uses a `let else` construct. | ||
#![feature(let_else)] | ||
|
||
pub fn test(a: Option<u32>) -> Option<u32> { //~ ERROR mismatched types | ||
let Some(_) = a else { return None; }; | ||
println!("Foo"); | ||
} | ||
|
||
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,19 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/issue-94176.rs:5:32 | ||
| | ||
LL | pub fn test(a: Option<u32>) -> Option<u32> { | ||
| ---- ^^^^^^^^^^^ expected enum `Option`, found `()` | ||
| | | ||
| implicitly returns `()` as its body has no tail or `return` expression | ||
| | ||
= note: expected enum `Option<u32>` | ||
found unit type `()` | ||
help: consider returning the local binding `a` | ||
| | ||
LL ~ println!("Foo"); | ||
LL + a | ||
| | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |