1
Fork 0

Check types live across yields in generators too

This commit is contained in:
Michael Goulet 2023-09-23 04:03:24 +00:00
parent c21867f9f6
commit 79d685325c
13 changed files with 235 additions and 5 deletions

View file

@ -3018,6 +3018,13 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
err.span_label(span, "this closure captures all values by move");
}
}
ObligationCauseCode::SizedGeneratorInterior(generator_def_id) => {
let what = match self.tcx.generator_kind(generator_def_id) {
None | Some(hir::GeneratorKind::Gen) => "yield",
Some(hir::GeneratorKind::Async(..)) => "await",
};
err.note(format!("all values live across `{what}` must have a statically known size"));
}
ObligationCauseCode::ConstPatternStructural => {
err.note("constants used for pattern-matching must derive `PartialEq` and `Eq`");
}