diff options
| author | Michael Goulet <michael@errs.io> | 2025-02-20 02:21:58 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-03-03 23:09:42 +0000 |
| commit | 9d3d5a7fbb9d28d91e2d19d2b0bf5bc5af5b038c (patch) | |
| tree | 51cf69163e6eeb73ffd67a9d5a69273ef5b3670b /compiler/rustc_mir_transform/src/lib.rs | |
| parent | c566318a782030a33f370d7490d7bdac9d8bfca4 (diff) | |
| download | rust-9d3d5a7fbb9d28d91e2d19d2b0bf5bc5af5b038c.tar.gz rust-9d3d5a7fbb9d28d91e2d19d2b0bf5bc5af5b038c.zip | |
Check signature WF when lowering MIR body
Diffstat (limited to 'compiler/rustc_mir_transform/src/lib.rs')
| -rw-r--r-- | compiler/rustc_mir_transform/src/lib.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 04c9375b831..5df12ac4d8b 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -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) |
