File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Issue #94176: wrong span for the error message of a mismatched type error,
2
+ // if the function uses a `let else` construct.
3
+ #![ feature( let_else) ]
4
+
5
+ pub fn test ( a : Option < u32 > ) -> Option < u32 > { //~ ERROR mismatched types
6
+ let Some ( _) = a else { return None ; } ;
7
+ println ! ( "Foo" ) ;
8
+ }
9
+
10
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0308]: mismatched types
2
+ --> $DIR/issue-94176.rs:5:32
3
+ |
4
+ LL | pub fn test(a: Option<u32>) -> Option<u32> {
5
+ | ---- ^^^^^^^^^^^ expected enum `Option`, found `()`
6
+ | |
7
+ | implicitly returns `()` as its body has no tail or `return` expression
8
+ |
9
+ = note: expected enum `Option<u32>`
10
+ found unit type `()`
11
+ help: consider returning the local binding `a`
12
+ |
13
+ LL ~ println!("Foo");
14
+ LL + a
15
+ |
16
+
17
+ error: aborting due to previous error
18
+
19
+ For more information about this error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments