File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
compiler/rustc_mir_transform/src Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -749,15 +749,20 @@ fn sanitize_witness<'tcx>(
749749 }
750750 let decl_ty = tcx. normalize_erasing_regions ( param_env, decl. ty ) ;
751751
752- let is_uninhabited = tcx. is_ty_uninhabited_from (
752+ let is_inhabited = ! tcx. is_ty_uninhabited_from (
753753 tcx. parent_module ( tcx. hir ( ) . local_def_id_to_hir_id ( did. expect_local ( ) ) ) . to_def_id ( ) ,
754754 decl_ty,
755755 param_env,
756756 ) ;
757757
758758 // Sanity check that typeck knows about the type of locals which are
759759 // live across a suspension point
760- if !is_uninhabited && !allowed. contains ( & decl_ty) && !allowed_upvars. contains ( & decl_ty) {
760+ if is_inhabited || allowed. contains ( & decl_ty) || allowed_upvars. contains ( & decl_ty) {
761+ // This type which appears in the generator either...
762+ // - is uninhabited, in which case it can't actually be captured at runtime
763+ // - appears in the approximation from the static type (`allowed`)
764+ // - appears in the list of upvars ...
765+ } else {
761766 span_bug ! (
762767 body. span,
763768 "Broken MIR: generator contains type {} in MIR, \
You can’t perform that action at this time.
0 commit comments