about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-09-23 04:03:24 +0000
committerMichael Goulet <michael@errs.io>2023-09-23 04:19:14 +0000
commit79d685325c170f0aed483e4c50c1f2b7d5b2bdc1 (patch)
treeae6ed35d3655c8d5dd2fc3b482d53a46588614c4 /compiler/rustc_trait_selection/src/traits
parentc21867f9f6af92c4669b1ee7541291d7b9635b1a (diff)
downloadrust-79d685325c170f0aed483e4c50c1f2b7d5b2bdc1.tar.gz
rust-79d685325c170f0aed483e4c50c1f2b7d5b2bdc1.zip
Check types live across yields in generators too
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
index 74345169179..bb96e135741 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
@@ -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`");
             }