Skip to content

Commit

Permalink
Handle normalization failure in struct_tail_erasing_lifetimes
Browse files Browse the repository at this point in the history
Fixes an ICE that occurred when the struct in question has an error
  • Loading branch information
gurry authored and compiler-errors committed May 8, 2024
1 parent c3202af commit cacc082
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,14 @@ impl<'tcx> SizeSkeleton<'tcx> {
pointee,
|ty| match tcx.try_normalize_erasing_regions(param_env, ty) {
Ok(ty) => ty,
Err(_e) => {
if let Some(guar) = tcx.dcx().has_errors() {
Ty::new_error(tcx, guar)
} else {
bug!("normalization failed, but no errors reported");
}
}
Err(e) => Ty::new_error_with_message(
tcx,
DUMMY_SP,
format!(
"normalization failed for {} but no errors reported",
e.get_type_for_failure()
),
),
},
|| {},
);
Expand Down

0 comments on commit cacc082

Please sign in to comment.