Skip to content

Commit ed1618d

Browse files
committed
MIR visitor: constant -> const_operand
1 parent 921645c commit ed1618d

File tree

11 files changed

+28
-24
lines changed

11 files changed

+28
-24
lines changed

compiler/rustc_borrowck/src/renumber.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for RegionRenumberer<'a, 'tcx> {
113113
}
114114

115115
#[instrument(skip(self), level = "debug")]
116-
fn visit_constant(&mut self, constant: &mut ConstOperand<'tcx>, location: Location) {
116+
fn visit_const_operand(&mut self, constant: &mut ConstOperand<'tcx>, location: Location) {
117117
let const_ = constant.const_;
118118
constant.const_ = self.renumber_regions(const_, || RegionCtxt::Location(location));
119119
debug!("constant: {:#?}", constant);

compiler/rustc_borrowck/src/type_check/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,10 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
301301
self.sanitize_place(place, location, context);
302302
}
303303

304-
fn visit_constant(&mut self, constant: &ConstOperand<'tcx>, location: Location) {
305-
debug!(?constant, ?location, "visit_constant");
304+
fn visit_const_operand(&mut self, constant: &ConstOperand<'tcx>, location: Location) {
305+
debug!(?constant, ?location, "visit_const_operand");
306306

307-
self.super_constant(constant, location);
307+
self.super_const_operand(constant, location);
308308
let ty = self.sanitize_type(constant, constant.const_.ty());
309309

310310
self.cx.infcx.tcx.for_each_free_region(&ty, |live_region| {

compiler/rustc_middle/src/mir/pretty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ fn use_verbose(ty: Ty<'_>, fn_def: bool) -> bool {
12871287
}
12881288

12891289
impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
1290-
fn visit_constant(&mut self, constant: &ConstOperand<'tcx>, _location: Location) {
1290+
fn visit_const_operand(&mut self, constant: &ConstOperand<'tcx>, _location: Location) {
12911291
let ConstOperand { span, user_ty, const_ } = constant;
12921292
if use_verbose(const_.ty(), true) {
12931293
self.push("mir::ConstOperand");
@@ -1415,7 +1415,7 @@ pub fn write_allocations<'tcx>(
14151415
struct CollectAllocIds(BTreeSet<AllocId>);
14161416

14171417
impl<'tcx> Visitor<'tcx> for CollectAllocIds {
1418-
fn visit_constant(&mut self, c: &ConstOperand<'tcx>, _: Location) {
1418+
fn visit_const_operand(&mut self, c: &ConstOperand<'tcx>, _: Location) {
14191419
match c.const_ {
14201420
Const::Ty(_, _) | Const::Unevaluated(..) => {}
14211421
Const::Val(val, _) => {

compiler/rustc_middle/src/mir/visit.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ macro_rules! make_mir_visitor {
184184

185185
/// This is called for every constant in the MIR body and every `required_consts`
186186
/// (i.e., including consts that have been dead-code-eliminated).
187-
fn visit_constant(
187+
fn visit_const_operand(
188188
&mut self,
189189
constant: & $($mutability)? ConstOperand<'tcx>,
190190
location: Location,
191191
) {
192-
self.super_constant(constant, location);
192+
self.super_const_operand(constant, location);
193193
}
194194

195195
fn visit_ty_const(
@@ -597,7 +597,7 @@ macro_rules! make_mir_visitor {
597597
}
598598
InlineAsmOperand::Const { value }
599599
| InlineAsmOperand::SymFn { value } => {
600-
self.visit_constant(value, location);
600+
self.visit_const_operand(value, location);
601601
}
602602
InlineAsmOperand::Out { place: None, .. }
603603
| InlineAsmOperand::SymStatic { def_id: _ }
@@ -788,7 +788,7 @@ macro_rules! make_mir_visitor {
788788
);
789789
}
790790
Operand::Constant(constant) => {
791-
self.visit_constant(constant, location);
791+
self.visit_const_operand(constant, location);
792792
}
793793
}
794794
}
@@ -867,7 +867,7 @@ macro_rules! make_mir_visitor {
867867
}
868868
}
869869
match value {
870-
VarDebugInfoContents::Const(c) => self.visit_constant(c, location),
870+
VarDebugInfoContents::Const(c) => self.visit_const_operand(c, location),
871871
VarDebugInfoContents::Place(place) =>
872872
self.visit_place(
873873
place,
@@ -882,7 +882,7 @@ macro_rules! make_mir_visitor {
882882
_scope: $(& $mutability)? SourceScope
883883
) {}
884884

885-
fn super_constant(
885+
fn super_const_operand(
886886
&mut self,
887887
constant: & $($mutability)? ConstOperand<'tcx>,
888888
location: Location
@@ -1057,7 +1057,7 @@ macro_rules! super_body {
10571057

10581058
for const_ in &$($mutability)? $body.required_consts {
10591059
let location = Location::START;
1060-
$self.visit_constant(const_, location);
1060+
$self.visit_const_operand(const_, location);
10611061
}
10621062
}
10631063
}

compiler/rustc_mir_transform/src/known_panics_lint.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,9 @@ impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> {
706706
self.super_operand(operand, location);
707707
}
708708

709-
fn visit_constant(&mut self, constant: &ConstOperand<'tcx>, location: Location) {
710-
trace!("visit_constant: {:?}", constant);
711-
self.super_constant(constant, location);
709+
fn visit_const_operand(&mut self, constant: &ConstOperand<'tcx>, location: Location) {
710+
trace!("visit_const_operand: {:?}", constant);
711+
self.super_const_operand(constant, location);
712712
self.eval_constant(constant);
713713
}
714714

compiler/rustc_mir_transform/src/promote_consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Promoter<'a, 'tcx> {
956956
}
957957
}
958958

959-
fn visit_constant(&mut self, constant: &mut ConstOperand<'tcx>, _location: Location) {
959+
fn visit_const_operand(&mut self, constant: &mut ConstOperand<'tcx>, _location: Location) {
960960
if constant.const_.is_required_const() {
961961
self.promoted.required_consts.push(*constant);
962962
}

compiler/rustc_mir_transform/src/required_consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ impl<'a, 'tcx> RequiredConstsVisitor<'a, 'tcx> {
1212
}
1313

1414
impl<'tcx> Visitor<'tcx> for RequiredConstsVisitor<'_, 'tcx> {
15-
fn visit_constant(&mut self, constant: &ConstOperand<'tcx>, _: Location) {
15+
fn visit_const_operand(&mut self, constant: &ConstOperand<'tcx>, _: Location) {
1616
if constant.const_.is_required_const() {
1717
self.required_consts.push(*constant);
1818
}

compiler/rustc_mir_transform/src/reveal_all.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ impl<'tcx> MutVisitor<'tcx> for RevealAllVisitor<'tcx> {
4949
}
5050

5151
#[inline]
52-
fn visit_constant(&mut self, constant: &mut ConstOperand<'tcx>, location: Location) {
52+
fn visit_const_operand(&mut self, constant: &mut ConstOperand<'tcx>, location: Location) {
5353
// We have to use `try_normalize_erasing_regions` here, since it's
5454
// possible that we visit impossible-to-satisfy where clauses here,
5555
// see #91745
5656
if let Ok(c) = self.tcx.try_normalize_erasing_regions(self.param_env, constant.const_) {
5757
constant.const_ = c;
5858
}
59-
self.super_constant(constant, location);
59+
self.super_const_operand(constant, location);
6060
}
6161

6262
#[inline]

compiler/rustc_monomorphize/src/collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirUsedCollector<'a, 'tcx> {
799799
/// This does not walk the MIR of the constant as that is not needed for codegen, all we need is
800800
/// to ensure that the constant evaluates successfully and walk the result.
801801
#[instrument(skip(self), level = "debug")]
802-
fn visit_constant(&mut self, constant: &mir::ConstOperand<'tcx>, location: Location) {
802+
fn visit_const_operand(&mut self, constant: &mir::ConstOperand<'tcx>, location: Location) {
803803
// No `super_constant` as we don't care about `visit_ty`/`visit_ty_const`.
804804
let Some(val) = self.eval_constant(constant) else { return };
805805
collect_const_value(self.tcx, val, self.used_items);

compiler/rustc_monomorphize/src/polymorphize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> {
261261
self.super_local_decl(local, local_decl);
262262
}
263263

264-
fn visit_constant(&mut self, ct: &mir::ConstOperand<'tcx>, location: Location) {
264+
fn visit_const_operand(&mut self, ct: &mir::ConstOperand<'tcx>, location: Location) {
265265
match ct.const_ {
266266
mir::Const::Ty(_, c) => {
267267
c.visit_with(self);

compiler/rustc_smir/src/rustc_smir/builder.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ impl<'tcx> BodyBuilder<'tcx> {
5252
}
5353

5454
impl<'tcx> MutVisitor<'tcx> for BodyBuilder<'tcx> {
55-
fn visit_constant(&mut self, constant: &mut mir::ConstOperand<'tcx>, location: mir::Location) {
55+
fn visit_const_operand(
56+
&mut self,
57+
constant: &mut mir::ConstOperand<'tcx>,
58+
location: mir::Location,
59+
) {
5660
let const_ = constant.const_;
5761
let val = match const_.eval(self.tcx, ty::ParamEnv::reveal_all(), constant.span) {
5862
Ok(v) => v,
@@ -63,7 +67,7 @@ impl<'tcx> MutVisitor<'tcx> for BodyBuilder<'tcx> {
6367
};
6468
let ty = constant.ty();
6569
constant.const_ = mir::Const::Val(val, ty);
66-
self.super_constant(constant, location);
70+
self.super_const_operand(constant, location);
6771
}
6872

6973
fn tcx(&self) -> TyCtxt<'tcx> {

0 commit comments

Comments
 (0)