Work around the fact that check_mod_type_wf
may spuriously return ErrorGuaranteed
, even if that error is only emitted by check_modwitem_types
This commit is contained in:
parent
c716f180e8
commit
beaf46f7e5
64 changed files with 661 additions and 80 deletions
|
@ -128,7 +128,11 @@ fn check_union_fields(tcx: TyCtxt<'_>, span: Span, item_def_id: LocalDefId) -> b
|
|||
|
||||
let param_env = tcx.param_env(item_def_id);
|
||||
for field in &def.non_enum_variant().fields {
|
||||
let field_ty = tcx.normalize_erasing_regions(param_env, field.ty(tcx, args));
|
||||
let Ok(field_ty) = tcx.try_normalize_erasing_regions(param_env, field.ty(tcx, args))
|
||||
else {
|
||||
tcx.sess.delay_span_bug(span, "could not normalize field type");
|
||||
continue;
|
||||
};
|
||||
|
||||
if !allowed_union_field(field_ty, tcx, param_env) {
|
||||
let (field_span, ty_span) = match tcx.hir().get_if_local(field.did) {
|
||||
|
|
|
@ -205,15 +205,19 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
|
|||
})?;
|
||||
}
|
||||
|
||||
tcx.sess.time("wf_checking", || {
|
||||
let errs = tcx.sess.time("wf_checking", || {
|
||||
tcx.hir().try_par_for_each_module(|module| tcx.ensure().check_mod_type_wf(module))
|
||||
})?;
|
||||
});
|
||||
|
||||
// NOTE: This is copy/pasted in librustdoc/core.rs and should be kept in sync.
|
||||
tcx.sess.time("item_types_checking", || {
|
||||
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_item_types(module))
|
||||
});
|
||||
|
||||
// HACK: `check_mod_type_wf` may spuriously emit errors due to `delay_span_bug`, even if those errors
|
||||
// only actually get emitted in `check_mod_item_types`.
|
||||
errs?;
|
||||
|
||||
if tcx.features().rustc_attrs {
|
||||
tcx.sess.track_errors(|| collect::test_opaque_hidden_types(tcx))?;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue