From ba27e22f671f6b2a56519e61a75fe070b0e96bf9 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 9 Jan 2024 15:49:31 +0000 Subject: [PATCH] Use a ty::Error instead of patching up a type after erroring --- compiler/rustc_hir_analysis/src/collect/type_of.rs | 10 +++------- 1 file 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) {