mirror of
https://github.com/rust-lang/rust
synced 2024-09-06 01:11:17 +00:00
![Esteban Küber](/assets/img/avatar_default.png)
When encountering code like ```rust fn foo() -> i32 { match 0 { 1 => return 0, 2 => "", _ => 1, } } ``` Point at the return type and not at the prior arm, as that arm has type `!` which isn't influencing the arm corresponding to arm `2`. Fix #78124.
22 lines
522 B
Rust
22 lines
522 B
Rust
#![allow(unused)]
|
|
|
|
fn test(shouldwe: Option<u32>, shouldwe2: Option<u32>) -> u32 {
|
|
//~^ NOTE expected `u32` because of return type
|
|
match shouldwe {
|
|
Some(val) => {
|
|
match shouldwe2 {
|
|
Some(val) => {
|
|
return val;
|
|
}
|
|
None => (), //~ ERROR mismatched types
|
|
//~^ NOTE expected `u32`, found `()`
|
|
}
|
|
}
|
|
None => return 12,
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
println!("returned {}", test(None, Some(5)));
|
|
}
|