mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Make visiting traits generic over the Interner
This commit is contained in:
parent
0b7dda9afd
commit
dea342d861
@ -21,7 +21,7 @@ where
|
||||
tcx: TyCtxt<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> TypeVisitor<'tcx> for UsedParamsNeedSubstVisitor<'tcx> {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for UsedParamsNeedSubstVisitor<'tcx> {
|
||||
type BreakTy = FoundParam;
|
||||
|
||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
|
@ -261,7 +261,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes(
|
||||
selftys: Vec<(Span, Option<String>)>,
|
||||
}
|
||||
|
||||
impl<'tcx> ty::visit::ir::TypeVisitor<'tcx> for ProhibitOpaqueVisitor<'tcx> {
|
||||
impl<'tcx> ty::visit::ir::TypeVisitor<TyCtxt<'tcx>> for ProhibitOpaqueVisitor<'tcx> {
|
||||
type BreakTy = Ty<'tcx>;
|
||||
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
@ -1447,7 +1447,7 @@ fn opaque_type_cycle_error(
|
||||
opaques: Vec<DefId>,
|
||||
closures: Vec<DefId>,
|
||||
}
|
||||
impl<'tcx> ty::visit::ir::TypeVisitor<'tcx> for OpaqueTypeCollector {
|
||||
impl<'tcx> ty::visit::ir::TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeCollector {
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
match *t.kind() {
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => {
|
||||
|
@ -772,7 +772,7 @@ impl<'tcx> GATSubstCollector<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeVisitor<'tcx> for GATSubstCollector<'tcx> {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for GATSubstCollector<'tcx> {
|
||||
type BreakTy = !;
|
||||
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
@ -1435,7 +1435,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
|
||||
struct CountParams {
|
||||
params: FxHashSet<u32>,
|
||||
}
|
||||
impl<'tcx> ty::visit::ir::TypeVisitor<'tcx> for CountParams {
|
||||
impl<'tcx> ty::visit::ir::TypeVisitor<TyCtxt<'tcx>> for CountParams {
|
||||
type BreakTy = ();
|
||||
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
|
@ -552,7 +552,7 @@ fn fast_reject_auto_impl<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId, self_ty:
|
||||
seen: FxHashSet<DefId>,
|
||||
}
|
||||
|
||||
impl<'tcx> TypeVisitor<'tcx> for DisableAutoTraitVisitor<'tcx> {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for DisableAutoTraitVisitor<'tcx> {
|
||||
type BreakTy = ();
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
let tcx = self.tcx;
|
||||
|
@ -1752,7 +1752,7 @@ fn is_late_bound_map(
|
||||
|
||||
use std::ops::ControlFlow;
|
||||
use ty::Ty;
|
||||
impl<'tcx> TypeVisitor<'tcx> for ConstrainedCollectorPostAstConv {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ConstrainedCollectorPostAstConv {
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<!> {
|
||||
match t.kind() {
|
||||
ty::Param(param_ty) => {
|
||||
|
@ -56,7 +56,7 @@ struct ParameterCollector {
|
||||
include_nonconstraining: bool,
|
||||
}
|
||||
|
||||
impl<'tcx> TypeVisitor<'tcx> for ParameterCollector {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ParameterCollector {
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
match *t.kind() {
|
||||
ty::Alias(ty::Projection, ..) if !self.include_nonconstraining => {
|
||||
|
@ -101,7 +101,7 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ty::ir::TypeVisitor<'tcx> for OpaqueTypeLifetimeCollector<'tcx> {
|
||||
impl<'tcx> ty::ir::TypeVisitor<TyCtxt<'tcx>> for OpaqueTypeLifetimeCollector<'tcx> {
|
||||
#[instrument(level = "trace", skip(self), ret)]
|
||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if let ty::RegionKind::ReEarlyBound(ebr) = r.kind() {
|
||||
|
@ -12,7 +12,7 @@ use rustc_infer::infer::{InferOk, InferResult};
|
||||
use rustc_macros::{TypeFoldable, TypeVisitable};
|
||||
use rustc_middle::ty::subst::InternalSubsts;
|
||||
use rustc_middle::ty::visit::TypeVisitable;
|
||||
use rustc_middle::ty::{self, ir::TypeVisitor, Ty, TypeSuperVisitable};
|
||||
use rustc_middle::ty::{self, ir::TypeVisitor, Ty, TyCtxt, TypeSuperVisitable};
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_span::sym;
|
||||
@ -232,7 +232,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
struct MentionsTy<'tcx> {
|
||||
expected_ty: Ty<'tcx>,
|
||||
}
|
||||
impl<'tcx> TypeVisitor<'tcx> for MentionsTy<'tcx> {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for MentionsTy<'tcx> {
|
||||
type BreakTy = ();
|
||||
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
|
@ -3,7 +3,9 @@ use rustc_hir as hir;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_infer::traits::ObligationCauseCode;
|
||||
use rustc_middle::ty::{self, ir::TypeVisitor, DefIdTree, Ty, TypeSuperVisitable, TypeVisitable};
|
||||
use rustc_middle::ty::{
|
||||
self, ir::TypeVisitor, DefIdTree, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable,
|
||||
};
|
||||
use rustc_span::{self, Span};
|
||||
use rustc_trait_selection::traits;
|
||||
|
||||
@ -247,7 +249,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
t: T,
|
||||
) -> Option<ty::GenericArg<'tcx>> {
|
||||
struct FindAmbiguousParameter<'a, 'tcx>(&'a FnCtxt<'a, 'tcx>, DefId);
|
||||
impl<'tcx> TypeVisitor<'tcx> for FindAmbiguousParameter<'_, 'tcx> {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for FindAmbiguousParameter<'_, 'tcx> {
|
||||
type BreakTy = ty::GenericArg<'tcx>;
|
||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> std::ops::ControlFlow<Self::BreakTy> {
|
||||
if let Some(origin) = self.0.type_var_origin(ty)
|
||||
|
@ -561,7 +561,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
|
||||
struct RecursionChecker {
|
||||
def_id: LocalDefId,
|
||||
}
|
||||
impl<'tcx> ty::ir::TypeVisitor<'tcx> for RecursionChecker {
|
||||
impl<'tcx> ty::ir::TypeVisitor<TyCtxt<'tcx>> for RecursionChecker {
|
||||
type BreakTy = ();
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *t.kind() {
|
||||
|
@ -1491,7 +1491,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ty::visit::ir::TypeVisitor<'tcx> for OpaqueTypesVisitor<'tcx> {
|
||||
impl<'tcx> ty::visit::ir::TypeVisitor<TyCtxt<'tcx>> for OpaqueTypesVisitor<'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);
|
||||
|
@ -540,7 +540,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
/// Collect all the trait objects in a type that could have received an implicit `'static` lifetime.
|
||||
pub struct TraitObjectVisitor(pub FxIndexSet<DefId>);
|
||||
|
||||
impl<'tcx> TypeVisitor<'tcx> for TraitObjectVisitor {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for TraitObjectVisitor {
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
match t.kind() {
|
||||
ty::Dynamic(preds, re, _) if re.is_static() => {
|
||||
|
@ -75,7 +75,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ty::visit::ir::TypeVisitor<'tcx> for HighlightBuilder<'tcx> {
|
||||
impl<'tcx> ty::visit::ir::TypeVisitor<TyCtxt<'tcx>> for HighlightBuilder<'tcx> {
|
||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if !r.has_name() && self.counter <= 3 {
|
||||
self.highlight.highlighting_region(r, self.counter);
|
||||
|
@ -792,7 +792,7 @@ struct ScopeInstantiator<'me, 'tcx> {
|
||||
bound_region_scope: &'me mut BoundRegionScope<'tcx>,
|
||||
}
|
||||
|
||||
impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
|
||||
impl<'me, 'tcx> TypeVisitor<TyCtxt<'tcx>> for ScopeInstantiator<'me, 'tcx> {
|
||||
fn visit_binder<T: TypeVisitable<'tcx>>(
|
||||
&mut self,
|
||||
t: &ty::Binder<'tcx, T>,
|
||||
|
@ -431,7 +431,7 @@ pub struct ConstrainOpaqueTypeRegionVisitor<'tcx, OP: FnMut(ty::Region<'tcx>)> {
|
||||
pub op: OP,
|
||||
}
|
||||
|
||||
impl<'tcx, OP> TypeVisitor<'tcx> for ConstrainOpaqueTypeRegionVisitor<'tcx, OP>
|
||||
impl<'tcx, OP> TypeVisitor<TyCtxt<'tcx>> for ConstrainOpaqueTypeRegionVisitor<'tcx, OP>
|
||||
where
|
||||
OP: FnMut(ty::Region<'tcx>),
|
||||
{
|
||||
|
@ -127,7 +127,7 @@ impl<'a, 'tcx> UnresolvedTypeOrConstFinder<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeOrConstFinder<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for UnresolvedTypeOrConstFinder<'a, 'tcx> {
|
||||
type BreakTy = (ty::Term<'tcx>, Option<Span>);
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
let t = self.infcx.shallow_resolve(t);
|
||||
|
@ -2,7 +2,7 @@ use crate::traits;
|
||||
use crate::traits::project::Normalized;
|
||||
use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFoldable};
|
||||
use rustc_middle::ty::visit::{TypeVisitable, TypeVisitor};
|
||||
use rustc_middle::ty::{self, ir};
|
||||
use rustc_middle::ty::{self, ir, TyCtxt};
|
||||
|
||||
use std::fmt;
|
||||
use std::ops::ControlFlow;
|
||||
@ -72,7 +72,7 @@ impl<'tcx, O: TypeFoldable<'tcx>> ir::TypeFoldable<'tcx> for traits::Obligation<
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, O: TypeVisitable<'tcx>> ir::TypeVisitable<'tcx> for traits::Obligation<'tcx, O> {
|
||||
impl<'tcx, O: TypeVisitable<'tcx>> ir::TypeVisitable<TyCtxt<'tcx>> for traits::Obligation<'tcx, O> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
self.predicate.visit_with(visitor)?;
|
||||
self.param_env.visit_with(visitor)
|
||||
|
@ -1144,7 +1144,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
||||
|
||||
fn check_for_opaque_ty(&mut self, sp: Span, ty: Ty<'tcx>) -> bool {
|
||||
struct ProhibitOpaqueTypes;
|
||||
impl<'tcx> ty::visit::ir::TypeVisitor<'tcx> for ProhibitOpaqueTypes {
|
||||
impl<'tcx> ty::visit::ir::TypeVisitor<TyCtxt<'tcx>> for ProhibitOpaqueTypes {
|
||||
type BreakTy = Ty<'tcx>;
|
||||
|
||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
|
@ -19,7 +19,7 @@ pub fn type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
|
||||
s.bind_with(|_| synstructure::BindStyle::Move);
|
||||
|
||||
s.bound_impl(
|
||||
quote!(::rustc_middle::ty::visit::ir::TypeVisitable<'tcx>),
|
||||
quote!(::rustc_middle::ty::visit::ir::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>),
|
||||
quote! {
|
||||
fn visit_with<__V: ::rustc_middle::ty::visit::TypeVisitor<'tcx>>(
|
||||
&self,
|
||||
|
@ -86,7 +86,7 @@ macro_rules! TrivialTypeTraversalImpls {
|
||||
}
|
||||
}
|
||||
|
||||
impl<$tcx> $crate::ty::visit::ir::TypeVisitable<$tcx> for $ty {
|
||||
impl<$tcx> $crate::ty::visit::ir::TypeVisitable<$crate::ty::TyCtxt<$tcx>> for $ty {
|
||||
#[inline]
|
||||
fn visit_with<F: $crate::ty::visit::TypeVisitor<$tcx>>(
|
||||
&self,
|
||||
@ -136,7 +136,7 @@ macro_rules! EnumTypeTraversalImpl {
|
||||
(impl<$($p:tt),*> TypeVisitable<$tcx:tt> for $s:path {
|
||||
$($variants:tt)*
|
||||
} $(where $($wc:tt)*)*) => {
|
||||
impl<$($p),*> $crate::ty::visit::ir::TypeVisitable<$tcx> for $s
|
||||
impl<$($p),*> $crate::ty::visit::ir::TypeVisitable<$crate::ty::TyCtxt<$tcx>> for $s
|
||||
$(where $($wc)*)*
|
||||
{
|
||||
fn visit_with<V: $crate::ty::visit::TypeVisitor<$tcx>>(
|
||||
|
@ -2751,7 +2751,7 @@ impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ir::TypeVisitable<'tcx> for UserTypeProjection {
|
||||
impl<'tcx> ir::TypeVisitable<TyCtxt<'tcx>> for UserTypeProjection {
|
||||
fn visit_with<Vs: TypeVisitor<'tcx>>(&self, visitor: &mut Vs) -> ControlFlow<Vs::BreakTy> {
|
||||
self.base.visit_with(visitor)
|
||||
// Note: there's nothing in `self.proj` to visit.
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use super::*;
|
||||
|
||||
impl<'tcx, R: Idx, C: Idx> ir::TypeVisitable<'tcx> for BitMatrix<R, C> {
|
||||
impl<'tcx, R: Idx, C: Idx> ir::TypeVisitable<TyCtxt<'tcx>> for BitMatrix<R, C> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use rustc_data_structures::intern::Interned;
|
||||
|
||||
use crate::ty::{
|
||||
ir::{self, TypeFoldable, TypeVisitable},
|
||||
FallibleTypeFolder, Ty, TypeFolder, TypeVisitor,
|
||||
FallibleTypeFolder, Ty, TyCtxt, TypeFolder, TypeVisitor,
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Copy, Clone, Hash)]
|
||||
@ -48,7 +48,7 @@ impl<'tcx> TypeFoldable<'tcx> for ExternalConstraints<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeVisitable<'tcx> for ExternalConstraints<'tcx> {
|
||||
impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for ExternalConstraints<'tcx> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(
|
||||
&self,
|
||||
visitor: &mut V,
|
||||
|
@ -461,7 +461,7 @@ pub struct IsSuggestableVisitor<'tcx> {
|
||||
infer_suggestable: bool,
|
||||
}
|
||||
|
||||
impl<'tcx> TypeVisitor<'tcx> for IsSuggestableVisitor<'tcx> {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for IsSuggestableVisitor<'tcx> {
|
||||
type BreakTy = ();
|
||||
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
|
@ -61,7 +61,7 @@ pub mod ir {
|
||||
///
|
||||
/// To implement this conveniently, use the derive macro located in
|
||||
/// `rustc_macros`.
|
||||
pub trait TypeFoldable<'tcx>: TypeVisitable<'tcx> {
|
||||
pub trait TypeFoldable<'tcx>: TypeVisitable<TyCtxt<'tcx>> {
|
||||
/// The entry point for folding. To fold a value `t` with a folder `f`
|
||||
/// call: `t.try_fold_with(f)`.
|
||||
///
|
||||
|
@ -923,7 +923,7 @@ impl<'tcx> ir::TypeFoldable<'tcx> for Term<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ir::TypeVisitable<'tcx> for Term<'tcx> {
|
||||
impl<'tcx> ir::TypeVisitable<TyCtxt<'tcx>> for Term<'tcx> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
self.unpack().visit_with(visitor)
|
||||
}
|
||||
@ -1632,7 +1632,7 @@ impl<'tcx> ir::TypeFoldable<'tcx> for ParamEnv<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ir::TypeVisitable<'tcx> for ParamEnv<'tcx> {
|
||||
impl<'tcx> ir::TypeVisitable<TyCtxt<'tcx>> for ParamEnv<'tcx> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
self.caller_bounds().visit_with(visitor)?;
|
||||
self.reveal().visit_with(visitor)
|
||||
|
@ -2493,7 +2493,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ty::visit::ir::TypeVisitor<'tcx> for RegionNameCollector<'tcx> {
|
||||
impl<'tcx> ty::visit::ir::TypeVisitor<TyCtxt<'tcx>> for RegionNameCollector<'tcx> {
|
||||
type BreakTy = ();
|
||||
|
||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
|
@ -369,7 +369,7 @@ impl<'tcx> ir::TypeFoldable<'tcx> for ty::AdtDef<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ir::TypeVisitable<'tcx> for ty::AdtDef<'tcx> {
|
||||
impl<'tcx> ir::TypeVisitable<TyCtxt<'tcx>> for ty::AdtDef<'tcx> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
@ -384,7 +384,9 @@ impl<'tcx, T: TypeFoldable<'tcx>, U: TypeFoldable<'tcx>> ir::TypeFoldable<'tcx>
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: TypeVisitable<'tcx>, U: TypeVisitable<'tcx>> ir::TypeVisitable<'tcx> for (T, U) {
|
||||
impl<'tcx, T: TypeVisitable<'tcx>, U: TypeVisitable<'tcx>> ir::TypeVisitable<TyCtxt<'tcx>>
|
||||
for (T, U)
|
||||
{
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
self.0.visit_with(visitor)?;
|
||||
self.1.visit_with(visitor)
|
||||
@ -407,7 +409,7 @@ impl<'tcx, A: TypeFoldable<'tcx>, B: TypeFoldable<'tcx>, C: TypeFoldable<'tcx>>
|
||||
}
|
||||
|
||||
impl<'tcx, A: TypeVisitable<'tcx>, B: TypeVisitable<'tcx>, C: TypeVisitable<'tcx>>
|
||||
ir::TypeVisitable<'tcx> for (A, B, C)
|
||||
ir::TypeVisitable<TyCtxt<'tcx>> for (A, B, C)
|
||||
{
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
self.0.visit_with(visitor)?;
|
||||
@ -482,7 +484,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable<'tcx> for Rc<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable<'tcx> for Rc<T> {
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable<TyCtxt<'tcx>> for Rc<T> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
(**self).visit_with(visitor)
|
||||
}
|
||||
@ -528,7 +530,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable<'tcx> for Arc<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable<'tcx> for Arc<T> {
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable<TyCtxt<'tcx>> for Arc<T> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
(**self).visit_with(visitor)
|
||||
}
|
||||
@ -540,7 +542,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable<'tcx> for Box<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable<'tcx> for Box<T> {
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable<TyCtxt<'tcx>> for Box<T> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
(**self).visit_with(visitor)
|
||||
}
|
||||
@ -552,13 +554,13 @@ impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable<'tcx> for Vec<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable<'tcx> for Vec<T> {
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable<TyCtxt<'tcx>> for Vec<T> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
self.iter().try_for_each(|t| t.visit_with(visitor))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable<'tcx> for &[T] {
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable<TyCtxt<'tcx>> for &[T] {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
self.iter().try_for_each(|t| t.visit_with(visitor))
|
||||
}
|
||||
@ -570,7 +572,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable<'tcx> for Box<[T]> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable<'tcx> for Box<[T]> {
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable<TyCtxt<'tcx>> for Box<[T]> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
self.iter().try_for_each(|t| t.visit_with(visitor))
|
||||
}
|
||||
@ -582,7 +584,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable<'tcx> for ty::Binder<'tcx, T>
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable<'tcx> for ty::Binder<'tcx, T> {
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable<TyCtxt<'tcx>> for ty::Binder<'tcx, T> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
visitor.visit_binder(self)
|
||||
}
|
||||
@ -597,7 +599,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeSuperFoldable<'tcx> for ty::Binder<'tcx, T
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> TypeSuperVisitable<'tcx> for ty::Binder<'tcx, T> {
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> TypeSuperVisitable<TyCtxt<'tcx>> for ty::Binder<'tcx, T> {
|
||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
self.as_ref().skip_binder().visit_with(visitor)
|
||||
}
|
||||
@ -627,7 +629,7 @@ impl<'tcx> ir::TypeFoldable<'tcx> for Ty<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ir::TypeVisitable<'tcx> for Ty<'tcx> {
|
||||
impl<'tcx> ir::TypeVisitable<TyCtxt<'tcx>> for Ty<'tcx> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
visitor.visit_ty(*self)
|
||||
}
|
||||
@ -683,7 +685,7 @@ impl<'tcx> TypeSuperFoldable<'tcx> for Ty<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeSuperVisitable<'tcx> for Ty<'tcx> {
|
||||
impl<'tcx> TypeSuperVisitable<TyCtxt<'tcx>> for Ty<'tcx> {
|
||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
match self.kind() {
|
||||
ty::RawPtr(ref tm) => tm.visit_with(visitor),
|
||||
@ -733,7 +735,7 @@ impl<'tcx> ir::TypeFoldable<'tcx> for ty::Region<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ir::TypeVisitable<'tcx> for ty::Region<'tcx> {
|
||||
impl<'tcx> ir::TypeVisitable<TyCtxt<'tcx>> for ty::Region<'tcx> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
visitor.visit_region(*self)
|
||||
}
|
||||
@ -748,7 +750,7 @@ impl<'tcx> TypeSuperFoldable<'tcx> for ty::Region<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeSuperVisitable<'tcx> for ty::Region<'tcx> {
|
||||
impl<'tcx> TypeSuperVisitable<TyCtxt<'tcx>> for ty::Region<'tcx> {
|
||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
@ -760,7 +762,7 @@ impl<'tcx> ir::TypeFoldable<'tcx> for ty::Predicate<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ir::TypeVisitable<'tcx> for ty::Predicate<'tcx> {
|
||||
impl<'tcx> ir::TypeVisitable<TyCtxt<'tcx>> for ty::Predicate<'tcx> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
visitor.visit_predicate(*self)
|
||||
}
|
||||
@ -776,7 +778,7 @@ impl<'tcx> TypeSuperFoldable<'tcx> for ty::Predicate<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeSuperVisitable<'tcx> for ty::Predicate<'tcx> {
|
||||
impl<'tcx> TypeSuperVisitable<TyCtxt<'tcx>> for ty::Predicate<'tcx> {
|
||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
self.kind().visit_with(visitor)
|
||||
}
|
||||
@ -794,7 +796,7 @@ impl<'tcx, T: TypeFoldable<'tcx>, I: Idx> ir::TypeFoldable<'tcx> for IndexVec<I,
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: TypeVisitable<'tcx>, I: Idx> ir::TypeVisitable<'tcx> for IndexVec<I, T> {
|
||||
impl<'tcx, T: TypeVisitable<'tcx>, I: Idx> ir::TypeVisitable<TyCtxt<'tcx>> for IndexVec<I, T> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
self.iter().try_for_each(|t| t.visit_with(visitor))
|
||||
}
|
||||
@ -806,7 +808,7 @@ impl<'tcx> ir::TypeFoldable<'tcx> for ty::Const<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ir::TypeVisitable<'tcx> for ty::Const<'tcx> {
|
||||
impl<'tcx> ir::TypeVisitable<TyCtxt<'tcx>> for ty::Const<'tcx> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
visitor.visit_const(*self)
|
||||
}
|
||||
@ -827,7 +829,7 @@ impl<'tcx> TypeSuperFoldable<'tcx> for ty::Const<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeSuperVisitable<'tcx> for ty::Const<'tcx> {
|
||||
impl<'tcx> TypeSuperVisitable<TyCtxt<'tcx>> for ty::Const<'tcx> {
|
||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
self.ty().visit_with(visitor)?;
|
||||
self.kind().visit_with(visitor)
|
||||
@ -840,19 +842,19 @@ impl<'tcx> ir::TypeFoldable<'tcx> for InferConst<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ir::TypeVisitable<'tcx> for InferConst<'tcx> {
|
||||
impl<'tcx> ir::TypeVisitable<TyCtxt<'tcx>> for InferConst<'tcx> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, _visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeSuperVisitable<'tcx> for ty::UnevaluatedConst<'tcx> {
|
||||
impl<'tcx> TypeSuperVisitable<TyCtxt<'tcx>> for ty::UnevaluatedConst<'tcx> {
|
||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
self.substs.visit_with(visitor)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ir::TypeVisitable<'tcx> for TyAndLayout<'tcx, Ty<'tcx>> {
|
||||
impl<'tcx> ir::TypeVisitable<TyCtxt<'tcx>> for TyAndLayout<'tcx, Ty<'tcx>> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
visitor.visit_ty(self.ty)
|
||||
}
|
||||
|
@ -2040,7 +2040,7 @@ impl<'tcx> Ty<'tcx> {
|
||||
pub fn contains(self, other: Ty<'tcx>) -> bool {
|
||||
struct ContainsTyVisitor<'tcx>(Ty<'tcx>);
|
||||
|
||||
impl<'tcx> TypeVisitor<'tcx> for ContainsTyVisitor<'tcx> {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ContainsTyVisitor<'tcx> {
|
||||
type BreakTy = ();
|
||||
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
@ -2058,7 +2058,7 @@ impl<'tcx> Ty<'tcx> {
|
||||
pub fn contains_closure(self) -> bool {
|
||||
struct ContainsClosureVisitor;
|
||||
|
||||
impl<'tcx> TypeVisitor<'tcx> for ContainsClosureVisitor {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ContainsClosureVisitor {
|
||||
type BreakTy = ();
|
||||
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
|
@ -237,7 +237,7 @@ impl<'tcx> ir::TypeFoldable<'tcx> for GenericArg<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ir::TypeVisitable<'tcx> for GenericArg<'tcx> {
|
||||
impl<'tcx> ir::TypeVisitable<TyCtxt<'tcx>> for GenericArg<'tcx> {
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
match self.unpack() {
|
||||
GenericArgKind::Lifetime(lt) => lt.visit_with(visitor),
|
||||
@ -535,7 +535,7 @@ impl<'tcx> ir::TypeFoldable<'tcx> for &'tcx ty::List<Ty<'tcx>> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable<'tcx> for &'tcx ty::List<T> {
|
||||
impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable<TyCtxt<'tcx>> for &'tcx ty::List<T> {
|
||||
#[inline]
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy> {
|
||||
self.iter().try_for_each(|t| t.visit_with(visitor))
|
||||
@ -554,7 +554,7 @@ pub struct EarlyBinder<T>(pub T);
|
||||
|
||||
/// For early binders, you should first call `subst` before using any visitors.
|
||||
impl<'tcx, T> !ir::TypeFoldable<'tcx> for ty::EarlyBinder<T> {}
|
||||
impl<'tcx, T> !ir::TypeVisitable<'tcx> for ty::EarlyBinder<T> {}
|
||||
impl<'tcx, T> !ir::TypeVisitable<TyCtxt<'tcx>> for ty::EarlyBinder<T> {}
|
||||
|
||||
impl<T> EarlyBinder<T> {
|
||||
pub fn as_ref(&self) -> EarlyBinder<&T> {
|
||||
|
@ -45,12 +45,12 @@ use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::sso::SsoHashSet;
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
pub trait TypeVisitable<'tcx> = ir::TypeVisitable<'tcx> + TypeVisitableExt<'tcx>;
|
||||
pub trait TypeSuperVisitable<'tcx> = ir::TypeSuperVisitable<'tcx>;
|
||||
pub trait TypeVisitor<'tcx> = ir::TypeVisitor<'tcx>;
|
||||
pub trait TypeVisitable<'tcx> = ir::TypeVisitable<TyCtxt<'tcx>> + TypeVisitableExt<'tcx>;
|
||||
pub trait TypeSuperVisitable<'tcx> = ir::TypeSuperVisitable<TyCtxt<'tcx>>;
|
||||
pub trait TypeVisitor<'tcx> = ir::TypeVisitor<TyCtxt<'tcx>>;
|
||||
|
||||
pub mod ir {
|
||||
use crate::ty::{self, Binder, Ty};
|
||||
use crate::ty::Interner;
|
||||
|
||||
use std::fmt;
|
||||
use std::ops::ControlFlow;
|
||||
@ -60,7 +60,7 @@ pub mod ir {
|
||||
///
|
||||
/// To implement this conveniently, use the derive macro located in
|
||||
/// `rustc_macros`.
|
||||
pub trait TypeVisitable<'tcx>: fmt::Debug + Clone {
|
||||
pub trait TypeVisitable<I: Interner>: fmt::Debug + Clone {
|
||||
/// The entry point for visiting. To visit a value `t` with a visitor `v`
|
||||
/// call: `t.visit_with(v)`.
|
||||
///
|
||||
@ -71,54 +71,66 @@ pub mod ir {
|
||||
/// that calls a visitor method specifically for that type (such as
|
||||
/// `V::visit_ty`). This is where control transfers from `TypeFoldable` to
|
||||
/// `TypeVisitor`.
|
||||
fn visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy>;
|
||||
fn visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy>;
|
||||
}
|
||||
|
||||
pub trait TypeSuperVisitable<'tcx>: TypeVisitable<'tcx> {
|
||||
pub trait TypeSuperVisitable<I: Interner>: TypeVisitable<I> {
|
||||
/// Provides a default visit for a type of interest. This should only be
|
||||
/// called within `TypeVisitor` methods, when a non-custom traversal is
|
||||
/// desired for the value of the type of interest passed to that method.
|
||||
/// For example, in `MyVisitor::visit_ty(ty)`, it is valid to call
|
||||
/// `ty.super_visit_with(self)`, but any other visiting should be done
|
||||
/// with `xyz.visit_with(self)`.
|
||||
fn super_visit_with<V: TypeVisitor<'tcx>>(
|
||||
&self,
|
||||
visitor: &mut V,
|
||||
) -> ControlFlow<V::BreakTy>;
|
||||
fn super_visit_with<V: TypeVisitor<I>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy>;
|
||||
}
|
||||
|
||||
/// This trait is implemented for every visiting traversal. There is a visit
|
||||
/// method defined for every type of interest. Each such method has a default
|
||||
/// that recurses into the type's fields in a non-custom fashion.
|
||||
pub trait TypeVisitor<'tcx>: Sized {
|
||||
pub trait TypeVisitor<I: Interner>: Sized {
|
||||
type BreakTy = !;
|
||||
|
||||
fn visit_binder<T: TypeVisitable<'tcx>>(
|
||||
fn visit_binder<T: TypeVisitable<I>>(
|
||||
&mut self,
|
||||
t: &Binder<'tcx, T>,
|
||||
) -> ControlFlow<Self::BreakTy> {
|
||||
t: &I::Binder<T>,
|
||||
) -> ControlFlow<Self::BreakTy>
|
||||
where
|
||||
I::Binder<T>: TypeSuperVisitable<I>,
|
||||
{
|
||||
t.super_visit_with(self)
|
||||
}
|
||||
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
fn visit_ty(&mut self, t: I::Ty) -> ControlFlow<Self::BreakTy>
|
||||
where
|
||||
I::Ty: TypeSuperVisitable<I>,
|
||||
{
|
||||
t.super_visit_with(self)
|
||||
}
|
||||
|
||||
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
fn visit_region(&mut self, r: I::Region) -> ControlFlow<Self::BreakTy>
|
||||
where
|
||||
I::Region: TypeSuperVisitable<I>,
|
||||
{
|
||||
r.super_visit_with(self)
|
||||
}
|
||||
|
||||
fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
fn visit_const(&mut self, c: I::Const) -> ControlFlow<Self::BreakTy>
|
||||
where
|
||||
I::Const: TypeSuperVisitable<I>,
|
||||
{
|
||||
c.super_visit_with(self)
|
||||
}
|
||||
|
||||
fn visit_predicate(&mut self, p: ty::Predicate<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
fn visit_predicate(&mut self, p: I::Predicate) -> ControlFlow<Self::BreakTy>
|
||||
where
|
||||
I::Predicate: TypeSuperVisitable<I>,
|
||||
{
|
||||
p.super_visit_with(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait TypeVisitableExt<'tcx>: ir::TypeVisitable<'tcx> {
|
||||
pub trait TypeVisitableExt<'tcx>: ir::TypeVisitable<TyCtxt<'tcx>> {
|
||||
/// Returns `true` if `self` has any late-bound regions that are either
|
||||
/// bound by `binder` or bound by some binder outside of `binder`.
|
||||
/// If `binder` is `ty::INNERMOST`, this indicates whether
|
||||
@ -240,7 +252,7 @@ pub trait TypeVisitableExt<'tcx>: ir::TypeVisitable<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T: ir::TypeVisitable<'tcx>> TypeVisitableExt<'tcx> for T {}
|
||||
impl<'tcx, T: ir::TypeVisitable<TyCtxt<'tcx>>> TypeVisitableExt<'tcx> for T {}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Region folder
|
||||
@ -295,7 +307,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
callback: F,
|
||||
}
|
||||
|
||||
impl<'tcx, F> ir::TypeVisitor<'tcx> for RegionVisitor<F>
|
||||
impl<'tcx, F> ir::TypeVisitor<TyCtxt<'tcx>> for RegionVisitor<F>
|
||||
where
|
||||
F: FnMut(ty::Region<'tcx>) -> bool,
|
||||
{
|
||||
@ -397,7 +409,7 @@ impl<'tcx> ValidateBoundVars<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ir::TypeVisitor<'tcx> for ValidateBoundVars<'tcx> {
|
||||
impl<'tcx> ir::TypeVisitor<TyCtxt<'tcx>> for ValidateBoundVars<'tcx> {
|
||||
type BreakTy = ();
|
||||
|
||||
fn visit_binder<T: TypeVisitable<'tcx>>(
|
||||
@ -509,7 +521,7 @@ struct HasEscapingVarsVisitor {
|
||||
outer_index: ty::DebruijnIndex,
|
||||
}
|
||||
|
||||
impl<'tcx> ir::TypeVisitor<'tcx> for HasEscapingVarsVisitor {
|
||||
impl<'tcx> ir::TypeVisitor<TyCtxt<'tcx>> for HasEscapingVarsVisitor {
|
||||
type BreakTy = FoundEscapingVars;
|
||||
|
||||
fn visit_binder<T: TypeVisitable<'tcx>>(
|
||||
@ -586,7 +598,7 @@ impl std::fmt::Debug for HasTypeFlagsVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ir::TypeVisitor<'tcx> for HasTypeFlagsVisitor {
|
||||
impl<'tcx> ir::TypeVisitor<TyCtxt<'tcx>> for HasTypeFlagsVisitor {
|
||||
type BreakTy = FoundFlags;
|
||||
|
||||
#[inline]
|
||||
@ -656,7 +668,7 @@ impl LateBoundRegionsCollector {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ir::TypeVisitor<'tcx> for LateBoundRegionsCollector {
|
||||
impl<'tcx> ir::TypeVisitor<TyCtxt<'tcx>> for LateBoundRegionsCollector {
|
||||
fn visit_binder<T: TypeVisitable<'tcx>>(
|
||||
&mut self,
|
||||
t: &Binder<'tcx, T>,
|
||||
@ -718,7 +730,7 @@ impl MaxUniverse {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> ir::TypeVisitor<'tcx> for MaxUniverse {
|
||||
impl<'tcx> ir::TypeVisitor<TyCtxt<'tcx>> for MaxUniverse {
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if let ty::Placeholder(placeholder) = t.kind() {
|
||||
self.max_universe = ty::UniverseIndex::from_u32(
|
||||
|
@ -296,7 +296,7 @@ impl<'a, 'tcx> Visitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TypeVisitor<'tcx> for MarkUsedGenericParams<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for MarkUsedGenericParams<'a, 'tcx> {
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
fn visit_const(&mut self, c: Const<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if !c.has_non_region_param() {
|
||||
|
@ -174,7 +174,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, V> TypeVisitor<'tcx> for DefIdVisitorSkeleton<'_, 'tcx, V>
|
||||
impl<'tcx, V> TypeVisitor<TyCtxt<'tcx>> for DefIdVisitorSkeleton<'_, 'tcx, V>
|
||||
where
|
||||
V: DefIdVisitor<'tcx> + ?Sized,
|
||||
{
|
||||
|
@ -98,7 +98,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
||||
struct ContainsTerm<'tcx> {
|
||||
term: ty::Term<'tcx>,
|
||||
}
|
||||
impl<'tcx> TypeVisitor<'tcx> for ContainsTerm<'tcx> {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ContainsTerm<'tcx> {
|
||||
type BreakTy = ();
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if t.needs_infer() {
|
||||
|
@ -627,7 +627,7 @@ enum OrphanCheckEarlyExit<'tcx> {
|
||||
LocalTy(Ty<'tcx>),
|
||||
}
|
||||
|
||||
impl<'tcx> TypeVisitor<'tcx> for OrphanChecker<'tcx> {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for OrphanChecker<'tcx> {
|
||||
type BreakTy = OrphanCheckEarlyExit<'tcx>;
|
||||
fn visit_region(&mut self, _r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
ControlFlow::Continue(())
|
||||
|
@ -171,7 +171,7 @@ fn satisfied_from_param_env<'tcx>(
|
||||
single_match: Option<Result<ty::Const<'tcx>, ()>>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> TypeVisitor<'tcx> for Visitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for Visitor<'a, 'tcx> {
|
||||
type BreakTy = ();
|
||||
fn visit_const(&mut self, c: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
debug!("is_const_evaluatable: candidate={:?}", c);
|
||||
|
@ -2963,7 +2963,7 @@ impl ArgKind {
|
||||
|
||||
struct HasNumericInferVisitor;
|
||||
|
||||
impl<'tcx> ty::ir::TypeVisitor<'tcx> for HasNumericInferVisitor {
|
||||
impl<'tcx> ty::ir::TypeVisitor<TyCtxt<'tcx>> for HasNumericInferVisitor {
|
||||
type BreakTy = ();
|
||||
|
||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
|
@ -481,7 +481,7 @@ fn is_impossible_method(tcx: TyCtxt<'_>, (impl_def_id, trait_item_def_id): (DefI
|
||||
generics: &'tcx ty::Generics,
|
||||
trait_item_def_id: DefId,
|
||||
}
|
||||
impl<'tcx> ty::ir::TypeVisitor<'tcx> for ReferencesOnlyParentGenerics<'tcx> {
|
||||
impl<'tcx> ty::ir::TypeVisitor<TyCtxt<'tcx>> for ReferencesOnlyParentGenerics<'tcx> {
|
||||
type BreakTy = ();
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
// If this is a parameter from the trait item's own generics, then bail
|
||||
|
@ -836,7 +836,7 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeVisitable<'tcx>>(
|
||||
supertraits: Option<Vec<DefId>>,
|
||||
}
|
||||
|
||||
impl<'tcx> TypeVisitor<'tcx> for IllegalSelfTypeVisitor<'tcx> {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for IllegalSelfTypeVisitor<'tcx> {
|
||||
type BreakTy = ();
|
||||
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
|
@ -115,7 +115,7 @@ struct MaxEscapingBoundVarVisitor {
|
||||
escaping: usize,
|
||||
}
|
||||
|
||||
impl<'tcx> TypeVisitor<'tcx> for MaxEscapingBoundVarVisitor {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for MaxEscapingBoundVarVisitor {
|
||||
fn visit_binder<T: TypeVisitable<'tcx>>(
|
||||
&mut self,
|
||||
t: &ty::Binder<'tcx, T>,
|
||||
|
@ -80,7 +80,7 @@ impl<'tcx> Search<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeVisitor<'tcx> for Search<'tcx> {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for Search<'tcx> {
|
||||
type BreakTy = Ty<'tcx>;
|
||||
|
||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
|
@ -926,7 +926,7 @@ impl<'tcx> BoundVarsCollector<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for BoundVarsCollector<'tcx> {
|
||||
fn visit_binder<T: TypeVisitable<'tcx>>(
|
||||
&mut self,
|
||||
t: &Binder<'tcx, T>,
|
||||
@ -1175,7 +1175,7 @@ impl PlaceholdersCollector {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> TypeVisitor<'tcx> for PlaceholdersCollector {
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for PlaceholdersCollector {
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
match t.kind() {
|
||||
ty::Placeholder(p) if p.universe == self.universe_index => {
|
||||
|
@ -4,7 +4,7 @@ use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_index::bit_set::{BitSet, HybridBitSet};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::mir::{self, visit::Visitor as _, Mutability};
|
||||
use rustc_middle::ty::{self, visit::ir::TypeVisitor};
|
||||
use rustc_middle::ty::{self, visit::ir::TypeVisitor, TyCtxt};
|
||||
use rustc_mir_dataflow::{impls::MaybeStorageLive, Analysis, ResultsCursor};
|
||||
use std::borrow::Cow;
|
||||
use std::ops::ControlFlow;
|
||||
@ -136,7 +136,7 @@ impl<'a, 'b, 'tcx> mir::visit::Visitor<'tcx> for PossibleBorrowerVisitor<'a, 'b,
|
||||
|
||||
struct ContainsRegion;
|
||||
|
||||
impl TypeVisitor<'_> for ContainsRegion {
|
||||
impl TypeVisitor<TyCtxt<'_>> for ContainsRegion {
|
||||
type BreakTy = ();
|
||||
|
||||
fn visit_region(&mut self, _: ty::Region<'_>) -> ControlFlow<Self::BreakTy> {
|
||||
|
@ -838,7 +838,7 @@ pub fn for_each_top_level_late_bound_region<B>(
|
||||
index: u32,
|
||||
f: F,
|
||||
}
|
||||
impl<'tcx, B, F: FnMut(BoundRegion) -> ControlFlow<B>> TypeVisitor<'tcx> for V<F> {
|
||||
impl<'tcx, B, F: FnMut(BoundRegion) -> ControlFlow<B>> TypeVisitor<TyCtxt<'tcx>> for V<F> {
|
||||
type BreakTy = B;
|
||||
fn visit_region(&mut self, r: Region<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
if let RegionKind::ReLateBound(idx, bound) = r.kind() && idx.as_u32() == self.index {
|
||||
|
Loading…
Reference in New Issue
Block a user