about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/lib.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-03-05 15:09:49 +0000
committerbors <bors@rust-lang.org>2025-03-05 15:09:49 +0000
commit07b5eeebc948743eaadb32a83d23931fd8854fe8 (patch)
tree7a4f9749a2a3cb7d327d693d5a0e9e7d0141dfda /compiler/rustc_mir_transform/src/lib.rs
parent4559163ccb500affc424fb9228dae5003672ffc7 (diff)
parentfe4c0850fe1ddfd1054d2c92cb832bb59edde2ea (diff)
downloadrust-07b5eeebc948743eaadb32a83d23931fd8854fe8.tar.gz
rust-07b5eeebc948743eaadb32a83d23931fd8854fe8.zip
Auto merge of #138058 - jieyouxu:rollup-skdt0oz, r=jieyouxu
Rollup of 20 pull requests

Successful merges:

 - #134063 (dec2flt: Clean up float parsing modules)
 - #136581 (Retire the legacy `Makefile`-based `run-make` test infra)
 - #136662 (Count char width at most once in `Formatter::pad`)
 - #136764 (Make `ptr_cast_add_auto_to_object` lint into hard error)
 - #136798 (Added documentation for flushing per #74348)
 - #136865 (Perform deeper compiletest path normalization for `$TEST_BUILD_DIR` to account for compare-mode/debugger cases, and normalize long type file filename hashes)
 - #136975 (Look for `python3` first on MacOS, not `py`)
 - #136977 (Upload Datadog metrics with citool)
 - #137240 (Slightly reformat `std::fs::remove_dir_all` error docs)
 - #137298 (Check signature WF when lowering MIR body)
 - #137463 ([illumos] attempt to use posix_spawn to spawn processes)
 - #137477 (uefi: Add Service Binding Protocol abstraction)
 - #137569 (Stabilize `string_extend_from_within`)
 - #137633 (Only use implied bounds hack if bevy, and use deeply normalize in implied bounds hack)
 - #137679 (Various coretests improvements)
 - #137723 (Make `rust.description` more general-purpose and pass `CFG_VER_DESCRIPTION`)
 - #137728 (Remove unsizing coercions for tuples)
 - #137731 (Resume one waiter at once in deadlock handler)
 - #137875 (mir_build: Integrate "simplification" steps into match-pair-tree creation)
 - #138028 (compiler: add `ExternAbi::is_rustic_abi`)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_mir_transform/src/lib.rs')
-rw-r--r--compiler/rustc_mir_transform/src/lib.rs18
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)