diff --git a/src/librustc/ty/fold.rs b/src/librustc/ty/fold.rs index dd936efb3c8..96705124b28 100644 --- a/src/librustc/ty/fold.rs +++ b/src/librustc/ty/fold.rs @@ -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 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor { // 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 {