1 #![feature(trait_upcasting)]
3 trait Foo: Bar<i32> + Bar<u32> {}
5 fn bar(&self) -> Option<T> {
10 fn test_specific(x: &dyn Foo) {
11 let _ = x as &dyn Bar<i32>; // OK
12 let _ = x as &dyn Bar<u32>; // OK
15 fn test_unknown_version(x: &dyn Foo) {
16 let _ = x as &dyn Bar<_>; // Ambiguous
17 //~^ ERROR non-primitive cast
18 //~^^ ERROR the trait bound `&dyn Foo: Bar<_>` is not satisfied
21 fn test_infer_version(x: &dyn Foo) {
22 let a = x as &dyn Bar<_>; // OK
23 let _: Option<u32> = a.bar();