1
Fork 0

address review again

This commit is contained in:
b-naber 2022-09-14 15:35:24 +02:00
parent ba00189d8e
commit 6af8fb7936
20 changed files with 119 additions and 520 deletions

View file

@ -38,6 +38,16 @@ where
})
}
fn renumber_regions_in_mir_constant<'tcx>(
infcx: &InferCtxt<'_, 'tcx>,
value: ConstantKind<'tcx>,
) -> ConstantKind<'tcx> {
infcx.tcx.super_fold_regions(value, |_region, _depth| {
let origin = NllRegionVariableOrigin::Existential { from_forall: false };
infcx.next_nll_region_var(origin)
})
}
struct NllVisitor<'a, 'tcx> {
infcx: &'a InferCtxt<'a, 'tcx>,
}
@ -49,6 +59,13 @@ impl<'a, 'tcx> NllVisitor<'a, 'tcx> {
{
renumber_regions(self.infcx, value)
}
fn renumber_regions_in_mir_constant(
&mut self,
value: ConstantKind<'tcx>,
) -> ConstantKind<'tcx> {
renumber_regions_in_mir_constant(self.infcx, value)
}
}
impl<'a, 'tcx> MutVisitor<'tcx> for NllVisitor<'a, 'tcx> {
@ -81,29 +98,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for NllVisitor<'a, 'tcx> {
#[instrument(skip(self), level = "debug")]
fn visit_constant(&mut self, constant: &mut Constant<'tcx>, _location: Location) {
let literal = constant.literal;
debug!("{:#?}", literal);
match literal {
ConstantKind::Ty(ct) => {
let ct = self.renumber_regions(ct);
debug!("renumbered ct {:#?}", ct);
constant.literal = ConstantKind::Ty(ct);
}
ConstantKind::Unevaluated(uv, ty) => {
debug!("uv: {:#?}, ty: {:#?}", uv, ty);
let uv = self.renumber_regions(uv);
debug!("uv: {:#?}", uv);
let ty = self.renumber_regions(ty);
debug!("{:#?}", ty);
constant.literal = ConstantKind::Unevaluated(uv, ty);
}
ConstantKind::Val(val, ty) => {
let ty = self.renumber_regions(ty);
constant.literal = ConstantKind::Val(val, ty);
}
}
constant.literal = self.renumber_regions_in_mir_constant(literal);
debug!("constant: {:#?}", constant);
}
}

View file

@ -354,7 +354,9 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
let tcx = self.tcx();
let maybe_uneval = match constant.literal {
ConstantKind::Ty(ct) => match ct.kind() {
ty::ConstKind::Unevaluated(uv) => Some(uv.expand()),
ty::ConstKind::Unevaluated(_) => {
bug!("should not encounter unevaluated ConstantKind::Ty here, got {:?}", ct)
}
_ => None,
},
ConstantKind::Unevaluated(uv, _) => Some(uv),