You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
diagnostics: Box<dyn Trait> suggestion with multiple matching impl
The two altered expectation messages both seem like improvements:
- `coerce-expect-unsized-ascribed.stderr` says you can go
`Box<char> -> Box<dyn Debug>`, which you can.
- `upcast_soundness_bug.stderr` used to say that you could go
`Box<dyn Trait<u8, u8>> -> Box<dyn Trait>`, which you can't,
because the type parameters are missing in the destination
and the only ones that work aren't what's needed.
Copy file name to clipboardExpand all lines: tests/ui/coercion/coerce-expect-unsized-ascribed.stderr
+4
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,7 @@ LL | let _ = type_ascribe!(Box::new( if true { false } else { true }), Box<d
42
42
|
43
43
= note: expected struct `Box<dyn Debug>`
44
44
found struct `Box<bool>`
45
+
= help: `bool` implements `Debug` so you could box the found value and coerce it to the trait object `Box<dyn Debug>`, you will have to change the expected type as well
45
46
46
47
error[E0308]: mismatched types
47
48
--> $DIR/coerce-expect-unsized-ascribed.rs:16:27
@@ -51,6 +52,7 @@ LL | let _ = type_ascribe!(Box::new( match true { true => 'a', false => 'b'
51
52
|
52
53
= note: expected struct `Box<dyn Debug>`
53
54
found struct `Box<char>`
55
+
= help: `char` implements `Debug` so you could box the found value and coerce it to the trait object `Box<dyn Debug>`, you will have to change the expected type as well
= help: `bool` implements `Debug` so you could box the found value and coerce it to the trait object `Box<dyn Debug>`, you will have to change the expected type as well
= help: `char` implements `Debug` so you could box the found value and coerce it to the trait object `Box<dyn Debug>`, you will have to change the expected type as well
Copy file name to clipboardExpand all lines: tests/ui/traits/upcast_soundness_bug.stderr
-1
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,6 @@ LL | let p = p as *const dyn Trait<u8, u16>; // <- this is bad!
6
6
|
7
7
= note: expected trait object `dyn Trait<u8, u8>`
8
8
found trait object `dyn Trait<u8, u16>`
9
-
= 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
0 commit comments