|
| 1 | +error[E0107]: missing generics for associated type `SuperTrait::SubType` |
| 2 | + --> $DIR/issue-76535.rs:34:33 |
| 3 | + | |
| 4 | +LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0)); |
| 5 | + | ^^^^^^^ expected 1 lifetime argument |
| 6 | + | |
| 7 | +note: associated type defined here, with 1 lifetime parameter: `'a` |
| 8 | + --> $DIR/issue-76535.rs:4:10 |
| 9 | + | |
| 10 | +LL | type SubType<'a>: SubTrait where Self: 'a; |
| 11 | + | ^^^^^^^ -- |
| 12 | +help: add missing lifetime argument |
| 13 | + | |
| 14 | +LL | let sub: Box<dyn SuperTrait<SubType<'a> = SubStruct>> = Box::new(SuperStruct::new(0)); |
| 15 | + | ++++ |
| 16 | + |
| 17 | +error[E0038]: the trait `SuperTrait` cannot be made into an object |
| 18 | + --> $DIR/issue-76535.rs:34:14 |
| 19 | + | |
| 20 | +LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0)); |
| 21 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object |
| 22 | + | |
| 23 | +note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> |
| 24 | + --> $DIR/issue-76535.rs:4:10 |
| 25 | + | |
| 26 | +LL | pub trait SuperTrait { |
| 27 | + | ---------- this trait cannot be made into an object... |
| 28 | +LL | type SubType<'a>: SubTrait where Self: 'a; |
| 29 | + | ^^^^^^^ ...because it contains the generic associated type `SubType` |
| 30 | + = help: consider moving `SubType` to another trait |
| 31 | + = help: only type `SuperStruct` is seen to implement the trait in this crate, consider using it directly instead |
| 32 | + = note: `SuperTrait` can be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type |
| 33 | + |
| 34 | +error[E0038]: the trait `SuperTrait` cannot be made into an object |
| 35 | + --> $DIR/issue-76535.rs:34:57 |
| 36 | + | |
| 37 | +LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0)); |
| 38 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object |
| 39 | + | |
| 40 | +note: for a trait to be "dyn-compatible" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> |
| 41 | + --> $DIR/issue-76535.rs:4:10 |
| 42 | + | |
| 43 | +LL | pub trait SuperTrait { |
| 44 | + | ---------- this trait cannot be made into an object... |
| 45 | +LL | type SubType<'a>: SubTrait where Self: 'a; |
| 46 | + | ^^^^^^^ ...because it contains the generic associated type `SubType` |
| 47 | + = help: consider moving `SubType` to another trait |
| 48 | + = help: only type `SuperStruct` is seen to implement the trait in this crate, consider using it directly instead |
| 49 | + = note: `SuperTrait` can be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type |
| 50 | + = note: required for the cast from `Box<SuperStruct>` to `Box<dyn SuperTrait<SubType<'_> = SubStruct<'_>>>` |
| 51 | + |
| 52 | +error: aborting due to 3 previous errors |
| 53 | + |
| 54 | +Some errors have detailed explanations: E0038, E0107. |
| 55 | +For more information about an error, try `rustc --explain E0038`. |
0 commit comments