Skip to content

Commit 513ea64

Browse files
committed
add missing visit_consts
1 parent 8ff7850 commit 513ea64

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

src/librustc/traits/structural_impls.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,20 @@ impl<'tcx> TypeVisitor<'tcx> for BoundNamesCollector {
273273
t.super_visit_with(self)
274274
}
275275

276+
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool {
277+
match c.val {
278+
ty::ConstKind::Bound(debruijn, bound_var) if debruijn == self.binder_index => {
279+
self.types.insert(
280+
bound_var.as_u32(),
281+
Symbol::intern(&format!("^{}", bound_var.as_u32())),
282+
);
283+
}
284+
_ => (),
285+
}
286+
287+
c.super_visit_with(self)
288+
}
289+
276290
fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool {
277291
match r {
278292
ty::ReLateBound(index, br) if *index == self.binder_index => match br {

src/librustc/ty/fold.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -978,17 +978,27 @@ impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector {
978978
// ignore the inputs to a projection, as they may not appear
979979
// in the normalized form
980980
if self.just_constrained {
981-
match t.kind {
982-
ty::Projection(..) | ty::Opaque(..) => {
983-
return false;
984-
}
985-
_ => {}
981+
if let ty::Projection(..) | ty::Opaque(..) = t.kind {
982+
return false;
986983
}
987984
}
988985

989986
t.super_visit_with(self)
990987
}
991988

989+
fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool {
990+
// if we are only looking for "constrained" region, we have to
991+
// ignore the inputs of an unevaluated const, as they may not appear
992+
// in the normalized form
993+
if self.just_constrained {
994+
if let ty::ConstKind::Unevaluated(..) = c.val {
995+
return false;
996+
}
997+
}
998+
999+
c.super_visit_with(self)
1000+
}
1001+
9921002
fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool {
9931003
if let ty::ReLateBound(debruijn, br) = *r {
9941004
if debruijn == self.current_index {

0 commit comments

Comments
 (0)