diff options
| author | Maybe Lapkin <waffle.lapkin@gmail.com> | 2024-07-05 22:35:14 +0200 |
|---|---|---|
| committer | Maybe Lapkin <waffle.lapkin@gmail.com> | 2024-07-05 22:35:14 +0200 |
| commit | 073f3a263b179ed446a1ab1209da9d9990bc6f74 (patch) | |
| tree | 93101be853a142e01be212f94be574301522e955 /tests/ui/cast | |
| parent | 56de9da1f8bbde9dad8ed79dcf45f73e08f0354f (diff) | |
| download | rust-073f3a263b179ed446a1ab1209da9d9990bc6f74.tar.gz rust-073f3a263b179ed446a1ab1209da9d9990bc6f74.zip | |
Equate types instead of using `Unsize`
Diffstat (limited to 'tests/ui/cast')
| -rw-r--r-- | tests/ui/cast/ptr-to-trait-obj-different-args.rs | 8 | ||||
| -rw-r--r-- | tests/ui/cast/ptr-to-trait-obj-different-args.stderr | 45 |
2 files changed, 27 insertions, 26 deletions
diff --git a/tests/ui/cast/ptr-to-trait-obj-different-args.rs b/tests/ui/cast/ptr-to-trait-obj-different-args.rs index 88632f5506b..c6038cfe864 100644 --- a/tests/ui/cast/ptr-to-trait-obj-different-args.rs +++ b/tests/ui/cast/ptr-to-trait-obj-different-args.rs @@ -18,14 +18,14 @@ fn main() { let b: *const dyn B = a as _; //~ error: casting `*const dyn A` as `*const dyn B` is invalid let x: *const dyn Trait<X> = &(); - let y: *const dyn Trait<Y> = x as _; //~ error: the trait bound `dyn Trait<X>: Unsize<dyn Trait<Y>>` is not satisfied + let y: *const dyn Trait<Y> = x as _; //~ error: mismatched types _ = (b, y); } fn generic<T>(x: *const dyn Trait<X>, t: *const dyn Trait<T>) { - let _: *const dyn Trait<T> = x as _; //~ error: the trait bound `dyn Trait<X>: Unsize<dyn Trait<T>>` is not satisfied - let _: *const dyn Trait<X> = t as _; //~ error: the trait bound `dyn Trait<T>: Unsize<dyn Trait<X>>` is not satisfied + let _: *const dyn Trait<T> = x as _; //~ error: mismatched types + let _: *const dyn Trait<X> = t as _; //~ error: mismatched types } trait Assocked { @@ -33,5 +33,5 @@ trait Assocked { } fn change_assoc(x: *mut dyn Assocked<Assoc = u8>) -> *mut dyn Assocked<Assoc = u32> { - x as _ //~ error: the trait bound `dyn Assocked<Assoc = u8>: Unsize<dyn Assocked<Assoc = u32>>` is not satisfied + x as _ //~ error: mismatched types } diff --git a/tests/ui/cast/ptr-to-trait-obj-different-args.stderr b/tests/ui/cast/ptr-to-trait-obj-different-args.stderr index 65f0be8541f..b04289ae747 100644 --- a/tests/ui/cast/ptr-to-trait-obj-different-args.stderr +++ b/tests/ui/cast/ptr-to-trait-obj-different-args.stderr @@ -6,47 +6,48 @@ LL | let b: *const dyn B = a as _; | = note: vtable kinds may not match -error[E0277]: the trait bound `dyn Trait<X>: Unsize<dyn Trait<Y>>` is not satisfied +error[E0308]: mismatched types --> $DIR/ptr-to-trait-obj-different-args.rs:21:34 | LL | let y: *const dyn Trait<Y> = x as _; - | ^^^^^^ the trait `Unsize<dyn Trait<Y>>` is not implemented for `dyn Trait<X>` + | ^^^^^^ expected `X`, found `Y` | - = note: all implementations of `Unsize` are provided automatically by the compiler, see <https://doc.rust-lang.org/stable/std/marker/trait.Unsize.html> for more information + = note: expected trait object `dyn Trait<X>` + found trait object `dyn Trait<Y>` -error[E0277]: the trait bound `dyn Trait<X>: Unsize<dyn Trait<T>>` is not satisfied +error[E0308]: mismatched types --> $DIR/ptr-to-trait-obj-different-args.rs:27:34 | +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 _; - | ^^^^^^ the trait `Unsize<dyn Trait<T>>` is not implemented for `dyn Trait<X>` + | ^^^^^^ expected `X`, found type parameter `T` | - = note: all implementations of `Unsize` are provided automatically by the compiler, see <https://doc.rust-lang.org/stable/std/marker/trait.Unsize.html> for more information -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | fn generic<T>(x: *const dyn Trait<X>, t: *const dyn Trait<T>) where dyn Trait<X>: Unsize<dyn Trait<T>> { - | ++++++++++++++++++++++++++++++++++++++++ + = note: expected trait object `dyn Trait<X>` + found trait object `dyn Trait<T>` -error[E0277]: the trait bound `dyn Trait<T>: Unsize<dyn Trait<X>>` is not satisfied +error[E0308]: mismatched types --> $DIR/ptr-to-trait-obj-different-args.rs:28:34 | +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 _; - | ^^^^^^ the trait `Unsize<dyn Trait<X>>` is not implemented for `dyn Trait<T>` - | - = note: all implementations of `Unsize` are provided automatically by the compiler, see <https://doc.rust-lang.org/stable/std/marker/trait.Unsize.html> for more information -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | ^^^^^^ expected type parameter `T`, found `X` | -LL | fn generic<T>(x: *const dyn Trait<X>, t: *const dyn Trait<T>) where dyn Trait<T>: Unsize<dyn Trait<X>> { - | ++++++++++++++++++++++++++++++++++++++++ + = note: expected trait object `dyn Trait<T>` + found trait object `dyn Trait<X>` -error[E0277]: the trait bound `dyn Assocked<Assoc = u8>: Unsize<dyn Assocked<Assoc = u32>>` is not satisfied +error[E0308]: mismatched types --> $DIR/ptr-to-trait-obj-different-args.rs:36:5 | LL | x as _ - | ^^^^^^ the trait `Unsize<dyn Assocked<Assoc = u32>>` is not implemented for `dyn Assocked<Assoc = u8>` + | ^^^^^^ expected `u8`, found `u32` | - = note: all implementations of `Unsize` are provided automatically by the compiler, see <https://doc.rust-lang.org/stable/std/marker/trait.Unsize.html> for more information + = note: expected trait object `dyn Assocked<Assoc = u8>` + found trait object `dyn Assocked<Assoc = u32>` error: aborting due to 5 previous errors -Some errors have detailed explanations: E0277, E0606. -For more information about an error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0308, E0606. +For more information about an error, try `rustc --explain E0308`. |
