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
Auto merge of rust-lang#94911 - jackh726:gats_extended_2, r=compiler-errors
Make GATs object safe under generic_associated_types_extended feature
Based on rust-lang#94869
Let's say we have
```rust
trait StreamingIterator {
type Item<'a> where Self: 'a;
}
```
And `dyn for<'a> StreamingIterator<Item<'a> = &'a i32>`.
If we ask `(dyn for<'a> StreamingIterator<Item<'a> = &'a i32>): StreamingIterator`, then we have to prove that `for<'x> (&'x i32): Sized`. So, we generate *new* bound vars to subst for the GAT generics.
Importantly, this doesn't fully verify that these are usable and sound.
r? `@nikomatsakis`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object
6
6
|
7
7
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>
| ^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object
6
6
|
7
7
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>
error[E0038]: the trait `SuperTrait` cannot be made into an object
18
-
--> $DIR/issue-76535.rs:36:14
18
+
--> $DIR/issue-76535.rs:40:14
19
19
|
20
20
LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
21
21
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
22
22
|
23
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:6:10
24
+
--> $DIR/issue-76535.rs:10:10
25
25
|
26
26
LL | pub trait SuperTrait {
27
27
| ---------- this trait cannot be made into an object...
@@ -30,13 +30,13 @@ LL | type SubType<'a>: SubTrait where Self: 'a;
30
30
= help: consider moving `SubType` to another trait
31
31
32
32
error[E0038]: the trait `SuperTrait` cannot be made into an object
33
-
--> $DIR/issue-76535.rs:36:57
33
+
--> $DIR/issue-76535.rs:40:57
34
34
|
35
35
LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
36
36
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
37
37
|
38
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:6:10
39
+
--> $DIR/issue-76535.rs:10:10
40
40
|
41
41
LL | pub trait SuperTrait {
42
42
| ---------- this trait cannot be made into an object...
Copy file name to clipboardexpand all lines: src/test/ui/generic-associated-types/issue-78671.base.stderr
+4-4
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
error[E0107]: missing generics for associated type `CollectionFamily::Member`
2
-
--> $DIR/issue-78671.rs:7:47
2
+
--> $DIR/issue-78671.rs:11:47
3
3
|
4
4
LL | Box::new(Family) as &dyn CollectionFamily<Member=usize>
5
5
| ^^^^^^ expected 1 generic argument
6
6
|
7
7
note: associated type defined here, with 1 generic parameter: `T`
8
-
--> $DIR/issue-78671.rs:4:10
8
+
--> $DIR/issue-78671.rs:8:10
9
9
|
10
10
LL | type Member<T>;
11
11
| ^^^^^^ -
@@ -15,13 +15,13 @@ LL | Box::new(Family) as &dyn CollectionFamily<Member<T>=usize>
15
15
| ~~~~~~~~~
16
16
17
17
error[E0038]: the trait `CollectionFamily` cannot be made into an object
18
-
--> $DIR/issue-78671.rs:7:25
18
+
--> $DIR/issue-78671.rs:11:25
19
19
|
20
20
LL | Box::new(Family) as &dyn CollectionFamily<Member=usize>
21
21
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` cannot be made into an object
22
22
|
23
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-78671.rs:4:10
24
+
--> $DIR/issue-78671.rs:8:10
25
25
|
26
26
LL | trait CollectionFamily {
27
27
| ---------------- this trait cannot be made into an object...
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
22
22
|
23
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-79422.rs:20:10
24
+
--> $DIR/issue-79422.rs:24:10
25
25
|
26
26
LL | trait MapLike<K, V> {
27
27
| ------- this trait cannot be made into an object...
@@ -30,13 +30,13 @@ LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a;
30
30
= help: consider moving `VRefCont` to another trait
31
31
32
32
error[E0038]: the trait `MapLike` cannot be made into an object
33
-
--> $DIR/issue-79422.rs:41:13
33
+
--> $DIR/issue-79422.rs:45:13
34
34
|
35
35
LL | let m = Box::new(std::collections::BTreeMap::<u8, u8>::new())
36
36
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
37
37
|
38
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-79422.rs:20:10
39
+
--> $DIR/issue-79422.rs:24:10
40
40
|
41
41
LL | trait MapLike<K, V> {
42
42
| ------- this trait cannot be made into an object...
0 commit comments