about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-01-09 15:49:31 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2024-01-10 08:52:44 +0000
commitba27e22f671f6b2a56519e61a75fe070b0e96bf9 (patch)
treea8748e625b1d68b7282cc9f19c363a7202bae75e
parent9273d63f07e036b96dae4af4da8135416ff9b8f7 (diff)
Use a ty::Error instead of patching up a type after erroring
-rw-r--r--compiler/rustc_hir_analysis/src/collect/type_of.rs10
1 files changed, 3 insertions, 7 deletions
diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs
index 55720e6d2aa..18401726817 100644
--- a/compiler/rustc_hir_analysis/src/collect/type_of.rs
+++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs
@@ -603,6 +603,8 @@ fn infer_placeholder_type<'a>(
             }
 
             err.emit();
+            // diagnostic stashing loses the information of whether something is a hard error.
+            Ty::new_error_with_message(tcx, span, "ItemNoType is a hard error")
         }
         None => {
             let mut diag = bad_placeholder(tcx, vec![span], kind);
@@ -623,15 +625,9 @@ fn infer_placeholder_type<'a>(
                 }
             }
 
-            diag.emit();
+            Ty::new_error(tcx, diag.emit())
         }
     }
-
-    // Typeck doesn't expect erased regions to be returned from `type_of`.
-    tcx.fold_regions(ty, |r, _| match *r {
-        ty::ReErased => tcx.lifetimes.re_static,
-        _ => r,
-    })
 }
 
 fn check_feature_inherent_assoc_ty(tcx: TyCtxt<'_>, span: Span) {