about summary refs log tree commit diff
path: root/tests/ui/coercion/unboxing-needing-parenthases-issue-132924.rs
blob: fc4258fc0af8988bd6a0a03173eb50025fa061c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//@ check-fail
fn main() {
    let x = Box::new(Some(1));

    let test: Option<i32> = x;
    //~^ ERROR mismatched types
    let x = Box::new(Some(1));
    let test: Option<i32> = { x as Box<Option<i32>> };
    //~^ ERROR mismatched types

    let x = Box::new(Some(1));
    let test: Option<i32> = if true { x as Box<Option<i32>> } else { None };
    //~^ ERROR mismatched types

    let x = std::rc::Rc::new(Some(1));
    let test: Option<i32> = x as std::rc::Rc<Option<i32>>;
    //~^ ERROR mismatched types
}