Skip to content

Commit 2554fa1

Browse files
committed
renumber regions in mir constants correctly
1 parent a4bbb8d commit 2554fa1

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

compiler/rustc_borrowck/src/renumber.rs

+32-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use rustc_index::vec::IndexVec;
22
use rustc_infer::infer::{InferCtxt, NllRegionVariableOrigin};
33
use rustc_middle::mir::visit::{MutVisitor, TyContext};
44
use rustc_middle::mir::{Body, Location, Promoted};
5+
use rustc_middle::mir::{Constant, ConstantKind};
56
use rustc_middle::ty::subst::SubstsRef;
67
use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable};
78

@@ -77,7 +78,36 @@ impl<'a, 'tcx> MutVisitor<'tcx> for NllVisitor<'a, 'tcx> {
7778
debug!(?region);
7879
}
7980

80-
fn visit_const(&mut self, constant: &mut ty::Const<'tcx>, _location: Location) {
81-
*constant = self.renumber_regions(*constant);
81+
#[instrument(skip(self), level = "debug")]
82+
fn visit_constant(&mut self, constant: &mut Constant<'tcx>, _location: Location) {
83+
let literal = constant.literal;
84+
debug!("{:#?}", literal);
85+
86+
match literal {
87+
ConstantKind::Ty(ct) => {
88+
let ct = self.renumber_regions(ct);
89+
debug!("renumbered ct {:#?}", ct);
90+
91+
constant.literal = ConstantKind::Ty(ct);
92+
}
93+
ConstantKind::Unevaluated(uv, ty) => {
94+
debug!("uv: {:#?}, ty: {:#?}", uv, ty);
95+
let uv = self.renumber_regions(uv);
96+
debug!("uv: {:#?}", uv);
97+
let ty = self.renumber_regions(ty);
98+
debug!("{:#?}", ty);
99+
constant.literal = ConstantKind::Unevaluated(uv, ty);
100+
}
101+
ConstantKind::Val(val, ty) => {
102+
let ty = self.renumber_regions(ty);
103+
constant.literal = ConstantKind::Val(val, ty);
104+
}
105+
}
106+
107+
debug!("constant: {:#?}", constant);
108+
}
109+
110+
fn visit_const(&mut self, _constant: &mut ty::Const<'tcx>, _location: Location) {
111+
bug!("should never be called");
82112
}
83113
}

0 commit comments

Comments
 (0)