diff options
| author | Ralf Jung <post@ralfj.de> | 2024-02-24 17:16:05 +0100 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-04-23 22:52:43 +0200 |
| commit | 7183fa09bb9b5a0225cdc06b6855a806cd0c0ff8 (patch) | |
| tree | 6d23f22f6c11b3219e045bd8093aaf83bcbdcfe6 /compiler/rustc_mir_transform/src/lib.rs | |
| parent | 40dcd796d094b911b8b7b55a0519fb8e3d21680f (diff) | |
| download | rust-7183fa09bb9b5a0225cdc06b6855a806cd0c0ff8.tar.gz rust-7183fa09bb9b5a0225cdc06b6855a806cd0c0ff8.zip | |
promotion: do not promote const-fn calls in const when that may fail without the entire const failing
Diffstat (limited to 'compiler/rustc_mir_transform/src/lib.rs')
| -rw-r--r-- | compiler/rustc_mir_transform/src/lib.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index e477c068229..9bd5d1a2a97 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -333,13 +333,6 @@ fn mir_promoted( body.tainted_by_errors = Some(error_reported); } - let mut required_consts = Vec::new(); - let mut required_consts_visitor = RequiredConstsVisitor::new(&mut required_consts); - for (bb, bb_data) in traversal::reverse_postorder(&body) { - required_consts_visitor.visit_basic_block_data(bb, bb_data); - } - body.required_consts = required_consts; - // What we need to run borrowck etc. let promote_pass = promote_consts::PromoteTemps::default(); pm::run_passes( @@ -349,6 +342,14 @@ fn mir_promoted( Some(MirPhase::Analysis(AnalysisPhase::Initial)), ); + // Promotion generates new consts; we run this after promotion to ensure they are accounted for. + let mut required_consts = Vec::new(); + let mut required_consts_visitor = RequiredConstsVisitor::new(&mut required_consts); + for (bb, bb_data) in traversal::reverse_postorder(&body) { + required_consts_visitor.visit_basic_block_data(bb, bb_data); + } + body.required_consts = required_consts; + let promoted = promote_pass.promoted_fragments.into_inner(); (tcx.alloc_steal_mir(body), tcx.alloc_steal_promoted(promoted)) } |
