about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-07-08 16:01:38 +0000
committerbors <bors@rust-lang.org>2024-07-08 16:01:38 +0000
commita06e9c83f6bc6b9b69f1b0d9f1ab659f8f03db4d (patch)
tree5cfc3f26bad3ba0c2e488a4ab4902166a3eb7783 /tests
parentcfd7cf5a0e497c238dcf9947e2eeec01837beeb4 (diff)
parenta659f7a2bcefccb1a945656743a853ca0ac98c67 (diff)
downloadrust-a06e9c83f6bc6b9b69f1b0d9f1ab659f8f03db4d.tar.gz
rust-a06e9c83f6bc6b9b69f1b0d9f1ab659f8f03db4d.zip
Auto merge of #127486 - matthiaskrgr:rollup-lvv018b, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #120248 (Make casts of pointers to trait objects stricter)
 - #127355 (Mark format! with must_use hint)
 - #127399 (Verify that allocations output by GVN are sufficiently aligned.)
 - #127460 (clarify `sys::unix::fd::FileDesc::drop` comment)
 - #127467 (bootstrap: once_cell::sync::Lazy -> std::sync::LazyLock)

Failed merges:

 - #127357 (Remove `StructuredDiag`)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'tests')
-rw-r--r--tests/pretty/issue-4264.pp21
-rw-r--r--tests/ui/cast/cast-rfc0401-vtable-kinds.rs18
-rw-r--r--tests/ui/cast/cast-rfc0401-vtable-kinds.stderr2
-rw-r--r--tests/ui/cast/ptr-to-trait-obj-add-auto.rs18
-rw-r--r--tests/ui/cast/ptr-to-trait-obj-add-auto.stderr43
-rw-r--r--tests/ui/cast/ptr-to-trait-obj-add-super-auto.rs9
-rw-r--r--tests/ui/cast/ptr-to-trait-obj-different-args.rs37
-rw-r--r--tests/ui/cast/ptr-to-trait-obj-different-args.stderr53
-rw-r--r--tests/ui/cast/ptr-to-trait-obj-different-regions-id-trait.rs27
-rw-r--r--tests/ui/cast/ptr-to-trait-obj-different-regions-id-trait.stderr15
-rw-r--r--tests/ui/cast/ptr-to-trait-obj-different-regions-lt-ext.rs31
-rw-r--r--tests/ui/cast/ptr-to-trait-obj-different-regions-lt-ext.stderr10
-rw-r--r--tests/ui/cast/ptr-to-trait-obj-different-regions-misc.rs37
-rw-r--r--tests/ui/cast/ptr-to-trait-obj-different-regions-misc.stderr136
-rw-r--r--tests/ui/cast/ptr-to-trait-obj-ok.rs17
-rw-r--r--tests/ui/cast/ptr-to-trait-obj-wrap-upcast.rs14
-rw-r--r--tests/ui/cast/ptr-to-trait-obj-wrap-upcast.stderr11
-rw-r--r--tests/ui/deriving/deriving-in-fn.rs2
-rw-r--r--tests/ui/fmt/struct-field-as-captured-argument.fixed14
-rw-r--r--tests/ui/fmt/struct-field-as-captured-argument.rs14
-rw-r--r--tests/ui/fmt/struct-field-as-captured-argument.stderr70
-rw-r--r--tests/ui/issues/issue-20676.rs2
-rw-r--r--tests/ui/mir/alignment/misaligned-constant-gvn.rs8
-rw-r--r--tests/ui/mismatched_types/cast-rfc0401.rs2
-rw-r--r--tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.fixed4
-rw-r--r--tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.rs4
-rw-r--r--tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.stderr10
-rw-r--r--tests/ui/traits/upcast_soundness_bug.rs8
-rw-r--r--tests/ui/traits/upcast_soundness_bug.stderr13
29 files changed, 557 insertions, 93 deletions
diff --git a/tests/pretty/issue-4264.pp b/tests/pretty/issue-4264.pp
index 018ccf82dae..fa958d9f1e8 100644
--- a/tests/pretty/issue-4264.pp
+++ b/tests/pretty/issue-4264.pp
@@ -29,16 +29,17 @@ fn bar() ({
 
 
 
-    ({
-        let res =
-            ((::alloc::fmt::format as
-                    for<'a> fn(Arguments<'a>) -> String {format})(((format_arguments::new_const
-                        as
-                        fn(&[&'static str; 1]) -> Arguments<'_> {Arguments::<'_>::new_const::<1>})((&([("test"
-                                    as &str)] as [&str; 1]) as &[&str; 1])) as Arguments<'_>))
-                as String);
-        (res as String)
-    } as String);
+    ((::alloc::__export::must_use as
+            fn(String) -> String {must_use::<String>})(({
+            let res =
+                ((::alloc::fmt::format as
+                        for<'a> fn(Arguments<'a>) -> String {format})(((format_arguments::new_const
+                            as
+                            fn(&[&'static str; 1]) -> Arguments<'_> {Arguments::<'_>::new_const::<1>})((&([("test"
+                                        as &str)] as [&str; 1]) as &[&str; 1])) as Arguments<'_>))
+                    as String);
+            (res as String)
+        } as String)) as String);
 } as ())
 type Foo = [i32; (3 as usize)];
 struct Bar {
diff --git a/tests/ui/cast/cast-rfc0401-vtable-kinds.rs b/tests/ui/cast/cast-rfc0401-vtable-kinds.rs
index 0d8f92f013f..5704a33cc87 100644
--- a/tests/ui/cast/cast-rfc0401-vtable-kinds.rs
+++ b/tests/ui/cast/cast-rfc0401-vtable-kinds.rs
@@ -4,25 +4,12 @@
 
 #![feature(unsized_tuple_coercion)]
 
-trait Foo<T> {
-    fn foo(&self, _: T) -> u32 { 42 }
-}
-
 trait Bar { //~ WARN trait `Bar` is never used
     fn bar(&self) { println!("Bar!"); }
 }
 
-impl<T> Foo<T> for () {}
-impl Foo<u32> for u32 { fn foo(&self, _: u32) -> u32 { self+43 } }
 impl Bar for () {}
 
-unsafe fn round_trip_and_call<'a>(t: *const (dyn Foo<u32>+'a)) -> u32 {
-    let foo_e : *const dyn Foo<u32> = t as *const _;
-    let r_1 = foo_e as *mut dyn Foo<u32>;
-
-    (&*r_1).foo(0)
-}
-
 #[repr(C)]
 struct FooS<T:?Sized>(T);
 #[repr(C)]
@@ -38,11 +25,6 @@ fn tuple_i32_to_u32<T:?Sized>(u: *const (i32, T)) -> *const (u32, T) {
 
 
 fn main() {
-    let x = 4u32;
-    let y : &dyn Foo<u32> = &x;
-    let fl = unsafe { round_trip_and_call(y as *const dyn Foo<u32>) };
-    assert_eq!(fl, (43+4));
-
     let s = FooS([0,1,2]);
     let u: &FooS<[u32]> = &s;
     let u: *const FooS<[u32]> = u;
diff --git a/tests/ui/cast/cast-rfc0401-vtable-kinds.stderr b/tests/ui/cast/cast-rfc0401-vtable-kinds.stderr
index 952687e98d0..4f57e2e7df7 100644
--- a/tests/ui/cast/cast-rfc0401-vtable-kinds.stderr
+++ b/tests/ui/cast/cast-rfc0401-vtable-kinds.stderr
@@ -1,5 +1,5 @@
 warning: trait `Bar` is never used
-  --> $DIR/cast-rfc0401-vtable-kinds.rs:11:7
+  --> $DIR/cast-rfc0401-vtable-kinds.rs:7:7
    |
 LL | trait Bar {
    |       ^^^
diff --git a/tests/ui/cast/ptr-to-trait-obj-add-auto.rs b/tests/ui/cast/ptr-to-trait-obj-add-auto.rs
new file mode 100644
index 00000000000..46e72ea0877
--- /dev/null
+++ b/tests/ui/cast/ptr-to-trait-obj-add-auto.rs
@@ -0,0 +1,18 @@
+//@ check-pass
+
+trait Trait<'a> {}
+
+fn add_auto<'a>(x: *mut dyn Trait<'a>) -> *mut (dyn Trait<'a> + Send) {
+    x as _
+    //~^ warning: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
+    //~| warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+}
+
+// (to test diagnostic list formatting)
+fn add_multiple_auto<'a>(x: *mut dyn Trait<'a>) -> *mut (dyn Trait<'a> + Send + Sync + Unpin) {
+    x as _
+    //~^ warning: adding auto traits `Send`, `Sync`, and `Unpin` to a trait object in a pointer cast may cause UB later on
+    //~| warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+}
+
+fn main() {}
diff --git a/tests/ui/cast/ptr-to-trait-obj-add-auto.stderr b/tests/ui/cast/ptr-to-trait-obj-add-auto.stderr
new file mode 100644
index 00000000000..e5ef8bf76b4
--- /dev/null
+++ b/tests/ui/cast/ptr-to-trait-obj-add-auto.stderr
@@ -0,0 +1,43 @@
+warning: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
+  --> $DIR/ptr-to-trait-obj-add-auto.rs:6:5
+   |
+LL |     x as _
+   |     ^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #127323 <https://github.com/rust-lang/rust/issues/127323>
+   = note: `#[warn(ptr_cast_add_auto_to_object)]` on by default
+
+warning: adding auto traits `Send`, `Sync`, and `Unpin` to a trait object in a pointer cast may cause UB later on
+  --> $DIR/ptr-to-trait-obj-add-auto.rs:13:5
+   |
+LL |     x as _
+   |     ^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #127323 <https://github.com/rust-lang/rust/issues/127323>
+
+warning: 2 warnings emitted
+
+Future incompatibility report: Future breakage diagnostic:
+warning: adding an auto trait `Send` to a trait object in a pointer cast may cause UB later on
+  --> $DIR/ptr-to-trait-obj-add-auto.rs:6:5
+   |
+LL |     x as _
+   |     ^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #127323 <https://github.com/rust-lang/rust/issues/127323>
+   = note: `#[warn(ptr_cast_add_auto_to_object)]` on by default
+
+Future breakage diagnostic:
+warning: adding auto traits `Send`, `Sync`, and `Unpin` to a trait object in a pointer cast may cause UB later on
+  --> $DIR/ptr-to-trait-obj-add-auto.rs:13:5
+   |
+LL |     x as _
+   |     ^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #127323 <https://github.com/rust-lang/rust/issues/127323>
+   = note: `#[warn(ptr_cast_add_auto_to_object)]` on by default
+
diff --git a/tests/ui/cast/ptr-to-trait-obj-add-super-auto.rs b/tests/ui/cast/ptr-to-trait-obj-add-super-auto.rs
new file mode 100644
index 00000000000..ac8108d8ec4
--- /dev/null
+++ b/tests/ui/cast/ptr-to-trait-obj-add-super-auto.rs
@@ -0,0 +1,9 @@
+//@ check-pass
+
+trait Trait: Send {}
+impl Trait for () {}
+
+fn main() {
+    // This is OK: `Trait` has `Send` super trait.
+    &() as *const dyn Trait as *const (dyn Trait + Send);
+}
diff --git a/tests/ui/cast/ptr-to-trait-obj-different-args.rs b/tests/ui/cast/ptr-to-trait-obj-different-args.rs
new file mode 100644
index 00000000000..c6038cfe864
--- /dev/null
+++ b/tests/ui/cast/ptr-to-trait-obj-different-args.rs
@@ -0,0 +1,37 @@
+//@ check-fail
+//
+// issue: <https://github.com/rust-lang/rust/issues/120222>
+
+trait A {}
+impl<T> A for T {}
+trait B {}
+impl<T> B for T {}
+
+trait Trait<G> {}
+struct X;
+impl<T> Trait<X> for T {}
+struct Y;
+impl<T> Trait<Y> for T {}
+
+fn main() {
+    let a: *const dyn A = &();
+    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: 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: mismatched types
+    let _: *const dyn Trait<X> = t as _; //~ error: mismatched types
+}
+
+trait Assocked {
+    type Assoc: ?Sized;
+}
+
+fn change_assoc(x: *mut dyn Assocked<Assoc = u8>) -> *mut dyn Assocked<Assoc = u32> {
+    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
new file mode 100644
index 00000000000..b04289ae747
--- /dev/null
+++ b/tests/ui/cast/ptr-to-trait-obj-different-args.stderr
@@ -0,0 +1,53 @@
+error[E0606]: casting `*const dyn A` as `*const dyn B` is invalid
+  --> $DIR/ptr-to-trait-obj-different-args.rs:18:27
+   |
+LL |     let b: *const dyn B = a as _;
+   |                           ^^^^^^
+   |
+   = note: vtable kinds may not match
+
+error[E0308]: mismatched types
+  --> $DIR/ptr-to-trait-obj-different-args.rs:21:34
+   |
+LL |     let y: *const dyn Trait<Y> = x as _;
+   |                                  ^^^^^^ expected `X`, found `Y`
+   |
+   = note: expected trait object `dyn Trait<X>`
+              found trait object `dyn Trait<Y>`
+
+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 _;
+   |                                  ^^^^^^ expected `X`, found type parameter `T`
+   |
+   = note: expected trait object `dyn Trait<X>`
+              found trait object `dyn Trait<T>`
+
+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 _;
+   |                                  ^^^^^^ expected type parameter `T`, found `X`
+   |
+   = note: expected trait object `dyn Trait<T>`
+              found trait object `dyn Trait<X>`
+
+error[E0308]: mismatched types
+  --> $DIR/ptr-to-trait-obj-different-args.rs:36:5
+   |
+LL |     x as _
+   |     ^^^^^^ expected `u8`, found `u32`
+   |
+   = 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: E0308, E0606.
+For more information about an error, try `rustc --explain E0308`.
diff --git a/tests/ui/cast/ptr-to-trait-obj-different-regions-id-trait.rs b/tests/ui/cast/ptr-to-trait-obj-different-regions-id-trait.rs
new file mode 100644
index 00000000000..cdd55e24392
--- /dev/null
+++ b/tests/ui/cast/ptr-to-trait-obj-different-regions-id-trait.rs
@@ -0,0 +1,27 @@
+//@ check-fail
+//
+// Make sure we can't trick the compiler by using a projection.
+
+trait Cat<'a> {}
+impl Cat<'_> for () {}
+
+trait Id {
+    type Id: ?Sized;
+}
+impl<T: ?Sized> Id for T {
+    type Id = T;
+}
+
+struct S<T: ?Sized> {
+    tail: <T as Id>::Id,
+}
+
+fn m<'a>() {
+    let unsend: *const dyn Cat<'a> = &();
+    let _send = unsend as *const S<dyn Cat<'static>>;
+    //~^ error: lifetime may not live long enough
+}
+
+fn main() {
+    m();
+}
diff --git a/tests/ui/cast/ptr-to-trait-obj-different-regions-id-trait.stderr b/tests/ui/cast/ptr-to-trait-obj-different-regions-id-trait.stderr
new file mode 100644
index 00000000000..d1d598e603f
--- /dev/null
+++ b/tests/ui/cast/ptr-to-trait-obj-different-regions-id-trait.stderr
@@ -0,0 +1,15 @@
+error: lifetime may not live long enough
+  --> $DIR/ptr-to-trait-obj-different-regions-id-trait.rs:21:17
+   |
+LL | fn m<'a>() {
+   |      -- lifetime `'a` defined here
+LL |     let unsend: *const dyn Cat<'a> = &();
+LL |     let _send = unsend as *const S<dyn Cat<'static>>;
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`
+   |
+   = note: requirement occurs because of the type `S<dyn Cat<'_>>`, which makes the generic argument `dyn Cat<'_>` invariant
+   = note: the struct `S<T>` is invariant over the parameter `T`
+   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/cast/ptr-to-trait-obj-different-regions-lt-ext.rs b/tests/ui/cast/ptr-to-trait-obj-different-regions-lt-ext.rs
new file mode 100644
index 00000000000..96345de01c9
--- /dev/null
+++ b/tests/ui/cast/ptr-to-trait-obj-different-regions-lt-ext.rs
@@ -0,0 +1,31 @@
+//@ check-fail
+//
+// issue: <https://github.com/rust-lang/rust/issues/120217>
+
+#![feature(arbitrary_self_types)]
+
+trait Static<'a> {
+    fn proof(self: *const Self, s: &'a str) -> &'static str;
+}
+
+fn bad_cast<'a>(x: *const dyn Static<'static>) -> *const dyn Static<'a> {
+    x as _ //~ error: lifetime may not live long enough
+}
+
+impl Static<'static> for () {
+    fn proof(self: *const Self, s: &'static str) -> &'static str {
+        s
+    }
+}
+
+fn extend_lifetime(s: &str) -> &'static str {
+    bad_cast(&()).proof(s)
+}
+
+fn main() {
+    let s = String::from("Hello World");
+    let slice = extend_lifetime(&s);
+    println!("Now it exists: {slice}");
+    drop(s);
+    println!("Now it’s gone: {slice}");
+}
diff --git a/tests/ui/cast/ptr-to-trait-obj-different-regions-lt-ext.stderr b/tests/ui/cast/ptr-to-trait-obj-different-regions-lt-ext.stderr
new file mode 100644
index 00000000000..b7319e3356b
--- /dev/null
+++ b/tests/ui/cast/ptr-to-trait-obj-different-regions-lt-ext.stderr
@@ -0,0 +1,10 @@
+error: lifetime may not live long enough
+  --> $DIR/ptr-to-trait-obj-different-regions-lt-ext.rs:12:5
+   |
+LL | fn bad_cast<'a>(x: *const dyn Static<'static>) -> *const dyn Static<'a> {
+   |             -- lifetime `'a` defined here
+LL |     x as _
+   |     ^^^^^^ returning this value requires that `'a` must outlive `'static`
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.rs b/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.rs
new file mode 100644
index 00000000000..01c347bfae5
--- /dev/null
+++ b/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.rs
@@ -0,0 +1,37 @@
+//@ check-fail
+
+trait Trait<'a> {}
+
+fn change_lt<'a, 'b>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> {
+    x as _ //~ error: lifetime may not live long enough
+           //~| error: lifetime may not live long enough
+}
+
+fn change_lt_ab<'a: 'b, 'b>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> {
+    x as _ //~ error: lifetime may not live long enough
+}
+
+fn change_lt_ba<'a, 'b: 'a>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> {
+    x as _ //~ error: lifetime may not live long enough
+}
+
+trait Assocked {
+    type Assoc: ?Sized;
+}
+
+fn change_assoc_0<'a, 'b>(
+    x: *mut dyn Assocked<Assoc = dyn Send + 'a>,
+) -> *mut dyn Assocked<Assoc = dyn Send + 'b> {
+    x as _ //~ error: lifetime may not live long enough
+           //~| error: lifetime may not live long enough
+}
+
+fn change_assoc_1<'a, 'b>(
+    x: *mut dyn Assocked<Assoc = dyn Trait<'a>>,
+) -> *mut dyn Assocked<Assoc = dyn Trait<'b>> {
+    x as _ //~ error: lifetime may not live long enough
+           //~| error: lifetime may not live long enough
+}
+
+
+fn main() {}
diff --git a/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.stderr b/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.stderr
new file mode 100644
index 00000000000..7044e4dec1f
--- /dev/null
+++ b/tests/ui/cast/ptr-to-trait-obj-different-regions-misc.stderr
@@ -0,0 +1,136 @@
+error: lifetime may not live long enough
+  --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:6:5
+   |
+LL | fn change_lt<'a, 'b>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> {
+   |              --  -- lifetime `'b` defined here
+   |              |
+   |              lifetime `'a` defined here
+LL |     x as _
+   |     ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
+   |
+   = help: consider adding the following bound: `'b: 'a`
+   = note: requirement occurs because of a mutable pointer to `dyn Trait<'_>`
+   = note: mutable pointers are invariant over their type parameter
+   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
+
+error: lifetime may not live long enough
+  --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:6:5
+   |
+LL | fn change_lt<'a, 'b>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> {
+   |              --  -- lifetime `'b` defined here
+   |              |
+   |              lifetime `'a` defined here
+LL |     x as _
+   |     ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
+   |
+   = help: consider adding the following bound: `'a: 'b`
+   = note: requirement occurs because of a mutable pointer to `dyn Trait<'_>`
+   = note: mutable pointers are invariant over their type parameter
+   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
+
+help: `'b` and `'a` must be the same: replace one with the other
+
+error: lifetime may not live long enough
+  --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:11:5
+   |
+LL | fn change_lt_ab<'a: 'b, 'b>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> {
+   |                 --      -- lifetime `'b` defined here
+   |                 |
+   |                 lifetime `'a` defined here
+LL |     x as _
+   |     ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
+   |
+   = help: consider adding the following bound: `'b: 'a`
+   = note: requirement occurs because of a mutable pointer to `dyn Trait<'_>`
+   = note: mutable pointers are invariant over their type parameter
+   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
+
+error: lifetime may not live long enough
+  --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:15:5
+   |
+LL | fn change_lt_ba<'a, 'b: 'a>(x: *mut dyn Trait<'a>) -> *mut dyn Trait<'b> {
+   |                 --  -- lifetime `'b` defined here
+   |                 |
+   |                 lifetime `'a` defined here
+LL |     x as _
+   |     ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
+   |
+   = help: consider adding the following bound: `'a: 'b`
+   = note: requirement occurs because of a mutable pointer to `dyn Trait<'_>`
+   = note: mutable pointers are invariant over their type parameter
+   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
+
+error: lifetime may not live long enough
+  --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:25:5
+   |
+LL | fn change_assoc_0<'a, 'b>(
+   |                   --  -- lifetime `'b` defined here
+   |                   |
+   |                   lifetime `'a` defined here
+...
+LL |     x as _
+   |     ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
+   |
+   = help: consider adding the following bound: `'b: 'a`
+   = note: requirement occurs because of a mutable pointer to `dyn Assocked<Assoc = dyn Send>`
+   = note: mutable pointers are invariant over their type parameter
+   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
+
+error: lifetime may not live long enough
+  --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:25:5
+   |
+LL | fn change_assoc_0<'a, 'b>(
+   |                   --  -- lifetime `'b` defined here
+   |                   |
+   |                   lifetime `'a` defined here
+...
+LL |     x as _
+   |     ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
+   |
+   = help: consider adding the following bound: `'a: 'b`
+   = note: requirement occurs because of a mutable pointer to `dyn Assocked<Assoc = dyn Send>`
+   = note: mutable pointers are invariant over their type parameter
+   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
+
+help: `'b` and `'a` must be the same: replace one with the other
+   |
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+
+error: lifetime may not live long enough
+  --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:32:5
+   |
+LL | fn change_assoc_1<'a, 'b>(
+   |                   --  -- lifetime `'b` defined here
+   |                   |
+   |                   lifetime `'a` defined here
+...
+LL |     x as _
+   |     ^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
+   |
+   = help: consider adding the following bound: `'b: 'a`
+   = note: requirement occurs because of a mutable pointer to `dyn Assocked<Assoc = dyn Trait<'_>>`
+   = note: mutable pointers are invariant over their type parameter
+   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
+
+error: lifetime may not live long enough
+  --> $DIR/ptr-to-trait-obj-different-regions-misc.rs:32:5
+   |
+LL | fn change_assoc_1<'a, 'b>(
+   |                   --  -- lifetime `'b` defined here
+   |                   |
+   |                   lifetime `'a` defined here
+...
+LL |     x as _
+   |     ^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
+   |
+   = help: consider adding the following bound: `'a: 'b`
+   = note: requirement occurs because of a mutable pointer to `dyn Assocked<Assoc = dyn Trait<'_>>`
+   = note: mutable pointers are invariant over their type parameter
+   = help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
+
+help: `'b` and `'a` must be the same: replace one with the other
+   |
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+
+error: aborting due to 8 previous errors
+
diff --git a/tests/ui/cast/ptr-to-trait-obj-ok.rs b/tests/ui/cast/ptr-to-trait-obj-ok.rs
new file mode 100644
index 00000000000..656c99c58dc
--- /dev/null
+++ b/tests/ui/cast/ptr-to-trait-obj-ok.rs
@@ -0,0 +1,17 @@
+//@ check-pass
+
+trait Trait<'a> {}
+
+fn remove_auto<'a>(x: *mut (dyn Trait<'a> + Send)) -> *mut dyn Trait<'a> {
+    x as _
+}
+
+fn cast_inherent_lt<'a, 'b>(x: *mut (dyn Trait<'static> + 'a)) -> *mut (dyn Trait<'static> + 'b) {
+    x as _
+}
+
+fn unprincipled<'a, 'b>(x: *mut (dyn Send + 'a)) -> *mut (dyn Sync + 'b) {
+    x as _
+}
+
+fn main() {}
diff --git a/tests/ui/cast/ptr-to-trait-obj-wrap-upcast.rs b/tests/ui/cast/ptr-to-trait-obj-wrap-upcast.rs
new file mode 100644
index 00000000000..ff2c4cacfb1
--- /dev/null
+++ b/tests/ui/cast/ptr-to-trait-obj-wrap-upcast.rs
@@ -0,0 +1,14 @@
+trait Super {}
+trait Sub: Super {}
+
+struct Wrapper<T: ?Sized>(T);
+
+// This cast should not compile.
+// Upcasting can't work here, because we are also changing the type (`Wrapper`),
+// and reinterpreting would be confusing/surprising.
+// See <https://github.com/rust-lang/rust/pull/120248#discussion_r1487739518>
+fn cast(ptr: *const dyn Sub) -> *const Wrapper<dyn Super> {
+    ptr as _ //~ error: casting `*const (dyn Sub + 'static)` as `*const Wrapper<dyn Super>` is invalid
+}
+
+fn main() {}
diff --git a/tests/ui/cast/ptr-to-trait-obj-wrap-upcast.stderr b/tests/ui/cast/ptr-to-trait-obj-wrap-upcast.stderr
new file mode 100644
index 00000000000..38c8ba96bc5
--- /dev/null
+++ b/tests/ui/cast/ptr-to-trait-obj-wrap-upcast.stderr
@@ -0,0 +1,11 @@
+error[E0606]: casting `*const (dyn Sub + 'static)` as `*const Wrapper<dyn Super>` is invalid
+  --> $DIR/ptr-to-trait-obj-wrap-upcast.rs:11:5
+   |
+LL |     ptr as _
+   |     ^^^^^^^^
+   |
+   = note: vtable kinds may not match
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0606`.
diff --git a/tests/ui/deriving/deriving-in-fn.rs b/tests/ui/deriving/deriving-in-fn.rs
index 72da2148350..13f3d39597c 100644
--- a/tests/ui/deriving/deriving-in-fn.rs
+++ b/tests/ui/deriving/deriving-in-fn.rs
@@ -9,5 +9,5 @@ pub fn main() {
     }
 
     let f = Foo { foo: 10 };
-    format!("{:?}", f);
+    let _ = format!("{:?}", f);
 }
diff --git a/tests/ui/fmt/struct-field-as-captured-argument.fixed b/tests/ui/fmt/struct-field-as-captured-argument.fixed
index e13af744ec8..0da40737354 100644
--- a/tests/ui/fmt/struct-field-as-captured-argument.fixed
+++ b/tests/ui/fmt/struct-field-as-captured-argument.fixed
@@ -8,11 +8,11 @@ struct Foo {
 fn main() {
     let foo = Foo { field: 0 };
     let bar = 3;
-    format!("{0}", foo.field); //~ ERROR invalid format string: field access isn't supported
-    format!("{1} {} {bar}", "aa", foo.field); //~ ERROR invalid format string: field access isn't supported
-    format!("{2} {} {1} {bar}", "aa", "bb", foo.field); //~ ERROR invalid format string: field access isn't supported
-    format!("{1} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported
-    format!("{1:?} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported
-    format!("{1:#?} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported
-    format!("{1:.3} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{0}", foo.field); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{1} {} {bar}", "aa", foo.field); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{2} {} {1} {bar}", "aa", "bb", foo.field); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{1} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{1:?} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{1:#?} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{1:.3} {} {baz}", "aa", foo.field, baz = 3); //~ ERROR invalid format string: field access isn't supported
 }
diff --git a/tests/ui/fmt/struct-field-as-captured-argument.rs b/tests/ui/fmt/struct-field-as-captured-argument.rs
index 6a875a85848..325b4e3a218 100644
--- a/tests/ui/fmt/struct-field-as-captured-argument.rs
+++ b/tests/ui/fmt/struct-field-as-captured-argument.rs
@@ -8,11 +8,11 @@ struct Foo {
 fn main() {
     let foo = Foo { field: 0 };
     let bar = 3;
-    format!("{foo.field}"); //~ ERROR invalid format string: field access isn't supported
-    format!("{foo.field} {} {bar}", "aa"); //~ ERROR invalid format string: field access isn't supported
-    format!("{foo.field} {} {1} {bar}", "aa", "bb"); //~ ERROR invalid format string: field access isn't supported
-    format!("{foo.field} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported
-    format!("{foo.field:?} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported
-    format!("{foo.field:#?} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported
-    format!("{foo.field:.3} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{foo.field}"); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{foo.field} {} {bar}", "aa"); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{foo.field} {} {1} {bar}", "aa", "bb"); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{foo.field} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{foo.field:?} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{foo.field:#?} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported
+    let _ = format!("{foo.field:.3} {} {baz}", "aa", baz = 3); //~ ERROR invalid format string: field access isn't supported
 }
diff --git a/tests/ui/fmt/struct-field-as-captured-argument.stderr b/tests/ui/fmt/struct-field-as-captured-argument.stderr
index 7ea8b4068f2..4ef022cecb0 100644
--- a/tests/ui/fmt/struct-field-as-captured-argument.stderr
+++ b/tests/ui/fmt/struct-field-as-captured-argument.stderr
@@ -1,79 +1,79 @@
 error: invalid format string: field access isn't supported
-  --> $DIR/struct-field-as-captured-argument.rs:11:15
+  --> $DIR/struct-field-as-captured-argument.rs:11:23
    |
-LL |     format!("{foo.field}");
-   |               ^^^^^^^^^ not supported in format string
+LL |     let _ = format!("{foo.field}");
+   |                       ^^^^^^^^^ not supported in format string
    |
 help: consider using a positional formatting argument instead
    |
-LL |     format!("{0}", foo.field);
-   |               ~  +++++++++++
+LL |     let _ = format!("{0}", foo.field);
+   |                       ~  +++++++++++
 
 error: invalid format string: field access isn't supported
-  --> $DIR/struct-field-as-captured-argument.rs:12:15
+  --> $DIR/struct-field-as-captured-argument.rs:12:23
    |
-LL |     format!("{foo.field} {} {bar}", "aa");
-   |               ^^^^^^^^^ not supported in format string
+LL |     let _ = format!("{foo.field} {} {bar}", "aa");
+   |                       ^^^^^^^^^ not supported in format string
    |
 help: consider using a positional formatting argument instead
    |
-LL |     format!("{1} {} {bar}", "aa", foo.field);
-   |               ~                 +++++++++++
+LL |     let _ = format!("{1} {} {bar}", "aa", foo.field);
+   |                       ~                 +++++++++++
 
 error: invalid format string: field access isn't supported
-  --> $DIR/struct-field-as-captured-argument.rs:13:15
+  --> $DIR/struct-field-as-captured-argument.rs:13:23
    |
-LL |     format!("{foo.field} {} {1} {bar}", "aa", "bb");
-   |               ^^^^^^^^^ not supported in format string
+LL |     let _ = format!("{foo.field} {} {1} {bar}", "aa", "bb");
+   |                       ^^^^^^^^^ not supported in format string
    |
 help: consider using a positional formatting argument instead
    |
-LL |     format!("{2} {} {1} {bar}", "aa", "bb", foo.field);
-   |               ~                           +++++++++++
+LL |     let _ = format!("{2} {} {1} {bar}", "aa", "bb", foo.field);
+   |                       ~                           +++++++++++
 
 error: invalid format string: field access isn't supported
-  --> $DIR/struct-field-as-captured-argument.rs:14:15
+  --> $DIR/struct-field-as-captured-argument.rs:14:23
    |
-LL |     format!("{foo.field} {} {baz}", "aa", baz = 3);
-   |               ^^^^^^^^^ not supported in format string
+LL |     let _ = format!("{foo.field} {} {baz}", "aa", baz = 3);
+   |                       ^^^^^^^^^ not supported in format string
    |
 help: consider using a positional formatting argument instead
    |
-LL |     format!("{1} {} {baz}", "aa", foo.field, baz = 3);
-   |               ~                 +++++++++++
+LL |     let _ = format!("{1} {} {baz}", "aa", foo.field, baz = 3);
+   |                       ~                 +++++++++++
 
 error: invalid format string: field access isn't supported
-  --> $DIR/struct-field-as-captured-argument.rs:15:15
+  --> $DIR/struct-field-as-captured-argument.rs:15:23
    |
-LL |     format!("{foo.field:?} {} {baz}", "aa", baz = 3);
-   |               ^^^^^^^^^ not supported in format string
+LL |     let _ = format!("{foo.field:?} {} {baz}", "aa", baz = 3);
+   |                       ^^^^^^^^^ not supported in format string
    |
 help: consider using a positional formatting argument instead
    |
-LL |     format!("{1:?} {} {baz}", "aa", foo.field, baz = 3);
-   |               ~                   +++++++++++
+LL |     let _ = format!("{1:?} {} {baz}", "aa", foo.field, baz = 3);
+   |                       ~                   +++++++++++
 
 error: invalid format string: field access isn't supported
-  --> $DIR/struct-field-as-captured-argument.rs:16:15
+  --> $DIR/struct-field-as-captured-argument.rs:16:23
    |
-LL |     format!("{foo.field:#?} {} {baz}", "aa", baz = 3);
-   |               ^^^^^^^^^ not supported in format string
+LL |     let _ = format!("{foo.field:#?} {} {baz}", "aa", baz = 3);
+   |                       ^^^^^^^^^ not supported in format string
    |
 help: consider using a positional formatting argument instead
    |
-LL |     format!("{1:#?} {} {baz}", "aa", foo.field, baz = 3);
-   |               ~                    +++++++++++
+LL |     let _ = format!("{1:#?} {} {baz}", "aa", foo.field, baz = 3);
+   |                       ~                    +++++++++++
 
 error: invalid format string: field access isn't supported
-  --> $DIR/struct-field-as-captured-argument.rs:17:15
+  --> $DIR/struct-field-as-captured-argument.rs:17:23
    |
-LL |     format!("{foo.field:.3} {} {baz}", "aa", baz = 3);
-   |               ^^^^^^^^^ not supported in format string
+LL |     let _ = format!("{foo.field:.3} {} {baz}", "aa", baz = 3);
+   |                       ^^^^^^^^^ not supported in format string
    |
 help: consider using a positional formatting argument instead
    |
-LL |     format!("{1:.3} {} {baz}", "aa", foo.field, baz = 3);
-   |               ~                    +++++++++++
+LL |     let _ = format!("{1:.3} {} {baz}", "aa", foo.field, baz = 3);
+   |                       ~                    +++++++++++
 
 error: aborting due to 7 previous errors
 
diff --git a/tests/ui/issues/issue-20676.rs b/tests/ui/issues/issue-20676.rs
index b3319950b42..2059365c7d6 100644
--- a/tests/ui/issues/issue-20676.rs
+++ b/tests/ui/issues/issue-20676.rs
@@ -8,5 +8,5 @@ use std::fmt;
 
 fn main() {
     let a: &dyn fmt::Debug = &1;
-    format!("{:?}", a);
+    let _ = format!("{:?}", a);
 }
diff --git a/tests/ui/mir/alignment/misaligned-constant-gvn.rs b/tests/ui/mir/alignment/misaligned-constant-gvn.rs
new file mode 100644
index 00000000000..363d5c0ed34
--- /dev/null
+++ b/tests/ui/mir/alignment/misaligned-constant-gvn.rs
@@ -0,0 +1,8 @@
+//@ build-pass
+//@ compile-flags: -Zmir-opt-level=0 -Zmir-enable-passes=+GVN
+
+fn main() {
+    let variant: Option<u32> = None;
+    let transmuted: u64 = unsafe { std::mem::transmute(variant) };
+    println!("{transmuted}");
+}
diff --git a/tests/ui/mismatched_types/cast-rfc0401.rs b/tests/ui/mismatched_types/cast-rfc0401.rs
index 57222f45947..b2ff5b4a0c0 100644
--- a/tests/ui/mismatched_types/cast-rfc0401.rs
+++ b/tests/ui/mismatched_types/cast-rfc0401.rs
@@ -66,7 +66,7 @@ fn main()
 
     let cf: *const dyn Foo = &0;
     let _ = cf as *const [u16]; //~ ERROR is invalid
-    let _ = cf as *const dyn Bar; //~ ERROR is invalid
+    let _ = cf as *const dyn Bar; //~ ERROR casting `*const dyn Foo` as `*const dyn Bar` is invalid
 
     vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>(); //~ ERROR is invalid
 }
diff --git a/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.fixed b/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.fixed
index e072c476c6b..4e562193f0d 100644
--- a/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.fixed
+++ b/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.fixed
@@ -3,9 +3,9 @@
 
 trait Trait {}
 
-fn assert_send(ptr: *mut dyn Trait) -> *mut (dyn Trait + Send) {
+fn assert_send() -> *mut (dyn Trait + Send) {
     //~^ ERROR incorrect parentheses around trait bounds
-    ptr as _
+    loop {}
 }
 
 fn foo2(_: &(dyn Trait + Send)) {}
diff --git a/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.rs b/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.rs
index 88995141426..4a00059400c 100644
--- a/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.rs
+++ b/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.rs
@@ -3,9 +3,9 @@
 
 trait Trait {}
 
-fn assert_send(ptr: *mut dyn Trait) -> *mut dyn (Trait + Send) {
+fn assert_send() -> *mut dyn (Trait + Send) {
     //~^ ERROR incorrect parentheses around trait bounds
-    ptr as _
+    loop {}
 }
 
 fn foo2(_: &dyn (Trait + Send)) {}
diff --git a/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.stderr b/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.stderr
index 2d1abe91a1e..c67557fa14f 100644
--- a/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.stderr
+++ b/tests/ui/suggestions/issue-114797-bad-parentheses-dyn-trait.stderr
@@ -1,13 +1,13 @@
 error: incorrect parentheses around trait bounds
-  --> $DIR/issue-114797-bad-parentheses-dyn-trait.rs:6:49
+  --> $DIR/issue-114797-bad-parentheses-dyn-trait.rs:6:30
    |
-LL | fn assert_send(ptr: *mut dyn Trait) -> *mut dyn (Trait + Send) {
-   |                                                 ^            ^
+LL | fn assert_send() -> *mut dyn (Trait + Send) {
+   |                              ^            ^
    |
 help: fix the parentheses
    |
-LL - fn assert_send(ptr: *mut dyn Trait) -> *mut dyn (Trait + Send) {
-LL + fn assert_send(ptr: *mut dyn Trait) -> *mut (dyn Trait + Send) {
+LL - fn assert_send() -> *mut dyn (Trait + Send) {
+LL + fn assert_send() -> *mut (dyn Trait + Send) {
    |
 
 error: incorrect parentheses around trait bounds
diff --git a/tests/ui/traits/upcast_soundness_bug.rs b/tests/ui/traits/upcast_soundness_bug.rs
index 95b48cdf379..5eaa58f7efe 100644
--- a/tests/ui/traits/upcast_soundness_bug.rs
+++ b/tests/ui/traits/upcast_soundness_bug.rs
@@ -1,7 +1,8 @@
 #![feature(trait_upcasting)]
-//@ known-bug: #120222
-//@ check-pass
-//! This will segfault at runtime.
+//@ check-fail
+//
+// issue: <https://github.com/rust-lang/rust/pull/120222>
+//! This would segfault at runtime.
 
 pub trait SupSupA {
     fn method(&self) {}
@@ -56,6 +57,7 @@ pub fn user2() -> &'static dyn Trait<u8, u16> {
 fn main() {
     let p: *const dyn Trait<u8, u8> = &();
     let p = p as *const dyn Trait<u8, u16>; // <- this is bad!
+    //~^ error: mismatched types
     let p = p as *const dyn Super<u16>; // <- this upcast accesses improper vtable entry
     // accessing from L__unnamed_2 the position for the 'Super<u16> vtable (pointer)',
     // thus reading 'null pointer for missing_method'
diff --git a/tests/ui/traits/upcast_soundness_bug.stderr b/tests/ui/traits/upcast_soundness_bug.stderr
new file mode 100644
index 00000000000..5864abcdb41
--- /dev/null
+++ b/tests/ui/traits/upcast_soundness_bug.stderr
@@ -0,0 +1,13 @@
+error[E0308]: mismatched types
+  --> $DIR/upcast_soundness_bug.rs:59:13
+   |
+LL |     let p = p as *const dyn Trait<u8, u16>; // <- this is bad!
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `u16`
+   |
+   = note: expected trait object `dyn Trait<u8, u8>`
+              found trait object `dyn Trait<u8, u16>`
+   = help: `dyn Trait<u8, u16>` 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
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0308`.