drop_tracking_mir: diagnose recursive generator.

This commit is contained in:
Camille GILLOT 2023-01-28 22:45:52 +00:00
parent 0fbfc3e769
commit 0916616fec
2 changed files with 11 additions and 0 deletions

View File

@ -1511,6 +1511,14 @@ fn opaque_type_cycle_error(
{
label_match(interior_ty.ty, interior_ty.span);
}
if tcx.sess.opts.unstable_opts.drop_tracking_mir
&& let DefKind::Generator = tcx.def_kind(closure_def_id)
{
let generator_layout = tcx.mir_generator_witnesses(closure_def_id);
for interior_ty in &generator_layout.field_tys {
label_match(interior_ty.ty, interior_ty.source_info.span);
}
}
}
}
}

View File

@ -114,6 +114,9 @@ error[E0720]: cannot resolve opaque type
|
LL | fn generator_hold() -> impl Sized {
| ^^^^^^^^^^ recursive opaque type
...
LL | let x = generator_hold();
| - generator captures itself here
error[E0720]: cannot resolve opaque type
--> $DIR/recursive-impl-trait-type-indirect.rs:90:26