Skip to content

Commit ba27e22

Browse files
committed
Use a ty::Error instead of patching up a type after erroring
1 parent 9273d63 commit ba27e22

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

compiler/rustc_hir_analysis/src/collect/type_of.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,8 @@ fn infer_placeholder_type<'a>(
603603
}
604604

605605
err.emit();
606+
// diagnostic stashing loses the information of whether something is a hard error.
607+
Ty::new_error_with_message(tcx, span, "ItemNoType is a hard error")
606608
}
607609
None => {
608610
let mut diag = bad_placeholder(tcx, vec![span], kind);
@@ -623,15 +625,9 @@ fn infer_placeholder_type<'a>(
623625
}
624626
}
625627

626-
diag.emit();
628+
Ty::new_error(tcx, diag.emit())
627629
}
628630
}
629-
630-
// Typeck doesn't expect erased regions to be returned from `type_of`.
631-
tcx.fold_regions(ty, |r, _| match *r {
632-
ty::ReErased => tcx.lifetimes.re_static,
633-
_ => r,
634-
})
635631
}
636632

637633
fn check_feature_inherent_assoc_ty(tcx: TyCtxt<'_>, span: Span) {

0 commit comments

Comments
 (0)