Skip to content

Commit

Permalink
Add regression test for #94176
Browse files Browse the repository at this point in the history
  • Loading branch information
est31 committed Aug 12, 2022
1 parent e3c5bd6 commit 9818526
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/test/ui/let-else/issue-94176.rs
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() {}
19 changes: 19 additions & 0 deletions src/test/ui/let-else/issue-94176.stderr
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`.

0 comments on commit 9818526

Please sign in to comment.