1 #![feature(trait_upcasting)]
3 trait Foo<T>: Bar<i32> + Bar<T> {}
5 fn bar(&self) -> Option<T> {
10 fn test_specific(x: &dyn Foo<i32>) {
11 let _ = x as &dyn Bar<i32>; // OK
14 fn test_specific2(x: &dyn Foo<u32>) {
15 let _ = x as &dyn Bar<i32>; // OK
18 fn test_specific3(x: &dyn Foo<i32>) {
19 let _ = x as &dyn Bar<u32>; // Error
20 //~^ ERROR non-primitive cast
21 //~^^ ERROR the trait bound `&dyn Foo<i32>: Bar<u32>` is not satisfied
24 fn test_infer_arg(x: &dyn Foo<u32>) {
25 let a = x as &dyn Bar<_>; // Ambiguous
26 //~^ ERROR non-primitive cast
27 //~^^ ERROR the trait bound `&dyn Foo<u32>: Bar<_>` is not satisfied