Check signature WF when lowering MIR body
This commit is contained in:
parent
c566318a78
commit
9d3d5a7fbb
9 changed files with 60 additions and 3 deletions
|
@ -513,6 +513,24 @@ fn mir_drops_elaborated_and_const_checked(tcx: TyCtxt<'_>, def: LocalDefId) -> &
|
|||
body.tainted_by_errors = Some(error_reported);
|
||||
}
|
||||
|
||||
// Also taint the body if it's within a top-level item that is not well formed.
|
||||
//
|
||||
// We do this check here and not during `mir_promoted` because that may result
|
||||
// in borrowck cycles if WF requires looking into an opaque hidden type.
|
||||
let root = tcx.typeck_root_def_id(def.to_def_id());
|
||||
match tcx.def_kind(root) {
|
||||
DefKind::Fn
|
||||
| DefKind::AssocFn
|
||||
| DefKind::Static { .. }
|
||||
| DefKind::Const
|
||||
| DefKind::AssocConst => {
|
||||
if let Err(guar) = tcx.check_well_formed(root.expect_local()) {
|
||||
body.tainted_by_errors = Some(guar);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
run_analysis_to_runtime_passes(tcx, &mut body);
|
||||
|
||||
tcx.alloc_steal_mir(body)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue