rust/tests/ui/mismatched_types/issue-118145-unwrap-for-sho...

21 lines
378 B
Rust

//@ run-rustfix
#![allow(unused, dead_code)]
#[derive(Clone, Copy)]
struct Stuff {
count: i32,
}
struct Error;
fn demo() -> Result<Stuff, Error> {
let count = Ok(1);
Ok(Stuff { count: count? }) //~ ERROR mismatched types
}
fn demo_unwrap() -> Stuff {
let count = Some(1);
Stuff { count: count.expect("REASON") } //~ ERROR mismatched types
}
fn main() {}