]>
Commit | Line | Data |
---|---|---|
94222f64 | 1 | #![feature(trait_upcasting)] |
94222f64 XL |
2 | |
3 | trait Foo<T>: Bar<i32> + Bar<T> {} | |
4 | trait Bar<T> { | |
5 | fn bar(&self) -> Option<T> { | |
6 | None | |
7 | } | |
8 | } | |
9 | ||
10 | fn test_specific(x: &dyn Foo<i32>) { | |
11 | let _ = x as &dyn Bar<i32>; // OK | |
12 | } | |
13 | ||
14 | fn test_specific2(x: &dyn Foo<u32>) { | |
15 | let _ = x as &dyn Bar<i32>; // OK | |
16 | } | |
17 | ||
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 | |
22 | } | |
23 | ||
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 | |
28 | let _ = a.bar(); | |
29 | } | |
30 | ||
31 | fn main() {} |