Skip to content

Commit 8c86971

Browse files
committed
Move promote_consts back to rustc_mir_transform.
1 parent 7f6fa19 commit 8c86971

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
pub mod check_consts;
2-
pub mod promote_consts;
32
pub mod validate;

compiler/rustc_mir_transform/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ mod multiple_return_terminators;
9494
mod normalize_array_len;
9595
mod nrvo;
9696
mod prettify;
97+
mod promote_consts;
9798
mod ref_prop;
9899
mod remove_noop_landing_pads;
99100
mod remove_storage_markers;
@@ -115,7 +116,6 @@ mod uninhabited_enum_branching;
115116
mod unreachable_prop;
116117

117118
use rustc_const_eval::transform::check_consts::{self, ConstCx};
118-
use rustc_const_eval::transform::promote_consts;
119119
use rustc_const_eval::transform::validate;
120120
use rustc_mir_dataflow::rustc_peek;
121121

compiler/rustc_const_eval/src/transform/promote_consts.rs renamed to compiler/rustc_mir_transform/src/promote_consts.rs

+6-13
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use rustc_index::{Idx, IndexSlice, IndexVec};
2525
use std::cell::Cell;
2626
use std::{cmp, iter, mem};
2727

28-
use crate::transform::check_consts::{qualifs, ConstCx};
28+
use rustc_const_eval::transform::check_consts::{qualifs, ConstCx};
2929

3030
/// A `MirPass` for promotion.
3131
///
@@ -64,7 +64,7 @@ impl<'tcx> MirPass<'tcx> for PromoteTemps<'tcx> {
6464

6565
/// State of a temporary during collection and promotion.
6666
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
67-
pub enum TempState {
67+
enum TempState {
6868
/// No references to this temp.
6969
Undefined,
7070
/// One direct assignment and any number of direct uses.
@@ -78,18 +78,11 @@ pub enum TempState {
7878
PromotedOut,
7979
}
8080

81-
impl TempState {
82-
pub fn is_promotable(&self) -> bool {
83-
debug!("is_promotable: self={:?}", self);
84-
matches!(self, TempState::Defined { .. })
85-
}
86-
}
87-
8881
/// A "root candidate" for promotion, which will become the
8982
/// returned value in a promoted MIR, unless it's a subset
9083
/// of a larger candidate.
9184
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
92-
pub struct Candidate {
85+
struct Candidate {
9386
location: Location,
9487
}
9588

@@ -162,7 +155,7 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
162155
}
163156
}
164157

165-
pub fn collect_temps_and_candidates<'tcx>(
158+
fn collect_temps_and_candidates<'tcx>(
166159
ccx: &ConstCx<'_, 'tcx>,
167160
) -> (IndexVec<Local, TempState>, Vec<Candidate>) {
168161
let mut collector = Collector {
@@ -676,7 +669,7 @@ impl<'tcx> Validator<'_, 'tcx> {
676669
}
677670

678671
// FIXME(eddyb) remove the differences for promotability in `static`, `const`, `const fn`.
679-
pub fn validate_candidates(
672+
fn validate_candidates(
680673
ccx: &ConstCx<'_, '_>,
681674
temps: &mut IndexSlice<Local, TempState>,
682675
candidates: &[Candidate],
@@ -930,7 +923,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Promoter<'a, 'tcx> {
930923
}
931924
}
932925

933-
pub fn promote_candidates<'tcx>(
926+
fn promote_candidates<'tcx>(
934927
body: &mut Body<'tcx>,
935928
tcx: TyCtxt<'tcx>,
936929
mut temps: IndexVec<Local, TempState>,

0 commit comments

Comments
 (0)