]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generic-associated-types/issue-76535.base.stderr
Auto merge of #89123 - the8472:push_in_capacity, r=amanieu
[rust.git] / src / test / ui / generic-associated-types / issue-76535.base.stderr
1 error[E0107]: missing generics for associated type `SuperTrait::SubType`
2   --> $DIR/issue-76535.rs:39: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:9: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:39: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 "object safe" 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:9: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
32 error[E0038]: the trait `SuperTrait` cannot be made into an object
33   --> $DIR/issue-76535.rs:39:57
34    |
35 LL |     let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
36    |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
37    |
38 note: for a trait to be "object safe" 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>
39   --> $DIR/issue-76535.rs:9:10
40    |
41 LL | pub trait SuperTrait {
42    |           ---------- this trait cannot be made into an object...
43 LL |     type SubType<'a>: SubTrait where Self: 'a;
44    |          ^^^^^^^ ...because it contains the generic associated type `SubType`
45    = help: consider moving `SubType` to another trait
46    = note: required for `Box<SuperStruct>` to implement `CoerceUnsized<Box<dyn SuperTrait<SubType = SubStruct<'_>>>>`
47    = note: required by cast to type `Box<dyn SuperTrait<SubType = SubStruct<'_>>>`
48
49 error: aborting due to 3 previous errors
50
51 Some errors have detailed explanations: E0038, E0107.
52 For more information about an error, try `rustc --explain E0038`.