rust/tests/ui/cast/ptr-to-trait-obj-different-args.stderr

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
2.4 KiB
Plaintext
Raw Normal View History

error[E0606]: casting `*const dyn A` as `*const dyn B` is invalid
2024-06-04 15:21:09 +02:00
--> $DIR/ptr-to-trait-obj-different-args.rs:18:27
|
LL | let b: *const dyn B = a as _;
| ^^^^^^
|
= note: vtable kinds may not match
2024-07-05 22:35:14 +02:00
error[E0308]: mismatched types
2024-06-04 15:21:09 +02:00
--> $DIR/ptr-to-trait-obj-different-args.rs:21:34
|
LL | let y: *const dyn Trait<Y> = x as _;
2024-07-05 22:35:14 +02:00
| ^^^^^^ expected `X`, found `Y`
|
2024-07-05 22:35:14 +02:00
= note: expected trait object `dyn Trait<X>`
found trait object `dyn Trait<Y>`
= help: `dyn Trait<Y>` implements `Trait` so you could box the found value and coerce it to the trait object `Box<dyn Trait>`, you will have to change the expected type as well
2024-07-05 22:35:14 +02:00
error[E0308]: mismatched types
2024-06-04 15:21:09 +02:00
--> $DIR/ptr-to-trait-obj-different-args.rs:27:34
|
2024-07-05 22:35:14 +02:00
LL | fn generic<T>(x: *const dyn Trait<X>, t: *const dyn Trait<T>) {
| - found this type parameter
LL | let _: *const dyn Trait<T> = x as _;
2024-07-05 22:35:14 +02:00
| ^^^^^^ expected `X`, found type parameter `T`
|
2024-07-05 22:35:14 +02:00
= note: expected trait object `dyn Trait<X>`
found trait object `dyn Trait<T>`
= help: `dyn Trait<T>` implements `Trait` so you could box the found value and coerce it to the trait object `Box<dyn Trait>`, you will have to change the expected type as well
2024-07-05 22:35:14 +02:00
error[E0308]: mismatched types
2024-06-04 15:21:09 +02:00
--> $DIR/ptr-to-trait-obj-different-args.rs:28:34
|
2024-07-05 22:35:14 +02:00
LL | fn generic<T>(x: *const dyn Trait<X>, t: *const dyn Trait<T>) {
| - expected this type parameter
LL | let _: *const dyn Trait<T> = x as _;
LL | let _: *const dyn Trait<X> = t as _;
2024-07-05 22:35:14 +02:00
| ^^^^^^ expected type parameter `T`, found `X`
|
2024-07-05 22:35:14 +02:00
= note: expected trait object `dyn Trait<T>`
found trait object `dyn Trait<X>`
= help: `dyn Trait<X>` implements `Trait` so you could box the found value and coerce it to the trait object `Box<dyn Trait>`, you will have to change the expected type as well
2024-07-05 22:35:14 +02:00
error[E0308]: mismatched types
2024-06-04 15:21:09 +02:00
--> $DIR/ptr-to-trait-obj-different-args.rs:36:5
|
LL | x as _
2024-07-05 22:35:14 +02:00
| ^^^^^^ expected `u8`, found `u32`
|
2024-07-05 22:35:14 +02:00
= note: expected trait object `dyn Assocked<Assoc = u8>`
found trait object `dyn Assocked<Assoc = u32>`
error: aborting due to 5 previous errors
2024-07-05 22:35:14 +02:00
Some errors have detailed explanations: E0308, E0606.
For more information about an error, try `rustc --explain E0308`.