]> git.lizzy.rs Git - rust.git/commitdiff
add missing visit_consts
authorBastian Kauschke <bastian_kauschke@hotmail.de>
Mon, 23 Mar 2020 17:39:25 +0000 (18:39 +0100)
committerBastian Kauschke <bastian_kauschke@hotmail.de>
Mon, 23 Mar 2020 17:39:25 +0000 (18:39 +0100)
src/librustc/traits/structural_impls.rs
src/librustc/ty/fold.rs

index a5efea9e5fa4d73c4ea7720132ca2017f4c35966..b1fb02a67b3ff3a8447747960d2c2224990524e7 100644 (file)
@@ -273,6 +273,20 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
         t.super_visit_with(self)
     }
 
+    fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool {
+        match c.val {
+            ty::ConstKind::Bound(debruijn, bound_var) if debruijn == self.binder_index => {
+                self.types.insert(
+                    bound_var.as_u32(),
+                    Symbol::intern(&format!("^{}", bound_var.as_u32())),
+                );
+            }
+            _ => (),
+        }
+
+        c.super_visit_with(self)
+    }
+
     fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool {
         match r {
             ty::ReLateBound(index, br) if *index == self.binder_index => match br {
index 4adca6c7d97723fc9da8bd663744ee4ff4a38b36..3f4f2407f1e6e2fc9e9b9ebd160f2d04b78035a3 100644 (file)
@@ -978,17 +978,27 @@ fn visit_ty(&mut self, t: Ty<'tcx>) -> bool {
         // ignore the inputs to a projection, as they may not appear
         // in the normalized form
         if self.just_constrained {
-            match t.kind {
-                ty::Projection(..) | ty::Opaque(..) => {
-                    return false;
-                }
-                _ => {}
+            if let ty::Projection(..) | ty::Opaque(..) = t.kind {
+                return false;
             }
         }
 
         t.super_visit_with(self)
     }
 
+    fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> bool {
+        // if we are only looking for "constrained" region, we have to
+        // ignore the inputs of an unevaluated const, as they may not appear
+        // in the normalized form
+        if self.just_constrained {
+            if let ty::ConstKind::Unevaluated(..) = c.val {
+                return false;
+            }
+        }
+
+        c.super_visit_with(self)
+    }
+
     fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool {
         if let ty::ReLateBound(debruijn, br) = *r {
             if debruijn == self.current_index {