Skip to content

Commit 465c5e3

Browse files
authored
Unrolled build for #122366
Rollup merge of #122366 - oli-obk:opaques_defined_by_overflow, r=lcnr Fix stack overflow with recursive associated types fixes #122364
2 parents 7de1a1f + 783490d commit 465c5e3

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

compiler/rustc_ty_utils/src/opaque_types.rs

+4
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector<'tcx> {
240240
continue;
241241
}
242242

243+
if !self.seen.insert(assoc.def_id.expect_local()) {
244+
return;
245+
}
246+
243247
let impl_args = alias_ty.args.rebase_onto(
244248
self.tcx,
245249
impl_trait_ref.def_id,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
trait Foo {
2+
type Bar;
3+
fn foo(self) -> Self::Bar;
4+
}
5+
6+
impl Foo for Box<dyn Foo> {
7+
//~^ ERROR: the value of the associated type `Bar` in `Foo` must be specified
8+
type Bar = <Self as Foo>::Bar;
9+
fn foo(self) -> <Self as Foo>::Bar {
10+
(*self).foo()
11+
}
12+
}
13+
14+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0191]: the value of the associated type `Bar` in `Foo` must be specified
2+
--> $DIR/associated-type-cycle.rs:6:22
3+
|
4+
LL | type Bar;
5+
| -------- `Bar` defined here
6+
...
7+
LL | impl Foo for Box<dyn Foo> {
8+
| ^^^ help: specify the associated type: `Foo<Bar = Type>`
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0191`.

0 commit comments

Comments
 (0)