mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Add regression test for #94176
This commit is contained in:
parent
e3c5bd617d
commit
981852677c
10
src/test/ui/let-else/issue-94176.rs
Normal file
10
src/test/ui/let-else/issue-94176.rs
Normal file
@ -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
src/test/ui/let-else/issue-94176.stderr
Normal file
19
src/test/ui/let-else/issue-94176.stderr
Normal file
@ -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`.
|
Loading…
Reference in New Issue
Block a user