]> git.lizzy.rs Git - rust.git/commitdiff
impl visit_const for HasEscapingVarsVisitor
authorGabriel Smith <ga29smith@gmail.com>
Fri, 1 Mar 2019 04:09:44 +0000 (23:09 -0500)
committervarkor <github@varkor.com>
Wed, 1 May 2019 22:10:57 +0000 (23:10 +0100)
Signed-off-by: Gabriel Smith <ga29smith@gmail.com>
src/librustc/ty/fold.rs

index dd936efb3c80776a431999ac24b2cc2404fdc4b0..96705124b28239a6e801704423f857f9bf74fe94 100644 (file)
@@ -32,6 +32,7 @@
 //! looking for, and does not need to visit anything else.
 
 use crate::hir::def_id::DefId;
+use crate::mir::interpret::ConstValue;
 use crate::ty::{self, Binder, Ty, TyCtxt, TypeFlags, flags::FlagComputation};
 
 use std::collections::BTreeMap;
@@ -840,6 +841,17 @@ fn visit_region(&mut self, r: ty::Region<'tcx>) -> bool {
         // visited.
         r.bound_at_or_above_binder(self.outer_index)
     }
+
+    fn visit_const(&mut self, c: &'tcx ty::LazyConst<'tcx>) -> bool {
+        if let ty::LazyConst::Evaluated(ty::Const {
+            val: ConstValue::Infer(ty::InferConst::Canonical(debruijn, _)),
+            ..
+        }) = *c {
+            debruijn >= self.outer_index
+        } else {
+            false
+        }
+    }
 }
 
 struct HasTypeFlagsVisitor {