Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 49aacd0

Browse files
committedOct 25, 2023
Work around the fact that check_mod_type_wf may spuriously return ErrorGuaranteed, even if that error is only emitted by check_modwitem_types
1 parent c716f18 commit 49aacd0

File tree

63 files changed

+649
-78
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+649
-78
lines changed
 

‎compiler/rustc_hir_analysis/src/check/check.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
128128

129129
let param_env = tcx.param_env(item_def_id);
130130
for field in &def.non_enum_variant().fields {
131-
let field_ty = tcx.normalize_erasing_regions(param_env, field.ty(tcx, args));
131+
let Ok(field_ty) = tcx.try_normalize_erasing_regions(param_env, field.ty(tcx, args))
132+
else {
133+
tcx.sess.delay_span_bug(span, "could not normalize field type");
134+
continue;
135+
};
132136

133137
if !allowed_union_field(field_ty, tcx, param_env) {
134138
let (field_span, ty_span) = match tcx.hir().get_if_local(field.did) {

‎compiler/rustc_hir_analysis/src/lib.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,19 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
205205
})?;
206206
}
207207

208-
tcx.sess.time("wf_checking", || {
208+
let errs = tcx.sess.time("wf_checking", || {
209209
tcx.hir().try_par_for_each_module(|module| tcx.ensure().check_mod_type_wf(module))
210-
})?;
210+
});
211211

212212
// NOTE: This is copy/pasted in librustdoc/core.rs and should be kept in sync.
213213
tcx.sess.time("item_types_checking", || {
214214
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_item_types(module))
215215
});
216216

217+
// HACK: `check_mod_type_wf` may spuriously emit errors due to `delay_span_bug`, even if those errors
218+
// only actually get emitted in `check_mod_item_types`.
219+
errs?;
220+
217221
if tcx.features().rustc_attrs {
218222
tcx.sess.track_errors(|| collect::test_opaque_hidden_types(tcx))?;
219223
}

0 commit comments

Comments
 (0)
Please sign in to comment.