Skip to content

Commit dae55ba

Browse files
authored
Unrolled build for rust-lang#126337
Rollup merge of rust-lang#126337 - oli-obk:nested_gat_opaque, r=lcnr Add test for walking order dependent opaque type behaviour r? ```@lcnr``` adding the test for your comment here: https://github.com/rust-lang/rust/pull/122366/files#r1521124754
2 parents f6b4b71 + ffe5439 commit dae55ba

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#![feature(impl_trait_in_assoc_type)]
2+
3+
trait Foo: Sized {
4+
type Bar;
5+
type Gat<T: Foo>;
6+
fn foo(self) -> (<Self as Foo>::Gat<u32>, <Self as Foo>::Gat<Self>);
7+
}
8+
9+
impl Foo for u32 {
10+
type Bar = ();
11+
type Gat<T: Foo> = ();
12+
fn foo(self) -> (<Self as Foo>::Gat<u32>, <Self as Foo>::Gat<Self>) {
13+
((), ())
14+
}
15+
}
16+
17+
impl Foo for () {
18+
type Bar = impl Sized;
19+
type Gat<T: Foo> = <T as Foo>::Bar;
20+
// Because we encounter `Gat<u32>` first, we never walk into another `Gat`
21+
// again, thus missing the opaque type that we could be defining.
22+
fn foo(self) -> (<Self as Foo>::Gat<u32>, <Self as Foo>::Gat<Self>) {
23+
((), ())
24+
//~^ ERROR: mismatched types
25+
}
26+
}
27+
28+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/associated-type-undefine.rs:23:14
3+
|
4+
LL | type Bar = impl Sized;
5+
| ---------- the expected opaque type
6+
...
7+
LL | ((), ())
8+
| ^^ expected opaque type, found `()`
9+
|
10+
= note: expected opaque type `<() as Foo>::Bar`
11+
found unit type `()`
12+
note: this item must have the opaque type in its signature in order to be able to register hidden types
13+
--> $DIR/associated-type-undefine.rs:22:8
14+
|
15+
LL | fn foo(self) -> (<Self as Foo>::Gat<u32>, <Self as Foo>::Gat<Self>) {
16+
| ^^^
17+
18+
error: aborting due to 1 previous error
19+
20+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)