| 
1 |  | -error[E0308]: mismatched types  | 
 | 1 | +error[E0277]: the trait bound `&T: CoerceUnsized<&dyn Foo>` is not satisfied in `T`  | 
2 | 2 |   --> $DIR/dst-object-from-unsized-type.rs:11:23  | 
3 | 3 |    |  | 
4 | 4 | LL | fn test1<T: ?Sized + Foo>(t: &T) {  | 
5 |  | -   |          - found this type parameter  | 
 | 5 | +   |          - this type parameter needs to be `Sized`  | 
6 | 6 | LL |     let u: &dyn Foo = t;  | 
7 |  | -   |            --------   ^ expected `&dyn Foo`, found `&T`  | 
8 |  | -   |            |  | 
9 |  | -   |            expected due to this  | 
10 |  | -   |  | 
11 |  | -   = note: expected reference `&dyn Foo`  | 
12 |  | -              found reference `&T`  | 
13 |  | -   = help: type parameters must be constrained to match other types  | 
14 |  | -   = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters  | 
 | 7 | +   |                       ^ within `T`, the trait `Sized` is not implemented for `T`  | 
 | 8 | +   |  | 
 | 9 | +   = note: required because it appears within the type `T`  | 
 | 10 | +   = note: required for `&T` to implement `CoerceUnsized<&dyn Foo>`  | 
 | 11 | +   = note: required for the cast from `&T` to `&dyn Foo`  | 
 | 12 | +help: consider removing the `?Sized` bound to make the type parameter `Sized`  | 
 | 13 | +   |  | 
 | 14 | +LL - fn test1<T: ?Sized + Foo>(t: &T) {  | 
 | 15 | +LL + fn test1<T: Foo>(t: &T) {  | 
 | 16 | +   |  | 
15 | 17 | 
 
  | 
16 |  | -error[E0605]: non-primitive cast: `&T` as `&dyn Foo`  | 
17 |  | -  --> $DIR/dst-object-from-unsized-type.rs:16:23  | 
 | 18 | +error[E0277]: the trait bound `&T: CoerceUnsized<&dyn Foo>` is not satisfied in `T`  | 
 | 19 | +  --> $DIR/dst-object-from-unsized-type.rs:17:23  | 
18 | 20 |    |  | 
 | 21 | +LL | fn test2<T: ?Sized + Foo>(t: &T) {  | 
 | 22 | +   |          - this type parameter needs to be `Sized`  | 
19 | 23 | LL |     let v: &dyn Foo = t as &dyn Foo;  | 
20 |  | -   |                       ^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object  | 
 | 24 | +   |                       ^ within `T`, the trait `Sized` is not implemented for `T`  | 
 | 25 | +   |  | 
 | 26 | +   = note: required because it appears within the type `T`  | 
 | 27 | +   = note: required for `&T` to implement `CoerceUnsized<&dyn Foo>`  | 
 | 28 | +   = note: required for the cast from `&T` to `&dyn Foo`  | 
 | 29 | +help: consider removing the `?Sized` bound to make the type parameter `Sized`  | 
 | 30 | +   |  | 
 | 31 | +LL - fn test2<T: ?Sized + Foo>(t: &T) {  | 
 | 32 | +LL + fn test2<T: Foo>(t: &T) {  | 
 | 33 | +   |  | 
21 | 34 | 
 
  | 
22 |  | -error[E0308]: mismatched types  | 
23 |  | -  --> $DIR/dst-object-from-unsized-type.rs:21:28  | 
 | 35 | +error[E0277]: the trait bound `&str: CoerceUnsized<&dyn Foo>` is not satisfied in `str`  | 
 | 36 | +  --> $DIR/dst-object-from-unsized-type.rs:23:28  | 
24 | 37 |    |  | 
25 | 38 | LL |     let _: &[&dyn Foo] = &["hi"];  | 
26 |  | -   |                            ^^^^ expected `&dyn Foo`, found `&str`  | 
 | 39 | +   |                            ^^^^ within `str`, the trait `Sized` is not implemented for `str`  | 
27 | 40 |    |  | 
28 |  | -   = note: expected reference `&dyn Foo`  | 
29 |  | -              found reference `&'static str`  | 
30 |  | -   = help: `str` implements `Foo` so you could box the found value and coerce it to the trait object `Box<dyn Foo>`, you will have to change the expected type as well  | 
 | 41 | +   = note: `str` is considered to contain a `[u8]` slice for auto trait purposes  | 
 | 42 | +   = note: required for `&str` to implement `CoerceUnsized<&dyn Foo>`  | 
 | 43 | +   = note: required for the cast from `&'static str` to `&dyn Foo`  | 
31 | 44 | 
 
  | 
32 |  | -error[E0605]: non-primitive cast: `&[u8]` as `&dyn Foo`  | 
33 |  | -  --> $DIR/dst-object-from-unsized-type.rs:26:23  | 
 | 45 | +error[E0277]: the trait bound `&[u8]: CoerceUnsized<&dyn Foo>` is not satisfied in `[u8]`  | 
 | 46 | +  --> $DIR/dst-object-from-unsized-type.rs:29:23  | 
34 | 47 |    |  | 
35 | 48 | LL |     let _: &dyn Foo = x as &dyn Foo;  | 
36 |  | -   |                       ^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object  | 
 | 49 | +   |                       ^ within `[u8]`, the trait `Sized` is not implemented for `[u8]`  | 
 | 50 | +   |  | 
 | 51 | +   = note: required because it appears within the type `[u8]`  | 
 | 52 | +   = note: required for `&[u8]` to implement `CoerceUnsized<&dyn Foo>`  | 
 | 53 | +   = note: required for the cast from `&[u8]` to `&dyn Foo`  | 
37 | 54 | 
 
  | 
38 | 55 | error: aborting due to 4 previous errors  | 
39 | 56 | 
 
  | 
40 |  | -Some errors have detailed explanations: E0308, E0605.  | 
41 |  | -For more information about an error, try `rustc --explain E0308`.  | 
 | 57 | +For more information about this error, try `rustc --explain E0277`.  | 
0 commit comments