summaryrefslogtreecommitdiffstats
path: root/tests/ui/traits/new-solver/dont-coerce-infer-to-dyn.rs
blob: c2ac80459caacc3dcb2dd1be8aff185efd0357e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// compile-flags: -Ztrait-solver=next
// check-pass

use std::fmt::Display;
use std::rc::Rc;

fn mk<T: ?Sized>(t: Option<&T>) -> Rc<T> {
    todo!()
}

fn main() {
    let mut x = None;
    let y = mk(x);
    // Don't treat the line below as a unsize coercion `Rc<?0> ~> Rc<dyn Display>`
    let z: Rc<dyn Display> = y;
    x = Some(&1 as &dyn Display);
}