Skip to content

Commit 2496008

Browse files
Use TyCtxt instead of Sess in is_enabled
1 parent 706f244 commit 2496008

33 files changed

+78
-83
lines changed

compiler/rustc_mir_transform/src/add_retag.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ fn may_contain_reference<'tcx>(ty: Ty<'tcx>, depth: u32, tcx: TyCtxt<'tcx>) -> b
4949
}
5050

5151
impl<'tcx> crate::MirPass<'tcx> for AddRetag {
52-
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
53-
sess.opts.unstable_opts.mir_emit_retag
52+
fn is_enabled(&self, tcx: TyCtxt<'tcx>) -> bool {
53+
tcx.sess.opts.unstable_opts.mir_emit_retag
5454
}
5555

5656
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {

compiler/rustc_mir_transform/src/check_alignment.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ use rustc_middle::mir::interpret::Scalar;
44
use rustc_middle::mir::visit::PlaceContext;
55
use rustc_middle::mir::*;
66
use rustc_middle::ty::{Ty, TyCtxt};
7-
use rustc_session::Session;
87

98
use crate::check_pointers::{BorrowedFieldProjectionMode, PointerCheck, check_pointers};
109

1110
pub(super) struct CheckAlignment;
1211

1312
impl<'tcx> crate::MirPass<'tcx> for CheckAlignment {
14-
fn is_enabled(&self, sess: &Session) -> bool {
15-
sess.ub_checks()
13+
fn is_enabled(&self, tcx: TyCtxt<'tcx>) -> bool {
14+
tcx.sess.ub_checks()
1615
}
1716

1817
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {

compiler/rustc_mir_transform/src/check_null.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ use rustc_index::IndexVec;
22
use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext};
33
use rustc_middle::mir::*;
44
use rustc_middle::ty::{Ty, TyCtxt};
5-
use rustc_session::Session;
65

76
use crate::check_pointers::{BorrowedFieldProjectionMode, PointerCheck, check_pointers};
87

98
pub(super) struct CheckNull;
109

1110
impl<'tcx> crate::MirPass<'tcx> for CheckNull {
12-
fn is_enabled(&self, sess: &Session) -> bool {
13-
sess.ub_checks()
11+
fn is_enabled(&self, tcx: TyCtxt<'tcx>) -> bool {
12+
tcx.sess.ub_checks()
1413
}
1514

1615
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {

compiler/rustc_mir_transform/src/copy_prop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ use crate::ssa::SsaLocals;
2020
pub(super) struct CopyProp;
2121

2222
impl<'tcx> crate::MirPass<'tcx> for CopyProp {
23-
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
24-
sess.mir_opt_level() >= 1
23+
fn is_enabled(&self, tcx: TyCtxt<'tcx>) -> bool {
24+
tcx.sess.mir_opt_level() >= 1
2525
}
2626

2727
#[instrument(level = "trace", skip(self, tcx, body))]

compiler/rustc_mir_transform/src/coverage/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ use crate::coverage::mappings::ExtractedMappings;
2929
pub(super) struct InstrumentCoverage;
3030

3131
impl<'tcx> crate::MirPass<'tcx> for InstrumentCoverage {
32-
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
33-
sess.instrument_coverage()
32+
fn is_enabled(&self, tcx: TyCtxt<'tcx>) -> bool {
33+
tcx.sess.instrument_coverage()
3434
}
3535

3636
fn run_pass(&self, tcx: TyCtxt<'tcx>, mir_body: &mut mir::Body<'tcx>) {

compiler/rustc_mir_transform/src/dataflow_const_prop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const PLACE_LIMIT: usize = 100;
3535
pub(super) struct DataflowConstProp;
3636

3737
impl<'tcx> crate::MirPass<'tcx> for DataflowConstProp {
38-
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
39-
sess.mir_opt_level() >= 3
38+
fn is_enabled(&self, tcx: TyCtxt<'tcx>) -> bool {
39+
tcx.sess.mir_opt_level() >= 3
4040
}
4141

4242
#[instrument(skip_all level = "debug")]

compiler/rustc_mir_transform/src/dead_store_elimination.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ impl<'tcx> crate::MirPass<'tcx> for DeadStoreElimination {
140140
}
141141
}
142142

143-
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
144-
sess.mir_opt_level() >= 2
143+
fn is_enabled(&self, tcx: TyCtxt<'tcx>) -> bool {
144+
tcx.sess.mir_opt_level() >= 2
145145
}
146146

147147
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {

compiler/rustc_mir_transform/src/dest_prop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ use tracing::{debug, trace};
149149
pub(super) struct DestinationPropagation;
150150

151151
impl<'tcx> crate::MirPass<'tcx> for DestinationPropagation {
152-
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
152+
fn is_enabled(&self, tcx: TyCtxt<'tcx>) -> bool {
153153
// For now, only run at MIR opt level 3. Two things need to be changed before this can be
154154
// turned on by default:
155155
// 1. Because of the overeager removal of storage statements, this can cause stack space
@@ -158,7 +158,7 @@ impl<'tcx> crate::MirPass<'tcx> for DestinationPropagation {
158158
// 2. Despite being an overall perf improvement, this still causes a 30% regression in
159159
// keccak. We can temporarily fix this by bounding function size, but in the long term
160160
// we should fix this by being smarter about invalidating analysis results.
161-
sess.mir_opt_level() >= 3
161+
tcx.sess.mir_opt_level() >= 3
162162
}
163163

164164
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {

compiler/rustc_mir_transform/src/early_otherwise_branch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ use crate::patch::MirPatch;
9393
pub(super) struct EarlyOtherwiseBranch;
9494

9595
impl<'tcx> crate::MirPass<'tcx> for EarlyOtherwiseBranch {
96-
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
97-
sess.mir_opt_level() >= 2
96+
fn is_enabled(&self, tcx: TyCtxt<'tcx>) -> bool {
97+
tcx.sess.mir_opt_level() >= 2
9898
}
9999

100100
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ use crate::ssa::SsaLocals;
114114
pub(super) struct GVN;
115115

116116
impl<'tcx> crate::MirPass<'tcx> for GVN {
117-
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
118-
sess.mir_opt_level() >= 2
117+
fn is_enabled(&self, tcx: TyCtxt<'tcx>) -> bool {
118+
tcx.sess.mir_opt_level() >= 2
119119
}
120120

121121
#[instrument(level = "trace", skip(self, tcx, body))]

0 commit comments

Comments
 (0)