Skip to content

Commit 74be487

Browse files
authored
Rollup merge of rust-lang#99178 - Dajamante:clean_up, r=oli-obk
Lighten up const_prop_lint, reusing const_prop r? `@oli-obk`
2 parents aeca079 + e651829 commit 74be487

File tree

2 files changed

+23
-344
lines changed

2 files changed

+23
-344
lines changed

compiler/rustc_mir_transform/src/const_prop.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,18 @@ impl<'tcx> MirPass<'tcx> for ConstProp {
155155
}
156156
}
157157

158-
struct ConstPropMachine<'mir, 'tcx> {
158+
pub struct ConstPropMachine<'mir, 'tcx> {
159159
/// The virtual call stack.
160160
stack: Vec<Frame<'mir, 'tcx>>,
161161
/// `OnlyInsideOwnBlock` locals that were written in the current block get erased at the end.
162-
written_only_inside_own_block_locals: FxHashSet<Local>,
162+
pub written_only_inside_own_block_locals: FxHashSet<Local>,
163163
/// Locals that need to be cleared after every block terminates.
164-
only_propagate_inside_block_locals: BitSet<Local>,
165-
can_const_prop: IndexVec<Local, ConstPropMode>,
164+
pub only_propagate_inside_block_locals: BitSet<Local>,
165+
pub can_const_prop: IndexVec<Local, ConstPropMode>,
166166
}
167167

168168
impl ConstPropMachine<'_, '_> {
169-
fn new(
169+
pub fn new(
170170
only_propagate_inside_block_locals: BitSet<Local>,
171171
can_const_prop: IndexVec<Local, ConstPropMode>,
172172
) -> Self {
@@ -816,7 +816,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
816816

817817
/// The mode that `ConstProp` is allowed to run in for a given `Local`.
818818
#[derive(Clone, Copy, Debug, PartialEq)]
819-
enum ConstPropMode {
819+
pub enum ConstPropMode {
820820
/// The `Local` can be propagated into and reads of this `Local` can also be propagated.
821821
FullConstProp,
822822
/// The `Local` can only be propagated into and from its own block.
@@ -828,7 +828,7 @@ enum ConstPropMode {
828828
NoPropagation,
829829
}
830830

831-
struct CanConstProp {
831+
pub struct CanConstProp {
832832
can_const_prop: IndexVec<Local, ConstPropMode>,
833833
// False at the beginning. Once set, no more assignments are allowed to that local.
834834
found_assignment: BitSet<Local>,
@@ -838,7 +838,7 @@ struct CanConstProp {
838838

839839
impl CanConstProp {
840840
/// Returns true if `local` can be propagated
841-
fn check<'tcx>(
841+
pub fn check<'tcx>(
842842
tcx: TyCtxt<'tcx>,
843843
param_env: ParamEnv<'tcx>,
844844
body: &Body<'tcx>,

0 commit comments

Comments
 (0)