Rollup merge of #122366 - oli-obk:opaques_defined_by_overflow, r=lcnr
Fix stack overflow with recursive associated types fixes #122364
This commit is contained in:
commit
0b31375248
@ -240,6 +240,10 @@ fn visit_ty(&mut self, t: Ty<'tcx>) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if !self.seen.insert(assoc.def_id.expect_local()) {
|
||||
return;
|
||||
}
|
||||
|
||||
let impl_args = alias_ty.args.rebase_onto(
|
||||
self.tcx,
|
||||
impl_trait_ref.def_id,
|
||||
|
14
tests/ui/impl-trait/associated-type-cycle.rs
Normal file
14
tests/ui/impl-trait/associated-type-cycle.rs
Normal file
@ -0,0 +1,14 @@
|
||||
trait Foo {
|
||||
type Bar;
|
||||
fn foo(self) -> Self::Bar;
|
||||
}
|
||||
|
||||
impl Foo for Box<dyn Foo> {
|
||||
//~^ ERROR: the value of the associated type `Bar` in `Foo` must be specified
|
||||
type Bar = <Self as Foo>::Bar;
|
||||
fn foo(self) -> <Self as Foo>::Bar {
|
||||
(*self).foo()
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
12
tests/ui/impl-trait/associated-type-cycle.stderr
Normal file
12
tests/ui/impl-trait/associated-type-cycle.stderr
Normal file
@ -0,0 +1,12 @@
|
||||
error[E0191]: the value of the associated type `Bar` in `Foo` must be specified
|
||||
--> $DIR/associated-type-cycle.rs:6:22
|
||||
|
|
||||
LL | type Bar;
|
||||
| -------- `Bar` defined here
|
||||
...
|
||||
LL | impl Foo for Box<dyn Foo> {
|
||||
| ^^^ help: specify the associated type: `Foo<Bar = Type>`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0191`.
|
Loading…
Reference in New Issue
Block a user