1 error[E0605]: non-primitive cast: `&dyn Foo<i32>` as `&dyn Bar<u32>`
2 --> $DIR/type-checking-test-2.rs:20:13
4 LL | let _ = x as &dyn Bar<u32>; // Error
5 | ^^^^^^^^^^^^^^^^^^ invalid cast
7 help: consider borrowing the value
9 LL | let _ = &x as &dyn Bar<u32>; // Error
12 error[E0277]: the trait bound `&dyn Foo<i32>: Bar<u32>` is not satisfied
13 --> $DIR/type-checking-test-2.rs:20:13
15 LL | let _ = x as &dyn Bar<u32>; // Error
16 | ^ the trait `Bar<u32>` is not implemented for `&dyn Foo<i32>`
18 = note: required for the cast from `&dyn Foo<i32>` to the object type `dyn Bar<u32>`
20 error[E0605]: non-primitive cast: `&dyn Foo<u32>` as `&dyn Bar<_>`
21 --> $DIR/type-checking-test-2.rs:26:13
23 LL | let a = x as &dyn Bar<_>; // Ambiguous
24 | ^^^^^^^^^^^^^^^^ invalid cast
26 help: consider borrowing the value
28 LL | let a = &x as &dyn Bar<_>; // Ambiguous
31 error[E0277]: the trait bound `&dyn Foo<u32>: Bar<_>` is not satisfied
32 --> $DIR/type-checking-test-2.rs:26:13
34 LL | let a = x as &dyn Bar<_>; // Ambiguous
35 | ^ the trait `Bar<_>` is not implemented for `&dyn Foo<u32>`
37 = note: required for the cast from `&dyn Foo<u32>` to the object type `dyn Bar<_>`
39 error: aborting due to 4 previous errors
41 Some errors have detailed explanations: E0277, E0605.
42 For more information about an error, try `rustc --explain E0277`.