require a tcx
for TypeVisitor
This commit is contained in:
parent
76e755cf4a
commit
f4b606fd17
24 changed files with 182 additions and 50 deletions
|
@ -1537,6 +1537,10 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
impl<'tcx> ty::fold::TypeVisitor<'tcx> for OpaqueTypesVisitor<'tcx> {
|
||||
fn tcx_for_anon_const_substs<'a>(&'a self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if let Some((kind, def_id)) = TyCategory::from_ty(self.tcx, t) {
|
||||
let span = self.tcx.def_span(def_id);
|
||||
|
|
|
@ -9,7 +9,9 @@ use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorRepor
|
|||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::intravisit::{walk_ty, ErasedMap, NestedVisitorMap, Visitor};
|
||||
use rustc_hir::{self as hir, GenericBound, Item, ItemKind, Lifetime, LifetimeName, Node, TyKind};
|
||||
use rustc_middle::ty::{self, AssocItemContainer, RegionKind, Ty, TypeFoldable, TypeVisitor};
|
||||
use rustc_middle::ty::{
|
||||
self, AssocItemContainer, RegionKind, Ty, TyCtxt, TypeFoldable, TypeVisitor,
|
||||
};
|
||||
use rustc_span::symbol::Ident;
|
||||
use rustc_span::{MultiSpan, Span};
|
||||
|
||||
|
@ -476,8 +478,12 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
/// Collect all the trait objects in a type that could have received an implicit `'static` lifetime.
|
||||
pub(super) struct TraitObjectVisitor(pub(super) FxHashSet<DefId>);
|
||||
|
||||
impl TypeVisitor<'_> for TraitObjectVisitor {
|
||||
fn visit_ty(&mut self, t: Ty<'_>) -> ControlFlow<Self::BreakTy> {
|
||||
impl<'tcx> TypeVisitor<'tcx> for TraitObjectVisitor {
|
||||
fn tcx_for_anon_const_substs<'a>(&'a self) -> TyCtxt<'tcx> {
|
||||
bug!("tcx_for_anon_const_substs called for TraitObjectVisitor");
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
match t.kind() {
|
||||
ty::Dynamic(preds, RegionKind::ReStatic) => {
|
||||
if let Some(def_id) = preds.principal_def_id() {
|
||||
|
|
|
@ -202,6 +202,7 @@ where
|
|||
};
|
||||
|
||||
value.skip_binder().visit_with(&mut ScopeInstantiator {
|
||||
tcx: self.infcx.tcx,
|
||||
next_region: &mut next_region,
|
||||
target_index: ty::INNERMOST,
|
||||
bound_region_scope: &mut scope,
|
||||
|
@ -757,6 +758,7 @@ where
|
|||
/// `for<..`>. For each of those, it creates an entry in
|
||||
/// `bound_region_scope`.
|
||||
struct ScopeInstantiator<'me, 'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
next_region: &'me mut dyn FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
|
||||
// The debruijn index of the scope we are instantiating.
|
||||
target_index: ty::DebruijnIndex,
|
||||
|
@ -764,6 +766,10 @@ struct ScopeInstantiator<'me, 'tcx> {
|
|||
}
|
||||
|
||||
impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
|
||||
fn tcx_for_anon_const_substs<'a>(&'a self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
|
||||
fn visit_binder<T: TypeFoldable<'tcx>>(
|
||||
&mut self,
|
||||
t: &ty::Binder<'tcx, T>,
|
||||
|
|
|
@ -126,6 +126,11 @@ impl<'a, 'tcx> UnresolvedTypeFinder<'a, 'tcx> {
|
|||
|
||||
impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> {
|
||||
type BreakTy = (Ty<'tcx>, Option<Span>);
|
||||
|
||||
fn tcx_for_anon_const_substs(&self) -> TyCtxt<'tcx> {
|
||||
self.infcx.tcx
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
let t = self.infcx.shallow_resolve(t);
|
||||
if t.has_infer_types() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue