diff --git a/compiler/rustc_borrowck/src/constraint_generation.rs b/compiler/rustc_borrowck/src/constraint_generation.rs index 11b31c3f14028..1427f5cb31d9c 100644 --- a/compiler/rustc_borrowck/src/constraint_generation.rs +++ b/compiler/rustc_borrowck/src/constraint_generation.rs @@ -9,7 +9,7 @@ use rustc_middle::mir::{ }; use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::visit::TypeVisitable; -use rustc_middle::ty::{self, RegionVid, Ty}; +use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt}; use crate::{ borrow_set::BorrowSet, facts::AllFacts, location::LocationTable, nll::ToRegionVid, @@ -165,7 +165,7 @@ impl<'cx, 'tcx> ConstraintGeneration<'cx, 'tcx> { /// `location`. fn add_regular_live_constraint(&mut self, live_ty: T, location: Location) where - T: TypeVisitable<'tcx>, + T: TypeVisitable>, { debug!("add_regular_live_constraint(live_ty={:?}, location={:?})", live_ty, location); diff --git a/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs b/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs index d51cc652bfd46..68205fa45587b 100644 --- a/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs +++ b/compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs @@ -106,7 +106,7 @@ impl<'tcx> ToUniverseInfo<'tcx> } } -impl<'tcx, T: Copy + fmt::Display + TypeFoldable<'tcx> + 'tcx> ToUniverseInfo<'tcx> +impl<'tcx, T: Copy + fmt::Display + TypeFoldable> + 'tcx> ToUniverseInfo<'tcx> for Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::Normalize>> { fn to_universe_info(self, base_universe: ty::UniverseIndex) -> UniverseInfo<'tcx> { @@ -258,7 +258,7 @@ struct NormalizeQuery<'tcx, T> { impl<'tcx, T> TypeOpInfo<'tcx> for NormalizeQuery<'tcx, T> where - T: Copy + fmt::Display + TypeFoldable<'tcx> + 'tcx, + T: Copy + fmt::Display + TypeFoldable> + 'tcx, { fn fallback_error( &self, diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index 8c374c2164c7b..941da2dd3b5fc 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -17,7 +17,7 @@ use rustc_middle::mir::{ }; use rustc_middle::traits::ObligationCause; use rustc_middle::traits::ObligationCauseCode; -use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable}; +use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable, TypeVisitableExt}; use rustc_span::Span; use crate::{ @@ -1366,7 +1366,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// we use this kind of hacky solution. fn normalize_to_scc_representatives(&self, tcx: TyCtxt<'tcx>, value: T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { tcx.fold_regions(value, |r, _db| { let vid = self.to_region_vid(r); diff --git a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs index 4ccdeeff72b03..ae1d89de80efe 100644 --- a/compiler/rustc_borrowck/src/region_infer/opaque_types.rs +++ b/compiler/rustc_borrowck/src/region_infer/opaque_types.rs @@ -6,7 +6,7 @@ use rustc_infer::infer::TyCtxtInferExt as _; use rustc_infer::infer::{DefiningAnchor, InferCtxt}; use rustc_infer::traits::{Obligation, ObligationCause}; use rustc_middle::ty::subst::{GenericArgKind, InternalSubsts}; -use rustc_middle::ty::visit::TypeVisitable; +use rustc_middle::ty::visit::TypeVisitableExt; use rustc_middle::ty::{self, OpaqueHiddenType, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable}; use rustc_span::Span; use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt as _; @@ -178,7 +178,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// region names in error messages. pub(crate) fn name_regions(&self, tcx: TyCtxt<'tcx>, ty: T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { tcx.fold_regions(ty, |region, _| match *region { ty::ReVar(vid) => { diff --git a/compiler/rustc_borrowck/src/renumber.rs b/compiler/rustc_borrowck/src/renumber.rs index 960dedc74efbb..016f6f78dfa1d 100644 --- a/compiler/rustc_borrowck/src/renumber.rs +++ b/compiler/rustc_borrowck/src/renumber.rs @@ -38,7 +38,7 @@ pub(crate) fn renumber_regions<'tcx, T, F>( get_ctxt_fn: F, ) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, F: Fn() -> RegionCtxt, { infcx.tcx.fold_regions(value, |_region, _depth| { @@ -89,7 +89,7 @@ struct NllVisitor<'a, 'tcx> { impl<'a, 'tcx> NllVisitor<'a, 'tcx> { fn renumber_regions(&mut self, value: T, region_ctxt_fn: F) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, F: Fn() -> RegionCtxt, { renumber_regions(self.infcx, value, region_ctxt_fn) diff --git a/compiler/rustc_borrowck/src/type_check/canonical.rs b/compiler/rustc_borrowck/src/type_check/canonical.rs index 2b81a35052d7b..1be20f1870706 100644 --- a/compiler/rustc_borrowck/src/type_check/canonical.rs +++ b/compiler/rustc_borrowck/src/type_check/canonical.rs @@ -2,7 +2,7 @@ use std::fmt; use rustc_infer::infer::{canonical::Canonical, InferOk}; use rustc_middle::mir::ConstraintCategory; -use rustc_middle::ty::{self, ToPredicate, Ty, TypeFoldable}; +use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable}; use rustc_span::def_id::DefId; use rustc_span::Span; use rustc_trait_selection::traits::query::type_op::{self, TypeOpOutput}; @@ -66,7 +66,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { canonical: &Canonical<'tcx, T>, ) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { let old_universe = self.infcx.universe(); diff --git a/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs b/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs index 1dc6c42fbf78e..504633c6a5c39 100644 --- a/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs +++ b/compiler/rustc_borrowck/src/type_check/constraint_conversion.rs @@ -6,8 +6,8 @@ use rustc_infer::infer::region_constraints::{GenericKind, VerifyBound}; use rustc_infer::infer::{self, InferCtxt, SubregionOrigin}; use rustc_middle::mir::{ClosureOutlivesSubject, ClosureRegionRequirements, ConstraintCategory}; use rustc_middle::ty::subst::GenericArgKind; -use rustc_middle::ty::TypeFoldable; use rustc_middle::ty::{self, TyCtxt}; +use rustc_middle::ty::{TypeFoldable, TypeVisitableExt}; use rustc_span::{Span, DUMMY_SP}; use crate::{ @@ -171,7 +171,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> { /// /// FIXME: This should get removed once higher ranked region obligations /// are dealt with during trait solving. - fn replace_placeholders_with_nll>(&mut self, value: T) -> T { + fn replace_placeholders_with_nll>>(&mut self, value: T) -> T { if value.has_placeholders() { self.tcx.fold_regions(value, |r, _| match *r { ty::RePlaceholder(placeholder) => { diff --git a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs index 3ff5d188a3d35..473c059630073 100644 --- a/compiler/rustc_borrowck/src/type_check/liveness/trace.rs +++ b/compiler/rustc_borrowck/src/type_check/liveness/trace.rs @@ -3,7 +3,7 @@ use rustc_index::bit_set::HybridBitSet; use rustc_index::interval::IntervalSet; use rustc_infer::infer::canonical::QueryRegionConstraints; use rustc_middle::mir::{BasicBlock, Body, ConstraintCategory, Local, Location}; -use rustc_middle::ty::{Ty, TypeVisitable}; +use rustc_middle::ty::{Ty, TyCtxt, TypeVisitable, TypeVisitableExt}; use rustc_trait_selection::traits::query::dropck_outlives::DropckOutlivesResult; use rustc_trait_selection::traits::query::type_op::outlives::DropckOutlives; use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput}; @@ -477,7 +477,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> { /// points `live_at`. fn add_use_live_facts_for( &mut self, - value: impl TypeVisitable<'tcx>, + value: impl TypeVisitable>, live_at: &IntervalSet, ) { debug!("add_use_live_facts_for(value={:?})", value); @@ -542,7 +542,7 @@ impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> { fn make_all_regions_live( elements: &RegionValueElements, typeck: &mut TypeChecker<'_, 'tcx>, - value: impl TypeVisitable<'tcx>, + value: impl TypeVisitable>, live_at: &IntervalSet, ) { debug!("make_all_regions_live(value={:?})", value); diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index f14f8f1906be7..eb0fa1b6859ac 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -30,7 +30,7 @@ use rustc_middle::mir::*; use rustc_middle::ty::adjustment::PointerCast; use rustc_middle::ty::cast::CastTy; use rustc_middle::ty::subst::{SubstsRef, UserSubsts}; -use rustc_middle::ty::visit::TypeVisitable; +use rustc_middle::ty::visit::TypeVisitableExt; use rustc_middle::ty::{ self, Binder, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations, Dynamic, OpaqueHiddenType, OpaqueTypeKey, RegionVid, Ty, TyCtxt, UserType, UserTypeAnnotationIndex, diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index f3ca896cd0de1..3e8731755fc60 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -728,7 +728,7 @@ trait InferCtxtExt<'tcx> { value: T, ) -> T where - T: TypeFoldable<'tcx>; + T: TypeFoldable>; fn replace_bound_regions_with_nll_infer_vars( &self, @@ -738,7 +738,7 @@ trait InferCtxtExt<'tcx> { indices: &mut UniversalRegionIndices<'tcx>, ) -> T where - T: TypeFoldable<'tcx>; + T: TypeFoldable>; fn replace_late_bound_regions_with_nll_infer_vars_in_recursive_scope( &self, @@ -761,7 +761,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> { value: T, ) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { self.infcx.tcx.fold_regions(value, |region, _depth| { let name = match region.get_name() { @@ -785,7 +785,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for BorrowckInferCtxt<'cx, 'tcx> { indices: &mut UniversalRegionIndices<'tcx>, ) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { let (value, _map) = self.tcx.replace_late_bound_regions(value, |br| { debug!(?br); @@ -906,7 +906,7 @@ impl<'tcx> UniversalRegionIndices<'tcx> { /// returned by `to_region_vid`. pub fn fold_to_region_vids(&self, tcx: TyCtxt<'tcx>, value: T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { tcx.fold_regions(value, |region, _| tcx.mk_re_var(self.to_region_vid(region))) } diff --git a/compiler/rustc_codegen_cranelift/src/common.rs b/compiler/rustc_codegen_cranelift/src/common.rs index a8be0d32cc8c7..722e2754e8381 100644 --- a/compiler/rustc_codegen_cranelift/src/common.rs +++ b/compiler/rustc_codegen_cranelift/src/common.rs @@ -374,7 +374,7 @@ impl<'tcx> HasTargetSpec for FunctionCx<'_, '_, 'tcx> { impl<'tcx> FunctionCx<'_, '_, 'tcx> { pub(crate) fn monomorphize(&self, value: T) -> T where - T: TypeFoldable<'tcx> + Copy, + T: TypeFoldable> + Copy, { self.instance.subst_mir_and_normalize_erasing_regions( self.tcx, diff --git a/compiler/rustc_codegen_cranelift/src/lib.rs b/compiler/rustc_codegen_cranelift/src/lib.rs index c7fe382bac4e3..58154191c56bb 100644 --- a/compiler/rustc_codegen_cranelift/src/lib.rs +++ b/compiler/rustc_codegen_cranelift/src/lib.rs @@ -86,7 +86,7 @@ mod prelude { pub(crate) use rustc_middle::ty::layout::{self, LayoutOf, TyAndLayout}; pub(crate) use rustc_middle::ty::{ self, FloatTy, Instance, InstanceDef, IntTy, ParamEnv, Ty, TyCtxt, TypeAndMut, - TypeFoldable, UintTy, + TypeFoldable, TypeVisitableExt, UintTy, }; pub(crate) use rustc_target::abi::{Abi, Scalar, Size, VariantIdx}; diff --git a/compiler/rustc_codegen_gcc/src/callee.rs b/compiler/rustc_codegen_gcc/src/callee.rs index c1041125ecce7..9e3a22ee05d7c 100644 --- a/compiler/rustc_codegen_gcc/src/callee.rs +++ b/compiler/rustc_codegen_gcc/src/callee.rs @@ -1,6 +1,6 @@ use gccjit::{FunctionType, RValue}; use rustc_codegen_ssa::traits::BaseTypeMethods; -use rustc_middle::ty::{self, Instance, TypeVisitable}; +use rustc_middle::ty::{self, Instance, TypeVisitableExt}; use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt}; use crate::abi::FnAbiGccExt; diff --git a/compiler/rustc_codegen_gcc/src/mono_item.rs b/compiler/rustc_codegen_gcc/src/mono_item.rs index 9468a1ef4bbbb..a7c868354fb27 100644 --- a/compiler/rustc_codegen_gcc/src/mono_item.rs +++ b/compiler/rustc_codegen_gcc/src/mono_item.rs @@ -1,7 +1,7 @@ use rustc_codegen_ssa::traits::PreDefineMethods; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::mir::mono::{Linkage, Visibility}; -use rustc_middle::ty::{self, Instance, TypeVisitable}; +use rustc_middle::ty::{self, Instance, TypeVisitableExt}; use rustc_middle::ty::layout::{FnAbiOf, LayoutOf}; use rustc_span::def_id::DefId; diff --git a/compiler/rustc_codegen_gcc/src/type_of.rs b/compiler/rustc_codegen_gcc/src/type_of.rs index 1326af670cde4..ea2ce765053ff 100644 --- a/compiler/rustc_codegen_gcc/src/type_of.rs +++ b/compiler/rustc_codegen_gcc/src/type_of.rs @@ -3,7 +3,7 @@ use std::fmt::Write; use gccjit::{Struct, Type}; use crate::rustc_codegen_ssa::traits::{BaseTypeMethods, DerivedTypeMethods, LayoutTypeMethods}; use rustc_middle::bug; -use rustc_middle::ty::{self, Ty, TypeVisitable}; +use rustc_middle::ty::{self, Ty, TypeVisitableExt}; use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout}; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_target::abi::{self, Abi, F32, F64, FieldsShape, Int, Integer, Pointer, PointeeInfo, Size, TyAbiInterface, Variants}; diff --git a/compiler/rustc_codegen_llvm/src/callee.rs b/compiler/rustc_codegen_llvm/src/callee.rs index f1d01a4602a5e..6ee2a05ffd7b5 100644 --- a/compiler/rustc_codegen_llvm/src/callee.rs +++ b/compiler/rustc_codegen_llvm/src/callee.rs @@ -13,7 +13,7 @@ use crate::value::Value; use rustc_codegen_ssa::traits::*; use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt}; -use rustc_middle::ty::{self, Instance, TypeVisitable}; +use rustc_middle::ty::{self, Instance, TypeVisitableExt}; /// Codegens a reference to a fn/method item, monomorphizing and /// inlining as it goes. diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs index cef403b9f8b87..5392534cfcb79 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs @@ -27,7 +27,7 @@ use rustc_index::vec::IndexVec; use rustc_middle::mir; use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::subst::{GenericArgKind, SubstsRef}; -use rustc_middle::ty::{self, Instance, ParamEnv, Ty, TypeVisitable}; +use rustc_middle::ty::{self, Instance, ParamEnv, Ty, TypeVisitableExt}; use rustc_session::config::{self, DebugInfo}; use rustc_session::Session; use rustc_span::symbol::Symbol; diff --git a/compiler/rustc_codegen_llvm/src/mono_item.rs b/compiler/rustc_codegen_llvm/src/mono_item.rs index 76f692b2016fd..d0ae36349df1a 100644 --- a/compiler/rustc_codegen_llvm/src/mono_item.rs +++ b/compiler/rustc_codegen_llvm/src/mono_item.rs @@ -9,7 +9,7 @@ use rustc_hir::def_id::{DefId, LOCAL_CRATE}; pub use rustc_middle::mir::mono::MonoItem; use rustc_middle::mir::mono::{Linkage, Visibility}; use rustc_middle::ty::layout::{FnAbiOf, LayoutOf}; -use rustc_middle::ty::{self, Instance, TypeVisitable}; +use rustc_middle::ty::{self, Instance, TypeVisitableExt}; use rustc_session::config::CrateType; use rustc_target::spec::RelocModel; diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index 9cda24bab87d3..e264ce78f0d67 100644 --- a/compiler/rustc_codegen_llvm/src/type_of.rs +++ b/compiler/rustc_codegen_llvm/src/type_of.rs @@ -5,7 +5,7 @@ use rustc_codegen_ssa::traits::*; use rustc_middle::bug; use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout}; use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths}; -use rustc_middle::ty::{self, Ty, TypeVisitable}; +use rustc_middle::ty::{self, Ty, TypeVisitableExt}; use rustc_target::abi::{Abi, Align, FieldsShape}; use rustc_target::abi::{Int, Pointer, F32, F64}; use rustc_target::abi::{PointeeInfo, Scalar, Size, TyAbiInterface, Variants}; diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index e105322a0b426..cdc3e1dc237b2 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -16,7 +16,7 @@ use rustc_index::vec::Idx; use rustc_middle::mir::{self, AssertKind, SwitchTargets}; use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf}; use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths}; -use rustc_middle::ty::{self, Instance, Ty, TypeVisitable}; +use rustc_middle::ty::{self, Instance, Ty, TypeVisitableExt}; use rustc_session::config::OptLevel; use rustc_span::source_map::Span; use rustc_span::{sym, Symbol}; diff --git a/compiler/rustc_codegen_ssa/src/mir/mod.rs b/compiler/rustc_codegen_ssa/src/mir/mod.rs index eec91ffa44a0b..2ec9fdbf44f11 100644 --- a/compiler/rustc_codegen_ssa/src/mir/mod.rs +++ b/compiler/rustc_codegen_ssa/src/mir/mod.rs @@ -3,7 +3,7 @@ use crate::traits::*; use rustc_middle::mir; use rustc_middle::mir::interpret::ErrorHandled; use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, TyAndLayout}; -use rustc_middle::ty::{self, Instance, Ty, TypeFoldable}; +use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable, TypeVisitableExt}; use rustc_target::abi::call::{FnAbi, PassMode}; use std::iter; @@ -105,7 +105,7 @@ pub struct FunctionCx<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> { impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { pub fn monomorphize(&self, value: T) -> T where - T: Copy + TypeFoldable<'tcx>, + T: Copy + TypeFoldable>, { debug!("monomorphize: self.instance={:?}", self.instance); self.instance.subst_mir_and_normalize_erasing_regions( diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 24b157054d3e4..3db102e484dfa 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -489,7 +489,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { /// Call this on things you got out of the MIR (so it is as generic as the current /// stack frame), to bring it into the proper environment for this interpreter. - pub(super) fn subst_from_current_frame_and_normalize_erasing_regions>( + pub(super) fn subst_from_current_frame_and_normalize_erasing_regions< + T: TypeFoldable>, + >( &self, value: T, ) -> Result> { @@ -498,7 +500,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { /// Call this on things you got out of the MIR (so it is as generic as the provided /// stack frame), to bring it into the proper environment for this interpreter. - pub(super) fn subst_from_frame_and_normalize_erasing_regions>( + pub(super) fn subst_from_frame_and_normalize_erasing_regions>>( &self, frame: &Frame<'mir, 'tcx, M::Provenance, M::FrameExtra>, value: T, diff --git a/compiler/rustc_const_eval/src/interpret/util.rs b/compiler/rustc_const_eval/src/interpret/util.rs index 581cb6421f734..bf2b4ee69abfb 100644 --- a/compiler/rustc_const_eval/src/interpret/util.rs +++ b/compiler/rustc_const_eval/src/interpret/util.rs @@ -1,5 +1,7 @@ use rustc_middle::mir::interpret::InterpResult; -use rustc_middle::ty::{self, ir::TypeVisitor, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable}; +use rustc_middle::ty::{ + self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, +}; use std::ops::ControlFlow; /// Checks whether a type contains generic parameters which require substitution. @@ -9,7 +11,7 @@ use std::ops::ControlFlow; /// case these parameters are unused. pub(crate) fn ensure_monomorphic_enough<'tcx, T>(tcx: TyCtxt<'tcx>, ty: T) -> InterpResult<'tcx> where - T: TypeVisitable<'tcx>, + T: TypeVisitable>, { debug!("ensure_monomorphic_enough: ty={:?}", ty); if !ty.needs_subst() { diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index faf741de60a16..e4366f655e471 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -10,7 +10,7 @@ use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceC use rustc_middle::mir::*; use rustc_middle::ty::subst::{GenericArgKind, InternalSubsts}; use rustc_middle::ty::{self, adjustment::PointerCast, Instance, InstanceDef, Ty, TyCtxt}; -use rustc_middle::ty::{Binder, TraitRef, TypeVisitable}; +use rustc_middle::ty::{Binder, TraitRef, TypeVisitableExt}; use rustc_mir_dataflow::{self, Analysis}; use rustc_span::{sym, Span, Symbol}; use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt as _; diff --git a/compiler/rustc_const_eval/src/transform/promote_consts.rs b/compiler/rustc_const_eval/src/transform/promote_consts.rs index 19367d708ee74..ba08f5d30d94b 100644 --- a/compiler/rustc_const_eval/src/transform/promote_consts.rs +++ b/compiler/rustc_const_eval/src/transform/promote_consts.rs @@ -18,7 +18,7 @@ use rustc_middle::mir::traversal::ReversePostorderIter; use rustc_middle::mir::visit::{MutVisitor, MutatingUseContext, PlaceContext, Visitor}; use rustc_middle::mir::*; use rustc_middle::ty::subst::InternalSubsts; -use rustc_middle::ty::{self, List, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, List, TyCtxt, TypeVisitableExt}; use rustc_span::Span; use rustc_index::vec::{Idx, IndexVec}; diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs index 67dbf29da3b0a..3af2d0c4e668a 100644 --- a/compiler/rustc_const_eval/src/transform/validate.rs +++ b/compiler/rustc_const_eval/src/transform/validate.rs @@ -13,7 +13,7 @@ use rustc_middle::mir::{ RetagKind, RuntimePhase, Rvalue, SourceScope, Statement, StatementKind, Terminator, TerminatorKind, UnOp, START_BLOCK, }; -use rustc_middle::ty::{self, InstanceDef, ParamEnv, Ty, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, InstanceDef, ParamEnv, Ty, TyCtxt, TypeVisitableExt}; use rustc_mir_dataflow::impls::MaybeStorageLive; use rustc_mir_dataflow::storage::always_storage_live_locals; use rustc_mir_dataflow::{Analysis, ResultsCursor}; diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index c0cd54cc916e0..3764b9f68f572 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -35,7 +35,7 @@ use rustc_middle::middle::stability::AllowUnstable; use rustc_middle::ty::subst::{self, GenericArgKind, InternalSubsts, SubstsRef}; use rustc_middle::ty::DynKind; use rustc_middle::ty::GenericParamDefKind; -use rustc_middle::ty::{self, Const, DefIdTree, IsSuggestable, Ty, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, Const, DefIdTree, IsSuggestable, Ty, TyCtxt, TypeVisitableExt}; use rustc_session::lint::builtin::{AMBIGUOUS_ASSOCIATED_ITEMS, BARE_TRAIT_OBJECTS}; use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::edition::Edition; diff --git a/compiler/rustc_hir_analysis/src/autoderef.rs b/compiler/rustc_hir_analysis/src/autoderef.rs index a5c96a8b01613..ba2d4319af6e2 100644 --- a/compiler/rustc_hir_analysis/src/autoderef.rs +++ b/compiler/rustc_hir_analysis/src/autoderef.rs @@ -3,7 +3,7 @@ use crate::traits::query::evaluate_obligation::InferCtxtExt; use crate::traits::NormalizeExt; use crate::traits::{self, TraitEngine, TraitEngineExt}; use rustc_infer::infer::InferCtxt; -use rustc_middle::ty::TypeVisitable; +use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_session::Limit; use rustc_span::def_id::LocalDefId; diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 04396c883d3ab..3ca886f11d1f8 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -23,6 +23,7 @@ use rustc_middle::ty::subst::GenericArgKind; use rustc_middle::ty::util::{Discr, IntTypeExt}; use rustc_middle::ty::{ self, AdtDef, DefIdTree, ParamEnv, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, + TypeVisitableExt, }; use rustc_session::lint::builtin::{UNINHABITED_STATIC, UNSUPPORTED_CALLING_CONVENTIONS}; use rustc_span::symbol::sym; @@ -255,7 +256,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes( selftys: Vec<(Span, Option)>, } - impl<'tcx> ty::visit::ir::TypeVisitor> for ProhibitOpaqueVisitor<'tcx> { + impl<'tcx> ty::visit::TypeVisitor> for ProhibitOpaqueVisitor<'tcx> { type BreakTy = Ty<'tcx>; fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { @@ -1418,7 +1419,7 @@ fn opaque_type_cycle_error( opaques: Vec, closures: Vec, } - impl<'tcx> ty::visit::ir::TypeVisitor> for OpaqueTypeCollector { + impl<'tcx> ty::visit::TypeVisitor> for OpaqueTypeCollector { fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { match *t.kind() { ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, .. }) => { diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index a9fcc8e62501b..50005582f7cec 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -16,7 +16,8 @@ use rustc_infer::traits::util; use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::util::ExplicitSelf; use rustc_middle::ty::{ - self, ir::TypeFolder, DefIdTree, InternalSubsts, Ty, TypeFoldable, TypeSuperFoldable, + self, DefIdTree, InternalSubsts, Ty, TypeFoldable, TypeFolder, TypeSuperFoldable, + TypeVisitableExt, }; use rustc_middle::ty::{GenericParamDefKind, ToPredicate, TyCtxt}; use rustc_span::Span; diff --git a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs index b3e76010da34a..b1d5a27be9397 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsicck.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsicck.rs @@ -1,7 +1,7 @@ use rustc_ast::InlineAsmTemplatePiece; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; -use rustc_middle::ty::{self, Article, FloatTy, IntTy, Ty, TyCtxt, TypeVisitable, UintTy}; +use rustc_middle::ty::{self, Article, FloatTy, IntTy, Ty, TyCtxt, TypeVisitableExt, UintTy}; use rustc_session::lint; use rustc_span::def_id::LocalDefId; use rustc_span::{Symbol, DUMMY_SP}; diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 83b33321a525e..25be62534a5da 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -16,8 +16,8 @@ use rustc_middle::mir::ConstraintCategory; use rustc_middle::ty::query::Providers; use rustc_middle::ty::trait_def::TraitSpecializationKind; use rustc_middle::ty::{ - self, ir::TypeVisitor, AdtKind, GenericParamDefKind, Ty, TyCtxt, TypeFoldable, - TypeSuperVisitable, + self, AdtKind, GenericParamDefKind, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, + TypeVisitable, TypeVisitableExt, TypeVisitor, }; use rustc_middle::ty::{GenericArgKind, InternalSubsts}; use rustc_session::parse::feature_err; @@ -56,7 +56,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { // `ObligationCtxt::normalize`, but provides a nice `ObligationCauseCode`. fn normalize(&self, span: Span, loc: Option, value: T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { self.ocx.normalize( &ObligationCause::new(span, self.body_def_id, ObligationCauseCode::WellFormed(loc)), @@ -510,7 +510,7 @@ fn augment_param_env<'tcx>( /// fn into_iter<'a>(&'a self) -> Self::Iter<'a>; /// } /// ``` -fn gather_gat_bounds<'tcx, T: TypeFoldable<'tcx>>( +fn gather_gat_bounds<'tcx, T: TypeFoldable>>( tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, item_def_id: hir::OwnerId, @@ -708,7 +708,7 @@ struct GATSubstCollector<'tcx> { } impl<'tcx> GATSubstCollector<'tcx> { - fn visit>( + fn visit>>( gat: DefId, t: T, ) -> (FxHashSet<(ty::Region<'tcx>, usize)>, FxHashSet<(Ty<'tcx>, usize)>) { @@ -1382,7 +1382,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id struct CountParams { params: FxHashSet, } - impl<'tcx> ty::visit::ir::TypeVisitor> for CountParams { + impl<'tcx> ty::visit::TypeVisitor> for CountParams { type BreakTy = (); fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { diff --git a/compiler/rustc_hir_analysis/src/coherence/builtin.rs b/compiler/rustc_hir_analysis/src/coherence/builtin.rs index 51c5f29705191..875c5f1fd0043 100644 --- a/compiler/rustc_hir_analysis/src/coherence/builtin.rs +++ b/compiler/rustc_hir_analysis/src/coherence/builtin.rs @@ -11,7 +11,7 @@ use rustc_infer::infer::outlives::env::OutlivesEnvironment; use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::infer::{self, RegionResolutionError}; use rustc_middle::ty::adjustment::CoerceUnsizedInfo; -use rustc_middle::ty::{self, suggest_constraining_type_params, Ty, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, suggest_constraining_type_params, Ty, TyCtxt, TypeVisitableExt}; use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt; use rustc_trait_selection::traits::misc::{ type_allowed_to_implement_copy, CopyImplementationError, InfringingFieldsReason, diff --git a/compiler/rustc_hir_analysis/src/coherence/mod.rs b/compiler/rustc_hir_analysis/src/coherence/mod.rs index bbde59c953a02..23490bc091c1c 100644 --- a/compiler/rustc_hir_analysis/src/coherence/mod.rs +++ b/compiler/rustc_hir_analysis/src/coherence/mod.rs @@ -8,7 +8,7 @@ use rustc_errors::{error_code, struct_span_err}; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_middle::ty::query::Providers; -use rustc_middle::ty::{self, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt}; use rustc_span::sym; use rustc_trait_selection::traits; diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index f0a0e7e3e9293..52c4a376fb2dc 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -8,7 +8,8 @@ use rustc_hir as hir; use rustc_middle::ty::subst::InternalSubsts; use rustc_middle::ty::util::IgnoreRegions; use rustc_middle::ty::{ - self, ir::TypeVisitor, AliasKind, ImplPolarity, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, + self, AliasKind, ImplPolarity, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, + TypeVisitor, }; use rustc_session::lint; use rustc_span::def_id::{DefId, LocalDefId}; diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index e977767e02409..6c00b8ff7bdee 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -17,7 +17,7 @@ use rustc_hir::{GenericArg, GenericParam, GenericParamKind, HirIdMap, LifetimeNa use rustc_middle::bug; use rustc_middle::hir::nested_filter; use rustc_middle::middle::resolve_bound_vars::*; -use rustc_middle::ty::{self, ir::TypeVisitor, DefIdTree, TyCtxt, TypeSuperVisitable}; +use rustc_middle::ty::{self, DefIdTree, TyCtxt, TypeSuperVisitable, TypeVisitor}; use rustc_session::lint; use rustc_span::def_id::DefId; use rustc_span::symbol::{sym, Ident}; diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index a3bc0082ef20c..c013f1bdb3165 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -9,7 +9,7 @@ use rustc_middle::ty::print::with_forced_trimmed_paths; use rustc_middle::ty::subst::InternalSubsts; use rustc_middle::ty::util::IntTypeExt; use rustc_middle::ty::{ - self, ir::TypeFolder, DefIdTree, IsSuggestable, Ty, TyCtxt, TypeSuperFoldable, TypeVisitable, + self, DefIdTree, IsSuggestable, Ty, TyCtxt, TypeFolder, TypeSuperFoldable, TypeVisitableExt, }; use rustc_span::symbol::Ident; use rustc_span::{Span, DUMMY_SP}; diff --git a/compiler/rustc_hir_analysis/src/constrained_generic_params.rs b/compiler/rustc_hir_analysis/src/constrained_generic_params.rs index 072676c400d4e..e18b0f082798b 100644 --- a/compiler/rustc_hir_analysis/src/constrained_generic_params.rs +++ b/compiler/rustc_hir_analysis/src/constrained_generic_params.rs @@ -1,5 +1,5 @@ use rustc_data_structures::fx::FxHashSet; -use rustc_middle::ty::visit::{ir::TypeVisitor, TypeSuperVisitable, TypeVisitable}; +use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor}; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::source_map::Span; use std::ops::ControlFlow; @@ -43,7 +43,7 @@ pub fn parameters_for_impl<'tcx>( /// of parameters whose values are needed in order to constrain `ty` - these /// differ, with the latter being a superset, in the presence of projections. pub fn parameters_for<'tcx>( - t: &impl TypeVisitable<'tcx>, + t: &impl TypeVisitable>, include_nonconstraining: bool, ) -> Vec { let mut collector = ParameterCollector { parameters: vec![], include_nonconstraining }; diff --git a/compiler/rustc_hir_analysis/src/hir_wf_check.rs b/compiler/rustc_hir_analysis/src/hir_wf_check.rs index 8fc4610ae8567..e330fcc785770 100644 --- a/compiler/rustc_hir_analysis/src/hir_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/hir_wf_check.rs @@ -5,7 +5,7 @@ use rustc_hir::{ForeignItem, ForeignItemKind}; use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::traits::{ObligationCause, WellFormedLoc}; use rustc_middle::ty::query::Providers; -use rustc_middle::ty::{self, ir::TypeFolder, Region, TyCtxt, TypeFoldable}; +use rustc_middle::ty::{self, Region, TyCtxt, TypeFoldable, TypeFolder}; use rustc_span::def_id::LocalDefId; use rustc_trait_selection::traits; diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check.rs b/compiler/rustc_hir_analysis/src/impl_wf_check.rs index 8ab9964d81000..82a96f8e67408 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check.rs @@ -16,7 +16,7 @@ use rustc_errors::struct_span_err; use rustc_hir::def::DefKind; use rustc_hir::def_id::LocalDefId; use rustc_middle::ty::query::Providers; -use rustc_middle::ty::{self, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt}; use rustc_span::{Span, Symbol}; mod min_specialization; diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs index 4741e4b095d22..daa5d15704d87 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs @@ -76,7 +76,7 @@ use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::traits::specialization_graph::Node; use rustc_middle::ty::subst::{GenericArg, InternalSubsts, SubstsRef}; use rustc_middle::ty::trait_def::TraitSpecializationKind; -use rustc_middle::ty::{self, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt}; use rustc_span::Span; use rustc_trait_selection::traits::error_reporting::TypeErrCtxtExt; use rustc_trait_selection::traits::outlives_bounds::InferCtxtExt as _; diff --git a/compiler/rustc_hir_analysis/src/structured_errors/missing_cast_for_variadic_arg.rs b/compiler/rustc_hir_analysis/src/structured_errors/missing_cast_for_variadic_arg.rs index 324df313ef1d8..089491bef5ea5 100644 --- a/compiler/rustc_hir_analysis/src/structured_errors/missing_cast_for_variadic_arg.rs +++ b/compiler/rustc_hir_analysis/src/structured_errors/missing_cast_for_variadic_arg.rs @@ -1,6 +1,6 @@ use crate::structured_errors::StructuredDiagnostic; use rustc_errors::{Applicability, DiagnosticBuilder, DiagnosticId, ErrorGuaranteed}; -use rustc_middle::ty::{Ty, TypeVisitable}; +use rustc_middle::ty::{Ty, TypeVisitableExt}; use rustc_session::Session; use rustc_span::Span; diff --git a/compiler/rustc_hir_analysis/src/structured_errors/sized_unsized_cast.rs b/compiler/rustc_hir_analysis/src/structured_errors/sized_unsized_cast.rs index bb608805488ef..3b9fb367813d8 100644 --- a/compiler/rustc_hir_analysis/src/structured_errors/sized_unsized_cast.rs +++ b/compiler/rustc_hir_analysis/src/structured_errors/sized_unsized_cast.rs @@ -1,6 +1,6 @@ use crate::structured_errors::StructuredDiagnostic; use rustc_errors::{DiagnosticBuilder, DiagnosticId, ErrorGuaranteed}; -use rustc_middle::ty::{Ty, TypeVisitable}; +use rustc_middle::ty::{Ty, TypeVisitableExt}; use rustc_session::Session; use rustc_span::Span; diff --git a/compiler/rustc_hir_analysis/src/variance/mod.rs b/compiler/rustc_hir_analysis/src/variance/mod.rs index fb63bf224741a..5d5c8ca604a04 100644 --- a/compiler/rustc_hir_analysis/src/variance/mod.rs +++ b/compiler/rustc_hir_analysis/src/variance/mod.rs @@ -7,10 +7,8 @@ use rustc_arena::DroplessArena; use rustc_hir::def::DefKind; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_middle::ty::query::Providers; -#[cfg(not(bootstrap))] -use rustc_middle::ty::TypeVisitable; use rustc_middle::ty::{self, CrateVariancesMap, SubstsRef, Ty, TyCtxt}; -use rustc_middle::ty::{DefIdTree, TypeSuperVisitable}; +use rustc_middle::ty::{DefIdTree, TypeSuperVisitable, TypeVisitable}; use std::ops::ControlFlow; /// Defines the `TermsContext` basically houses an arena where we can @@ -101,7 +99,7 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc } } - impl<'tcx> ty::ir::TypeVisitor> for OpaqueTypeLifetimeCollector<'tcx> { + impl<'tcx> ty::TypeVisitor> for OpaqueTypeLifetimeCollector<'tcx> { #[instrument(level = "trace", skip(self), ret)] fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow { if let ty::RegionKind::ReEarlyBound(ebr) = r.kind() { diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 06b2b2451f0fa..ebb08a0cc04a8 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -21,7 +21,7 @@ use rustc_middle::ty::adjustment::{ Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability, }; use rustc_middle::ty::SubstsRef; -use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::{sym, Ident}; use rustc_span::Span; diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index 8e21c084841d0..316c2a7eeeb4b 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -41,7 +41,7 @@ use rustc_middle::mir::Mutability; use rustc_middle::ty::adjustment::AllowTwoPhase; use rustc_middle::ty::cast::{CastKind, CastTy}; use rustc_middle::ty::error::TypeError; -use rustc_middle::ty::{self, Ty, TypeAndMut, TypeVisitable, VariantDef}; +use rustc_middle::ty::{self, Ty, TypeAndMut, TypeVisitableExt, VariantDef}; use rustc_session::lint; use rustc_session::Session; use rustc_span::def_id::{DefId, LOCAL_CRATE}; diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs index c289eae8d2745..0eff3a2f9c2e6 100644 --- a/compiler/rustc_hir_typeck/src/closure.rs +++ b/compiler/rustc_hir_typeck/src/closure.rs @@ -11,8 +11,8 @@ use rustc_infer::infer::LateBoundRegionConversionTime; 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, TyCtxt, TypeSuperVisitable}; +use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt}; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor}; use rustc_span::def_id::LocalDefId; use rustc_span::source_map::Span; use rustc_span::sym; diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index a15fc9b57fbe6..706eb3f8647f2 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -54,7 +54,7 @@ use rustc_middle::ty::adjustment::{ use rustc_middle::ty::error::TypeError; use rustc_middle::ty::relate::RelateResult; use rustc_middle::ty::subst::SubstsRef; -use rustc_middle::ty::visit::TypeVisitable; +use rustc_middle::ty::visit::TypeVisitableExt; use rustc_middle::ty::{self, Ty, TypeAndMut}; use rustc_session::parse::feature_err; use rustc_span::symbol::sym; diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs index 241547b70aa2f..34d62987c3b0a 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -16,7 +16,7 @@ use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::fold::{BottomUpFolder, TypeFolder}; use rustc_middle::ty::print::{with_forced_trimmed_paths, with_no_trimmed_paths}; use rustc_middle::ty::relate::TypeRelation; -use rustc_middle::ty::{self, Article, AssocItem, Ty, TypeAndMut, TypeVisitable}; +use rustc_middle::ty::{self, Article, AssocItem, Ty, TypeAndMut, TypeVisitableExt}; use rustc_span::symbol::{sym, Symbol}; use rustc_span::{BytePos, Span}; use rustc_trait_selection::infer::InferCtxtExt as _; diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 08cbfffdd171b..4a7bb1b04391e 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -42,7 +42,7 @@ use rustc_middle::middle::stability; use rustc_middle::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase}; use rustc_middle::ty::error::TypeError::FieldMisMatch; use rustc_middle::ty::subst::SubstsRef; -use rustc_middle::ty::{self, AdtKind, Ty, TypeVisitable}; +use rustc_middle::ty::{self, AdtKind, Ty, TypeVisitableExt}; use rustc_session::errors::ExprParenthesesNeeded; use rustc_session::parse::feature_err; use rustc_span::edit_distance::find_best_match_for_name; diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index b2f3a3abb4c50..67de75301ad52 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -23,9 +23,9 @@ use rustc_infer::infer::InferResult; use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability}; use rustc_middle::ty::error::TypeError; use rustc_middle::ty::fold::TypeFoldable; -use rustc_middle::ty::visit::TypeVisitable; +use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt}; use rustc_middle::ty::{ - self, AdtKind, CanonicalUserType, DefIdTree, GenericParamDefKind, Ty, UserType, + self, AdtKind, CanonicalUserType, DefIdTree, GenericParamDefKind, Ty, TyCtxt, UserType, }; use rustc_middle::ty::{GenericArgKind, SubstsRef, UserSelfTy, UserSubsts}; use rustc_session::lint; @@ -315,7 +315,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub(in super::super) fn normalize(&self, span: Span, value: T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { self.register_infer_ok_obligations( self.at(&self.misc(span), self.param_env).normalize(value), @@ -443,7 +443,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // sufficiently enforced with erased regions. =) fn can_contain_user_lifetime_bounds(t: T) -> bool where - T: TypeVisitable<'tcx>, + T: TypeVisitable>, { t.has_free_regions() || t.has_projections() || t.has_infer_types() } diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs index 39e0ea98f96e3..d64492e503db0 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/adjust_fulfillment_errors.rs @@ -4,7 +4,7 @@ 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, TyCtxt, TypeSuperVisitable, TypeVisitable, + self, DefIdTree, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor, }; use rustc_span::{self, Span}; use rustc_trait_selection::traits; @@ -243,7 +243,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { true } - fn find_ambiguous_parameter_in>( + fn find_ambiguous_parameter_in>>( &self, item_def_id: DefId, t: T, diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 6a33826ea281c..bddf78a5419df 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -25,7 +25,7 @@ use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKi use rustc_infer::infer::InferOk; use rustc_infer::infer::TypeTrace; use rustc_middle::ty::adjustment::AllowTwoPhase; -use rustc_middle::ty::visit::TypeVisitable; +use rustc_middle::ty::visit::TypeVisitableExt; use rustc_middle::ty::{self, DefIdTree, IsSuggestable, Ty}; use rustc_session::Session; use rustc_span::symbol::{kw, Ident}; diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs index 3814ddaf73f44..1dea3e6f900d4 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs @@ -18,7 +18,7 @@ use rustc_infer::infer::error_reporting::TypeErrCtxt; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind}; use rustc_middle::ty::subst::GenericArgKind; -use rustc_middle::ty::{self, Const, Ty, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, Const, Ty, TyCtxt, TypeVisitableExt}; use rustc_session::Session; use rustc_span::symbol::Ident; use rustc_span::{self, Span, DUMMY_SP}; diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index 3539202d1ca6f..4b09dce6bb7c8 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -16,7 +16,7 @@ use rustc_middle::lint::in_external_macro; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::{ self, suggest_constraining_type_params, Binder, DefIdTree, IsSuggestable, ToPredicate, Ty, - TypeVisitable, + TypeVisitableExt, }; use rustc_session::errors::ExprParenthesesNeeded; use rustc_span::source_map::Spanned; diff --git a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs index b3dd3031db2a9..adedb5b742884 100644 --- a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs +++ b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/cfg_build.rs @@ -12,7 +12,7 @@ use rustc_index::vec::IndexVec; use rustc_infer::infer::InferCtxt; use rustc_middle::{ hir::map::Map, - ty::{ParamEnv, TyCtxt, TypeVisitable, TypeckResults}, + ty::{ParamEnv, TyCtxt, TypeVisitableExt, TypeckResults}, }; use std::mem::swap; diff --git a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/record_consumed_borrow.rs b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/record_consumed_borrow.rs index ed3d890315704..fa3887362d99c 100644 --- a/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/record_consumed_borrow.rs +++ b/compiler/rustc_hir_typeck/src/generator_interior/drop_ranges/record_consumed_borrow.rs @@ -9,7 +9,7 @@ use rustc_hir as hir; use rustc_middle::ty::{ParamEnv, TyCtxt}; use rustc_middle::{ hir::place::{PlaceBase, Projection, ProjectionKind}, - ty::TypeVisitable, + ty::TypeVisitableExt, }; pub(super) fn find_consumed_and_borrowed<'a, 'tcx>( diff --git a/compiler/rustc_hir_typeck/src/generator_interior/mod.rs b/compiler/rustc_hir_typeck/src/generator_interior/mod.rs index 14e3ba83b1037..e5f9292290ffe 100644 --- a/compiler/rustc_hir_typeck/src/generator_interior/mod.rs +++ b/compiler/rustc_hir_typeck/src/generator_interior/mod.rs @@ -16,7 +16,7 @@ use rustc_hir::{Arm, Expr, ExprKind, Guard, HirId, Pat, PatKind}; use rustc_infer::infer::RegionVariableOrigin; use rustc_middle::middle::region::{self, Scope, ScopeData, YieldData}; use rustc_middle::ty::fold::FnMutDelegate; -use rustc_middle::ty::{self, BoundVariableKind, RvalueScopes, Ty, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, BoundVariableKind, RvalueScopes, Ty, TyCtxt, TypeVisitableExt}; use rustc_span::symbol::sym; use rustc_span::Span; use smallvec::{smallvec, SmallVec}; diff --git a/compiler/rustc_hir_typeck/src/inherited.rs b/compiler/rustc_hir_typeck/src/inherited.rs index 87e54025330e8..26020382d8148 100644 --- a/compiler/rustc_hir_typeck/src/inherited.rs +++ b/compiler/rustc_hir_typeck/src/inherited.rs @@ -6,7 +6,7 @@ use rustc_hir::def_id::LocalDefId; use rustc_hir::HirIdMap; use rustc_infer::infer; use rustc_infer::infer::{DefiningAnchor, InferCtxt, InferOk, TyCtxtInferExt}; -use rustc_middle::ty::visit::TypeVisitable; +use rustc_middle::ty::visit::TypeVisitableExt; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::def_id::LocalDefIdMap; use rustc_span::{self, Span}; diff --git a/compiler/rustc_hir_typeck/src/intrinsicck.rs b/compiler/rustc_hir_typeck/src/intrinsicck.rs index 2c76582f2ec8f..19d2befc43879 100644 --- a/compiler/rustc_hir_typeck/src/intrinsicck.rs +++ b/compiler/rustc_hir_typeck/src/intrinsicck.rs @@ -3,7 +3,7 @@ use rustc_errors::struct_span_err; use rustc_hir as hir; use rustc_index::vec::Idx; use rustc_middle::ty::layout::{LayoutError, SizeSkeleton}; -use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; use rustc_target::abi::{Pointer, VariantIdx}; use super::FnCtxt; diff --git a/compiler/rustc_hir_typeck/src/mem_categorization.rs b/compiler/rustc_hir_typeck/src/mem_categorization.rs index 4b08832eddc9d..e50f5c77552dc 100644 --- a/compiler/rustc_hir_typeck/src/mem_categorization.rs +++ b/compiler/rustc_hir_typeck/src/mem_categorization.rs @@ -51,7 +51,7 @@ use rustc_middle::hir::place::*; use rustc_middle::ty::adjustment; use rustc_middle::ty::fold::TypeFoldable; -use rustc_middle::ty::{self, Ty, TyCtxt}; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; use rustc_data_structures::fx::FxIndexMap; use rustc_hir as hir; @@ -126,7 +126,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { fn resolve_vars_if_possible(&self, value: T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { self.infcx.resolve_vars_if_possible(value) } diff --git a/compiler/rustc_hir_typeck/src/method/confirm.rs b/compiler/rustc_hir_typeck/src/method/confirm.rs index f7de55c989fa3..169f128e0a003 100644 --- a/compiler/rustc_hir_typeck/src/method/confirm.rs +++ b/compiler/rustc_hir_typeck/src/method/confirm.rs @@ -14,7 +14,7 @@ use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCast}; use rustc_middle::ty::adjustment::{AllowTwoPhase, AutoBorrow, AutoBorrowMutability}; use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::subst::{self, SubstsRef}; -use rustc_middle::ty::{self, GenericParamDefKind, Ty}; +use rustc_middle::ty::{self, GenericParamDefKind, Ty, TyCtxt}; use rustc_middle::ty::{InternalSubsts, UserSubsts, UserType}; use rustc_span::{Span, DUMMY_SP}; use rustc_trait_selection::traits; @@ -635,7 +635,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> { fn instantiate_binder_with_fresh_vars(&self, value: ty::Binder<'tcx, T>) -> T where - T: TypeFoldable<'tcx> + Copy, + T: TypeFoldable> + Copy, { self.fcx.instantiate_binder_with_fresh_vars(self.span, infer::FnCall, value) } diff --git a/compiler/rustc_hir_typeck/src/method/mod.rs b/compiler/rustc_hir_typeck/src/method/mod.rs index c9ae82e8efbdf..0456dd56c340e 100644 --- a/compiler/rustc_hir_typeck/src/method/mod.rs +++ b/compiler/rustc_hir_typeck/src/method/mod.rs @@ -20,7 +20,7 @@ use rustc_hir::def_id::DefId; use rustc_infer::infer::{self, InferOk}; use rustc_middle::traits::ObligationCause; use rustc_middle::ty::subst::{InternalSubsts, SubstsRef}; -use rustc_middle::ty::{self, GenericParamDefKind, Ty, TypeVisitable}; +use rustc_middle::ty::{self, GenericParamDefKind, Ty, TypeVisitableExt}; use rustc_span::symbol::Ident; use rustc_span::Span; use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt; diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index 8b0473b7454c0..fc876802a4b9c 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -19,7 +19,7 @@ use rustc_middle::ty::fast_reject::{simplify_type, TreatParams}; use rustc_middle::ty::AssocItem; use rustc_middle::ty::GenericParamDefKind; use rustc_middle::ty::ToPredicate; -use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, TypeFoldable}; +use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, TypeFoldable, TypeVisitableExt}; use rustc_middle::ty::{InternalSubsts, SubstsRef}; use rustc_session::lint; use rustc_span::def_id::DefId; @@ -1905,7 +1905,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> { /// so forth. fn erase_late_bound_regions(&self, value: ty::Binder<'tcx, T>) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { self.tcx.erase_late_bound_regions(value) } diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 4f3dbe03c052a..f3f15ee0ae406 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -27,7 +27,7 @@ use rustc_middle::traits::util::supertraits; use rustc_middle::ty::fast_reject::DeepRejectCtxt; use rustc_middle::ty::fast_reject::{simplify_type, TreatParams}; use rustc_middle::ty::print::{with_crate_prefix, with_forced_trimmed_paths}; -use rustc_middle::ty::{self, DefIdTree, GenericArgKind, Ty, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, DefIdTree, GenericArgKind, Ty, TyCtxt, TypeVisitableExt}; use rustc_middle::ty::{IsSuggestable, ToPolyTraitRef}; use rustc_span::symbol::{kw, sym, Ident}; use rustc_span::Symbol; diff --git a/compiler/rustc_hir_typeck/src/op.rs b/compiler/rustc_hir_typeck/src/op.rs index c8256e7ec08e6..bb9d93d5057be 100644 --- a/compiler/rustc_hir_typeck/src/op.rs +++ b/compiler/rustc_hir_typeck/src/op.rs @@ -13,7 +13,7 @@ use rustc_middle::ty::adjustment::{ }; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::{ - self, ir::TypeFolder, DefIdTree, IsSuggestable, Ty, TyCtxt, TypeSuperFoldable, TypeVisitable, + self, DefIdTree, IsSuggestable, Ty, TyCtxt, TypeFolder, TypeSuperFoldable, TypeVisitableExt, }; use rustc_session::errors::ExprParenthesesNeeded; use rustc_span::source_map::Spanned; diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index ab6e76ef8aa35..b739324099db3 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -12,7 +12,7 @@ use rustc_hir::{HirId, Pat, PatKind}; use rustc_infer::infer; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_middle::middle::stability::EvalResult; -use rustc_middle::ty::{self, Adt, BindingMode, Ty, TypeVisitable}; +use rustc_middle::ty::{self, Adt, BindingMode, Ty, TypeVisitableExt}; use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS; use rustc_span::edit_distance::find_best_match_for_name; use rustc_span::hygiene::DesugaringKind; diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs index b6c9a88c82dad..0394567cb0977 100644 --- a/compiler/rustc_hir_typeck/src/writeback.rs +++ b/compiler/rustc_hir_typeck/src/writeback.rs @@ -13,8 +13,8 @@ use rustc_infer::infer::InferCtxt; use rustc_middle::hir::place::Place as HirPlace; use rustc_middle::mir::FakeReadCause; use rustc_middle::ty::adjustment::{Adjust, Adjustment, PointerCast}; -use rustc_middle::ty::fold::{ir::TypeFolder, TypeFoldable, TypeSuperFoldable}; -use rustc_middle::ty::visit::TypeSuperVisitable; +use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable}; +use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt}; use rustc_middle::ty::TypeckResults; use rustc_middle::ty::{self, ClosureSizeProfileData, Ty, TyCtxt}; use rustc_span::symbol::sym; @@ -561,7 +561,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { struct RecursionChecker { def_id: LocalDefId, } - impl<'tcx> ty::ir::TypeVisitor> for RecursionChecker { + impl<'tcx> ty::TypeVisitor> for RecursionChecker { type BreakTy = (); fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, .. }) = *t.kind() { @@ -685,7 +685,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { fn resolve(&mut self, x: T, span: &dyn Locatable) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { let mut resolver = Resolver::new(self.fcx, span, self.body); let x = x.fold_with(&mut resolver); diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs index b736a416e4a10..f66f6bd4ae1bc 100644 --- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs +++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs @@ -10,9 +10,9 @@ use crate::infer::canonical::{ }; use crate::infer::InferCtxt; use rustc_middle::ty::flags::FlagComputation; -use rustc_middle::ty::fold::{ir::TypeFolder, TypeFoldable, TypeSuperFoldable}; +use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable}; use rustc_middle::ty::subst::GenericArg; -use rustc_middle::ty::{self, BoundVar, InferConst, List, Ty, TyCtxt, TypeFlags}; +use rustc_middle::ty::{self, BoundVar, InferConst, List, Ty, TyCtxt, TypeFlags, TypeVisitableExt}; use std::sync::atomic::Ordering; use rustc_data_structures::fx::FxHashMap; @@ -41,7 +41,7 @@ impl<'tcx> InferCtxt<'tcx> { query_state: &mut OriginalQueryValues<'tcx>, ) -> Canonical<'tcx, V> where - V: TypeFoldable<'tcx>, + V: TypeFoldable>, { self.tcx.sess.perf_stats.queries_canonicalized.fetch_add(1, Ordering::Relaxed); @@ -60,7 +60,7 @@ impl<'tcx> InferCtxt<'tcx> { query_state: &mut OriginalQueryValues<'tcx>, ) -> Canonical<'tcx, V> where - V: TypeFoldable<'tcx>, + V: TypeFoldable>, { self.tcx.sess.perf_stats.queries_canonicalized.fetch_add(1, Ordering::Relaxed); @@ -100,7 +100,7 @@ impl<'tcx> InferCtxt<'tcx> { /// [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html#canonicalizing-the-query-result pub fn canonicalize_response(&self, value: V) -> Canonical<'tcx, V> where - V: TypeFoldable<'tcx>, + V: TypeFoldable>, { let mut query_state = OriginalQueryValues::default(); Canonicalizer::canonicalize( @@ -114,7 +114,7 @@ impl<'tcx> InferCtxt<'tcx> { pub fn canonicalize_user_type_annotation(&self, value: V) -> Canonical<'tcx, V> where - V: TypeFoldable<'tcx>, + V: TypeFoldable>, { let mut query_state = OriginalQueryValues::default(); Canonicalizer::canonicalize( @@ -136,7 +136,7 @@ impl<'tcx> InferCtxt<'tcx> { query_state: &mut OriginalQueryValues<'tcx>, ) -> Canonical<'tcx, V> where - V: TypeFoldable<'tcx>, + V: TypeFoldable>, { self.tcx.sess.perf_stats.queries_canonicalized.fetch_add(1, Ordering::Relaxed); @@ -333,7 +333,7 @@ impl<'cx, 'tcx> TypeFolder> for Canonicalizer<'cx, 'tcx> { fn fold_binder(&mut self, t: ty::Binder<'tcx, T>) -> ty::Binder<'tcx, T> where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { self.binder_index.shift_in(1); let t = t.super_fold_with(self); @@ -530,7 +530,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> { query_state: &mut OriginalQueryValues<'tcx>, ) -> Canonical<'tcx, V> where - V: TypeFoldable<'tcx>, + V: TypeFoldable>, { let needs_canonical_flags = if canonicalize_region_mode.any() { TypeFlags::NEEDS_INFER | diff --git a/compiler/rustc_infer/src/infer/canonical/mod.rs b/compiler/rustc_infer/src/infer/canonical/mod.rs index 4552256545b4b..4053546f00c3d 100644 --- a/compiler/rustc_infer/src/infer/canonical/mod.rs +++ b/compiler/rustc_infer/src/infer/canonical/mod.rs @@ -26,7 +26,7 @@ use crate::infer::{InferCtxt, RegionVariableOrigin, TypeVariableOrigin, TypeVari use rustc_index::vec::IndexVec; use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::subst::GenericArg; -use rustc_middle::ty::{self, List}; +use rustc_middle::ty::{self, List, TyCtxt}; use rustc_span::source_map::Span; pub use rustc_middle::infer::canonical::*; @@ -55,7 +55,7 @@ impl<'tcx> InferCtxt<'tcx> { canonical: &Canonical<'tcx, T>, ) -> (T, CanonicalVarValues<'tcx>) where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { // For each universe that is referred to in the incoming // query, create a universe in our local inference context. In diff --git a/compiler/rustc_infer/src/infer/canonical/query_response.rs b/compiler/rustc_infer/src/infer/canonical/query_response.rs index e993fb4c22bb9..d3470d70f6571 100644 --- a/compiler/rustc_infer/src/infer/canonical/query_response.rs +++ b/compiler/rustc_infer/src/infer/canonical/query_response.rs @@ -59,7 +59,7 @@ impl<'tcx> InferCtxt<'tcx> { fulfill_cx: &mut dyn TraitEngine<'tcx>, ) -> Fallible> where - T: Debug + TypeFoldable<'tcx>, + T: Debug + TypeFoldable>, Canonical<'tcx, QueryResponse<'tcx, T>>: ArenaAllocatable<'tcx>, { let query_response = self.make_query_response(inference_vars, answer, fulfill_cx)?; @@ -85,7 +85,7 @@ impl<'tcx> InferCtxt<'tcx> { answer: T, ) -> Canonical<'tcx, QueryResponse<'tcx, T>> where - T: Debug + TypeFoldable<'tcx>, + T: Debug + TypeFoldable>, { self.canonicalize_response(QueryResponse { var_values: inference_vars, @@ -106,7 +106,7 @@ impl<'tcx> InferCtxt<'tcx> { fulfill_cx: &mut dyn TraitEngine<'tcx>, ) -> Result, NoSolution> where - T: Debug + TypeFoldable<'tcx>, + T: Debug + TypeFoldable>, { let tcx = self.tcx; @@ -180,7 +180,7 @@ impl<'tcx> InferCtxt<'tcx> { query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>, ) -> InferResult<'tcx, R> where - R: Debug + TypeFoldable<'tcx>, + R: Debug + TypeFoldable>, { let InferOk { value: result_subst, mut obligations } = self.query_response_substitution(cause, param_env, original_values, query_response)?; @@ -242,7 +242,7 @@ impl<'tcx> InferCtxt<'tcx> { output_query_region_constraints: &mut QueryRegionConstraints<'tcx>, ) -> InferResult<'tcx, R> where - R: Debug + TypeFoldable<'tcx>, + R: Debug + TypeFoldable>, { let InferOk { value: result_subst, mut obligations } = self .query_response_substitution_guess(cause, param_env, original_values, query_response)?; @@ -356,7 +356,7 @@ impl<'tcx> InferCtxt<'tcx> { query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>, ) -> InferResult<'tcx, CanonicalVarValues<'tcx>> where - R: Debug + TypeFoldable<'tcx>, + R: Debug + TypeFoldable>, { debug!( "query_response_substitution(original_values={:#?}, query_response={:#?})", @@ -401,7 +401,7 @@ impl<'tcx> InferCtxt<'tcx> { query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>, ) -> InferResult<'tcx, CanonicalVarValues<'tcx>> where - R: Debug + TypeFoldable<'tcx>, + R: Debug + TypeFoldable>, { debug!( "query_response_substitution_guess(original_values={:#?}, query_response={:#?})", @@ -523,7 +523,7 @@ impl<'tcx> InferCtxt<'tcx> { query_response: &Canonical<'tcx, QueryResponse<'tcx, R>>, ) -> InferResult<'tcx, ()> where - R: Debug + TypeFoldable<'tcx>, + R: Debug + TypeFoldable>, { // A closure that yields the result value for the given // canonical variable; this is taken from diff --git a/compiler/rustc_infer/src/infer/canonical/substitute.rs b/compiler/rustc_infer/src/infer/canonical/substitute.rs index e77f2d37b7dae..c5c6fc41b9e91 100644 --- a/compiler/rustc_infer/src/infer/canonical/substitute.rs +++ b/compiler/rustc_infer/src/infer/canonical/substitute.rs @@ -16,7 +16,7 @@ pub(super) trait CanonicalExt<'tcx, V> { /// with the value given in `var_values`. fn substitute(&self, tcx: TyCtxt<'tcx>, var_values: &CanonicalVarValues<'tcx>) -> V where - V: TypeFoldable<'tcx>; + V: TypeFoldable>; /// Allows one to apply a substitute to some subset of /// `self.value`. Invoke `projection_fn` with `self.value` to get @@ -31,13 +31,13 @@ pub(super) trait CanonicalExt<'tcx, V> { projection_fn: impl FnOnce(&V) -> T, ) -> T where - T: TypeFoldable<'tcx>; + T: TypeFoldable>; } impl<'tcx, V> CanonicalExt<'tcx, V> for Canonical<'tcx, V> { fn substitute(&self, tcx: TyCtxt<'tcx>, var_values: &CanonicalVarValues<'tcx>) -> V where - V: TypeFoldable<'tcx>, + V: TypeFoldable>, { self.substitute_projected(tcx, var_values, |value| value.clone()) } @@ -49,7 +49,7 @@ impl<'tcx, V> CanonicalExt<'tcx, V> for Canonical<'tcx, V> { projection_fn: impl FnOnce(&V) -> T, ) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { assert_eq!(self.variables.len(), var_values.len()); let value = projection_fn(&self.value); @@ -66,7 +66,7 @@ pub(super) fn substitute_value<'tcx, T>( value: T, ) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { if var_values.var_values.is_empty() { value diff --git a/compiler/rustc_infer/src/infer/combine.rs b/compiler/rustc_infer/src/infer/combine.rs index f5504b05dc4e3..243545640f9f1 100644 --- a/compiler/rustc_infer/src/infer/combine.rs +++ b/compiler/rustc_infer/src/infer/combine.rs @@ -40,8 +40,8 @@ use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::relate::{self, Relate, RelateResult, TypeRelation}; use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::{ - self, ir::FallibleTypeFolder, AliasKind, InferConst, ToPredicate, Ty, TyCtxt, TypeFoldable, - TypeSuperFoldable, + self, AliasKind, FallibleTypeFolder, InferConst, ToPredicate, Ty, TyCtxt, TypeFoldable, + TypeSuperFoldable, TypeVisitableExt, }; use rustc_middle::ty::{IntType, UintType}; use rustc_span::{Span, DUMMY_SP}; diff --git a/compiler/rustc_infer/src/infer/equate.rs b/compiler/rustc_infer/src/infer/equate.rs index 742c01efff603..f830e9b3c53fc 100644 --- a/compiler/rustc_infer/src/infer/equate.rs +++ b/compiler/rustc_infer/src/infer/equate.rs @@ -6,7 +6,7 @@ use super::Subtype; use rustc_middle::ty::relate::{self, Relate, RelateResult, TypeRelation}; use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::TyVar; -use rustc_middle::ty::{self, Ty, TyCtxt}; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; use rustc_hir::def_id::DefId; diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index dd6a76f754ddf..95635405f894d 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -72,7 +72,7 @@ use rustc_middle::ty::print::with_forced_trimmed_paths; use rustc_middle::ty::relate::{self, RelateResult, TypeRelation}; use rustc_middle::ty::{ self, error::TypeError, List, Region, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, - TypeVisitable, + TypeVisitable, TypeVisitableExt, }; use rustc_span::{sym, symbol::kw, BytePos, DesugaringKind, Pos, Span}; use rustc_target::spec::abi; @@ -1450,8 +1450,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { impl<'tcx> OpaqueTypesVisitor<'tcx> { fn visit_expected_found( tcx: TyCtxt<'tcx>, - expected: impl TypeVisitable<'tcx>, - found: impl TypeVisitable<'tcx>, + expected: impl TypeVisitable>, + found: impl TypeVisitable>, ignore_span: Span, ) -> Self { let mut types_visitor = OpaqueTypesVisitor { @@ -1501,7 +1501,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } } - impl<'tcx> ty::visit::ir::TypeVisitor> for OpaqueTypesVisitor<'tcx> { + impl<'tcx> ty::visit::TypeVisitor> for OpaqueTypesVisitor<'tcx> { fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { if let Some((kind, def_id)) = TyCategory::from_ty(self.tcx, t) { let span = self.tcx.def_span(def_id); @@ -2206,7 +2206,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> { } /// Returns a string of the form "expected `{}`, found `{}`". - fn expected_found_str>( + fn expected_found_str>>( &self, exp_found: ty::error::ExpectedFound, ) -> Option<(DiagnosticStyledString, DiagnosticStyledString, Option, Option)> diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs index 641477e907dfa..b06ff10d86eb0 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -17,8 +17,7 @@ use rustc_hir::{ TyKind, }; use rustc_middle::ty::{ - self, ir::TypeVisitor, AssocItemContainer, StaticLifetimeVisitor, Ty, TyCtxt, - TypeSuperVisitable, + self, AssocItemContainer, StaticLifetimeVisitor, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor, }; use rustc_span::symbol::Ident; use rustc_span::Span; diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs index d295881d5d7a0..2875448ee157c 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs @@ -75,7 +75,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { } } - impl<'tcx> ty::visit::ir::TypeVisitor> for HighlightBuilder<'tcx> { + impl<'tcx> ty::visit::TypeVisitor> for HighlightBuilder<'tcx> { fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow { if !r.has_name() && self.counter <= 3 { self.highlight.highlighting_region(r, self.counter); diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs index ac4de2cc84266..db4b8af4683e3 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs @@ -143,7 +143,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { fn includes_region( &self, - ty: Binder<'tcx, impl TypeVisitable<'tcx>>, + ty: Binder<'tcx, impl TypeVisitable>>, region: ty::BoundRegionKind, ) -> bool { let late_bound_regions = self.tcx().collect_referenced_late_bound_regions(&ty); diff --git a/compiler/rustc_infer/src/infer/error_reporting/suggest.rs b/compiler/rustc_infer/src/infer/error_reporting/suggest.rs index 18c5097a26289..55dcfd05e0ad3 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/suggest.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/suggest.rs @@ -8,7 +8,7 @@ use rustc_middle::traits::{ StatementAsExpression, }; use rustc_middle::ty::print::with_no_trimmed_paths; -use rustc_middle::ty::{self as ty, IsSuggestable, Ty, TypeVisitable}; +use rustc_middle::ty::{self as ty, IsSuggestable, Ty, TypeVisitableExt}; use rustc_span::{sym, BytePos, Span}; use crate::errors::{ diff --git a/compiler/rustc_infer/src/infer/freshen.rs b/compiler/rustc_infer/src/infer/freshen.rs index 41bffdc684da4..f09f93abf45d6 100644 --- a/compiler/rustc_infer/src/infer/freshen.rs +++ b/compiler/rustc_infer/src/infer/freshen.rs @@ -33,8 +33,8 @@ use super::InferCtxt; use rustc_data_structures::fx::FxHashMap; use rustc_middle::infer::unify_key::ToType; -use rustc_middle::ty::fold::ir::TypeFolder; -use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable}; +use rustc_middle::ty::fold::TypeFolder; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, TypeVisitableExt}; use std::collections::hash_map::Entry; pub struct TypeFreshener<'a, 'tcx> { diff --git a/compiler/rustc_infer/src/infer/fudge.rs b/compiler/rustc_infer/src/infer/fudge.rs index cc2f19a570490..86c2c2be4a805 100644 --- a/compiler/rustc_infer/src/infer/fudge.rs +++ b/compiler/rustc_infer/src/infer/fudge.rs @@ -1,4 +1,4 @@ -use rustc_middle::ty::fold::{ir::TypeFolder, TypeFoldable, TypeSuperFoldable}; +use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable}; use rustc_middle::ty::{self, ConstVid, FloatVid, IntVid, RegionVid, Ty, TyCtxt, TyVid}; use super::type_variable::TypeVariableOrigin; @@ -98,7 +98,7 @@ impl<'tcx> InferCtxt<'tcx> { pub fn fudge_inference_if_ok(&self, f: F) -> Result where F: FnOnce() -> Result, - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { let variable_lengths = self.variable_lengths(); let (mut fudger, value) = self.probe(|_| { diff --git a/compiler/rustc_infer/src/infer/glb.rs b/compiler/rustc_infer/src/infer/glb.rs index 74abca7bbea36..37ef022f8271c 100644 --- a/compiler/rustc_infer/src/infer/glb.rs +++ b/compiler/rustc_infer/src/infer/glb.rs @@ -7,7 +7,7 @@ use super::Subtype; use crate::traits::{ObligationCause, PredicateObligations}; use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation}; -use rustc_middle::ty::{self, Ty, TyCtxt}; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; /// "Greatest lower bound" (common subtype) pub struct Glb<'combine, 'infcx, 'tcx> { diff --git a/compiler/rustc_infer/src/infer/higher_ranked/mod.rs b/compiler/rustc_infer/src/infer/higher_ranked/mod.rs index 82a1bb1fd1615..d1897cf24b4a0 100644 --- a/compiler/rustc_infer/src/infer/higher_ranked/mod.rs +++ b/compiler/rustc_infer/src/infer/higher_ranked/mod.rs @@ -6,7 +6,7 @@ use super::{HigherRankedType, InferCtxt}; use crate::infer::CombinedSnapshot; use rustc_middle::ty::fold::FnMutDelegate; use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation}; -use rustc_middle::ty::{self, Binder, TypeFoldable}; +use rustc_middle::ty::{self, Binder, TyCtxt, TypeFoldable}; impl<'a, 'tcx> CombineFields<'a, 'tcx> { /// Checks whether `for<..> sub <: for<..> sup` holds. @@ -72,7 +72,7 @@ impl<'tcx> InferCtxt<'tcx> { #[instrument(level = "debug", skip(self), ret)] pub fn instantiate_binder_with_placeholders(&self, binder: ty::Binder<'tcx, T>) -> T where - T: TypeFoldable<'tcx> + Copy, + T: TypeFoldable> + Copy, { if let Some(inner) = binder.no_bound_vars() { return inner; diff --git a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs index ac203c4eb0b24..175d02bc3cdc0 100644 --- a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs +++ b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs @@ -1024,7 +1024,7 @@ impl<'tcx> fmt::Debug for RegionAndOrigin<'tcx> { impl<'tcx> LexicalRegionResolutions<'tcx> { fn normalize(&self, tcx: TyCtxt<'tcx>, value: T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { tcx.fold_regions(value, |r, _db| self.resolve_region(tcx, r)) } diff --git a/compiler/rustc_infer/src/infer/lub.rs b/compiler/rustc_infer/src/infer/lub.rs index f997171b97f27..f541fcbceedb3 100644 --- a/compiler/rustc_infer/src/infer/lub.rs +++ b/compiler/rustc_infer/src/infer/lub.rs @@ -7,7 +7,7 @@ use super::Subtype; use crate::traits::{ObligationCause, PredicateObligations}; use rustc_middle::ty::relate::{Relate, RelateResult, TypeRelation}; -use rustc_middle::ty::{self, Ty, TyCtxt}; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; /// "Least upper bound" (common supertype) pub struct Lub<'combine, 'infcx, 'tcx> { diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs index 29c9af5c43fb9..cf8007c964dc0 100644 --- a/compiler/rustc_infer/src/infer/mod.rs +++ b/compiler/rustc_infer/src/infer/mod.rs @@ -26,10 +26,10 @@ use rustc_middle::mir::ConstraintCategory; use rustc_middle::traits::select; use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::fold::BoundVarReplacerDelegate; -use rustc_middle::ty::fold::{ir::TypeFolder, TypeFoldable, TypeSuperFoldable}; +use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable}; use rustc_middle::ty::relate::RelateResult; use rustc_middle::ty::subst::{GenericArg, GenericArgKind, InternalSubsts, SubstsRef}; -use rustc_middle::ty::visit::TypeVisitable; +use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt}; pub use rustc_middle::ty::IntVarValue; use rustc_middle::ty::{self, GenericParamDefKind, InferConst, InferTy, Ty, TyCtxt}; use rustc_middle::ty::{ConstVid, FloatVid, IntVid, TyVid}; @@ -617,7 +617,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> { canonical: &Canonical<'tcx, T>, ) -> (InferCtxt<'tcx>, T, CanonicalVarValues<'tcx>) where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { let infcx = self.build(); let (value, subst) = infcx.instantiate_canonical_with_fresh_inference_vars(span, canonical); @@ -697,7 +697,7 @@ impl<'tcx> InferCtxt<'tcx> { self.in_snapshot.get() } - pub fn freshen>(&self, t: T) -> T { + pub fn freshen>>(&self, t: T) -> T { t.fold_with(&mut self.freshener()) } @@ -1371,7 +1371,7 @@ impl<'tcx> InferCtxt<'tcx> { /// will be resolving them as well, e.g. in a loop). pub fn shallow_resolve(&self, value: T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { value.fold_with(&mut ShallowResolver { infcx: self }) } @@ -1388,7 +1388,7 @@ impl<'tcx> InferCtxt<'tcx> { /// at will. pub fn resolve_vars_if_possible(&self, value: T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { if !value.has_non_region_infer() { return value; @@ -1399,7 +1399,7 @@ impl<'tcx> InferCtxt<'tcx> { pub fn resolve_numeric_literals_with_default(&self, value: T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { if !value.needs_infer() { return value; // Avoid duplicated subst-folding. @@ -1414,7 +1414,7 @@ impl<'tcx> InferCtxt<'tcx> { value: &T, ) -> Option<(ty::Term<'tcx>, Option)> where - T: TypeVisitable<'tcx>, + T: TypeVisitable>, { value.visit_with(&mut resolve::UnresolvedTypeOrConstFinder::new(self)).break_value() } @@ -1429,7 +1429,7 @@ impl<'tcx> InferCtxt<'tcx> { } } - pub fn fully_resolve>(&self, value: T) -> FixupResult<'tcx, T> { + pub fn fully_resolve>>(&self, value: T) -> FixupResult<'tcx, T> { /*! * Attempts to resolve all type/region/const variables in * `value`. Region inference must have been run already (e.g., @@ -1462,7 +1462,7 @@ impl<'tcx> InferCtxt<'tcx> { value: ty::Binder<'tcx, T>, ) -> T where - T: TypeFoldable<'tcx> + Copy, + T: TypeFoldable> + Copy, { if let Some(inner) = value.no_bound_vars() { return inner; diff --git a/compiler/rustc_infer/src/infer/nll_relate/mod.rs b/compiler/rustc_infer/src/infer/nll_relate/mod.rs index 954334e88b0cb..214a5850fb6b2 100644 --- a/compiler/rustc_infer/src/infer/nll_relate/mod.rs +++ b/compiler/rustc_infer/src/infer/nll_relate/mod.rs @@ -29,7 +29,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_middle::traits::ObligationCause; use rustc_middle::ty::error::TypeError; use rustc_middle::ty::relate::{self, Relate, RelateResult, TypeRelation}; -use rustc_middle::ty::visit::{ir::TypeVisitor, TypeSuperVisitable, TypeVisitable}; +use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor}; use rustc_middle::ty::{self, InferConst, Ty, TyCtxt}; use rustc_span::{Span, Symbol}; use std::fmt::Debug; @@ -797,7 +797,7 @@ struct ScopeInstantiator<'me, 'tcx> { } impl<'me, 'tcx> TypeVisitor> for ScopeInstantiator<'me, 'tcx> { - fn visit_binder>( + fn visit_binder>>( &mut self, t: &ty::Binder<'tcx, T>, ) -> ControlFlow { diff --git a/compiler/rustc_infer/src/infer/opaque_types.rs b/compiler/rustc_infer/src/infer/opaque_types.rs index a657d655f3eef..d5c824d4c41c8 100644 --- a/compiler/rustc_infer/src/infer/opaque_types.rs +++ b/compiler/rustc_infer/src/infer/opaque_types.rs @@ -12,8 +12,8 @@ use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::fold::BottomUpFolder; use rustc_middle::ty::GenericArgKind; use rustc_middle::ty::{ - self, ir::TypeVisitor, OpaqueHiddenType, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable, - TypeSuperVisitable, TypeVisitable, + self, OpaqueHiddenType, OpaqueTypeKey, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, + TypeVisitable, TypeVisitableExt, TypeVisitor, }; use rustc_span::Span; @@ -45,7 +45,7 @@ pub struct OpaqueTypeDecl<'tcx> { impl<'tcx> InferCtxt<'tcx> { /// This is a backwards compatibility hack to prevent breaking changes from /// lazy TAIT around RPIT handling. - pub fn replace_opaque_types_with_inference_vars>( + pub fn replace_opaque_types_with_inference_vars>>( &self, value: T, body_id: LocalDefId, @@ -427,7 +427,7 @@ impl<'tcx, OP> TypeVisitor> for ConstrainOpaqueTypeRegionVisitor<'t where OP: FnMut(ty::Region<'tcx>), { - fn visit_binder>( + fn visit_binder>>( &mut self, t: &ty::Binder<'tcx, T>, ) -> ControlFlow { diff --git a/compiler/rustc_infer/src/infer/outlives/components.rs b/compiler/rustc_infer/src/infer/outlives/components.rs index e3d9566917125..ff23087fe8d8a 100644 --- a/compiler/rustc_infer/src/infer/outlives/components.rs +++ b/compiler/rustc_infer/src/infer/outlives/components.rs @@ -4,7 +4,7 @@ use rustc_data_structures::sso::SsoHashSet; use rustc_middle::ty::subst::{GenericArg, GenericArgKind}; -use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; use smallvec::{smallvec, SmallVec}; #[derive(Debug)] diff --git a/compiler/rustc_infer/src/infer/outlives/obligations.rs b/compiler/rustc_infer/src/infer/outlives/obligations.rs index 0194549a8868d..bbe7d4c63f794 100644 --- a/compiler/rustc_infer/src/infer/outlives/obligations.rs +++ b/compiler/rustc_infer/src/infer/outlives/obligations.rs @@ -69,7 +69,7 @@ use crate::traits::{ObligationCause, ObligationCauseCode}; use rustc_data_structures::undo_log::UndoLogs; use rustc_middle::mir::ConstraintCategory; use rustc_middle::ty::subst::GenericArgKind; -use rustc_middle::ty::{self, Region, SubstsRef, Ty, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, Region, SubstsRef, Ty, TyCtxt, TypeVisitableExt}; use smallvec::smallvec; impl<'tcx> InferCtxt<'tcx> { diff --git a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs index 2f7c496161bca..3c6cc2b90010f 100644 --- a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs +++ b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs @@ -1,7 +1,7 @@ use std::collections::hash_map::Entry; use rustc_data_structures::fx::FxHashMap; -use rustc_middle::ty::TypeVisitable; +use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::{ self, error::TypeError, diff --git a/compiler/rustc_infer/src/infer/resolve.rs b/compiler/rustc_infer/src/infer/resolve.rs index 2c246a5787c7c..5bb35832930bf 100644 --- a/compiler/rustc_infer/src/infer/resolve.rs +++ b/compiler/rustc_infer/src/infer/resolve.rs @@ -1,11 +1,8 @@ use super::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use super::{FixupError, FixupResult, InferCtxt, Span}; use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind}; -use rustc_middle::ty::fold::{ - ir::{FallibleTypeFolder, TypeFolder}, - TypeSuperFoldable, -}; -use rustc_middle::ty::visit::{ir::TypeVisitor, TypeSuperVisitable}; +use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFolder, TypeSuperFoldable}; +use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitableExt, TypeVisitor}; use rustc_middle::ty::{self, Const, InferConst, Ty, TyCtxt, TypeFoldable}; use std::ops::ControlFlow; @@ -200,7 +197,7 @@ impl<'a, 'tcx> TypeVisitor> for UnresolvedTypeOrConstFinder<'a, 'tc /// then an `Err` result is returned. pub fn fully_resolve<'tcx, T>(infcx: &InferCtxt<'tcx>, value: T) -> FixupResult<'tcx, T> where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { value.try_fold_with(&mut FullTypeResolver { infcx }) } diff --git a/compiler/rustc_infer/src/infer/sub.rs b/compiler/rustc_infer/src/infer/sub.rs index bf1b34415470c..b4e647dcc9bf5 100644 --- a/compiler/rustc_infer/src/infer/sub.rs +++ b/compiler/rustc_infer/src/infer/sub.rs @@ -3,7 +3,7 @@ use super::{ObligationEmittingRelation, SubregionOrigin}; use crate::traits::{Obligation, PredicateObligations}; use rustc_middle::ty::relate::{Cause, Relate, RelateResult, TypeRelation}; -use rustc_middle::ty::visit::TypeVisitable; +use rustc_middle::ty::visit::TypeVisitableExt; use rustc_middle::ty::TyVar; use rustc_middle::ty::{self, Ty, TyCtxt}; use std::mem; diff --git a/compiler/rustc_infer/src/traits/structural_impls.rs b/compiler/rustc_infer/src/traits/structural_impls.rs index 95df6cd62b90b..3a5273b0359e4 100644 --- a/compiler/rustc_infer/src/traits/structural_impls.rs +++ b/compiler/rustc_infer/src/traits/structural_impls.rs @@ -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, TyCtxt}; +use rustc_middle::ty::{self, TyCtxt}; use std::fmt; use std::ops::ControlFlow; @@ -61,8 +61,13 @@ impl<'tcx> fmt::Debug for traits::MismatchedProjectionTypes<'tcx> { /////////////////////////////////////////////////////////////////////////// // TypeFoldable implementations. -impl<'tcx, O: TypeFoldable<'tcx>> ir::TypeFoldable> for traits::Obligation<'tcx, O> { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx, O: TypeFoldable>> TypeFoldable> + for traits::Obligation<'tcx, O> +{ + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { Ok(traits::Obligation { cause: self.cause, recursion_depth: self.recursion_depth, @@ -72,8 +77,10 @@ impl<'tcx, O: TypeFoldable<'tcx>> ir::TypeFoldable> for traits::Obl } } -impl<'tcx, O: TypeVisitable<'tcx>> ir::TypeVisitable> for traits::Obligation<'tcx, O> { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx, O: TypeVisitable>> TypeVisitable> + for traits::Obligation<'tcx, O> +{ + fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { self.predicate.visit_with(visitor)?; self.param_env.visit_with(visitor) } diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 726042479e9b0..cd9b19385a0be 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -1583,7 +1583,7 @@ declare_lint_pass!( impl<'tcx> LateLintPass<'tcx> for TrivialConstraints { fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'tcx>) { - use rustc_middle::ty::visit::TypeVisitable; + use rustc_middle::ty::visit::TypeVisitableExt; use rustc_middle::ty::Clause; use rustc_middle::ty::PredicateKind::*; diff --git a/compiler/rustc_lint/src/enum_intrinsics_non_enums.rs b/compiler/rustc_lint/src/enum_intrinsics_non_enums.rs index 73bd4173270ba..f1ba192f2bcc0 100644 --- a/compiler/rustc_lint/src/enum_intrinsics_non_enums.rs +++ b/compiler/rustc_lint/src/enum_intrinsics_non_enums.rs @@ -4,7 +4,7 @@ use crate::{ LateContext, LateLintPass, }; use rustc_hir as hir; -use rustc_middle::ty::{visit::TypeVisitable, Ty}; +use rustc_middle::ty::{visit::TypeVisitableExt, Ty}; use rustc_span::{symbol::sym, Span}; declare_lint! { diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index b7fd6a254d811..15a229ea9c5f9 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -13,7 +13,9 @@ use rustc_hir as hir; use rustc_hir::{is_range_literal, Expr, ExprKind, Node}; use rustc_middle::ty::layout::{IntegerExt, LayoutOf, SizeSkeleton}; use rustc_middle::ty::subst::SubstsRef; -use rustc_middle::ty::{self, AdtKind, DefIdTree, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable}; +use rustc_middle::ty::{ + self, AdtKind, DefIdTree, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, +}; use rustc_span::def_id::LocalDefId; use rustc_span::source_map; use rustc_span::symbol::sym; @@ -1144,7 +1146,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> for ProhibitOpaqueTypes { + impl<'tcx> ty::visit::TypeVisitor> for ProhibitOpaqueTypes { type BreakTy = Ty<'tcx>; fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow { diff --git a/compiler/rustc_macros/src/type_foldable.rs b/compiler/rustc_macros/src/type_foldable.rs index 51729a377d957..388e254cd6453 100644 --- a/compiler/rustc_macros/src/type_foldable.rs +++ b/compiler/rustc_macros/src/type_foldable.rs @@ -37,16 +37,16 @@ pub fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:: bind.to_token_stream() } else { quote! { - ::rustc_middle::ty::fold::ir::TypeFoldable::try_fold_with(#bind, __folder)? + ::rustc_middle::ty::fold::TypeFoldable::try_fold_with(#bind, __folder)? } } }) }); s.bound_impl( - quote!(::rustc_middle::ty::fold::ir::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>), + quote!(::rustc_middle::ty::fold::TypeFoldable<::rustc_middle::ty::TyCtxt<'tcx>>), quote! { - fn try_fold_with<__F: ::rustc_middle::ty::fold::FallibleTypeFolder<'tcx>>( + fn try_fold_with<__F: ::rustc_middle::ty::fold::FallibleTypeFolder<::rustc_middle::ty::TyCtxt<'tcx>>>( self, __folder: &mut __F ) -> Result { diff --git a/compiler/rustc_macros/src/type_visitable.rs b/compiler/rustc_macros/src/type_visitable.rs index 0a16a371fdc94..f6f4c4779c302 100644 --- a/compiler/rustc_macros/src/type_visitable.rs +++ b/compiler/rustc_macros/src/type_visitable.rs @@ -30,15 +30,15 @@ pub fn type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2: s.add_bounds(synstructure::AddBounds::Generics); let body_visit = s.each(|bind| { quote! { - ::rustc_middle::ty::visit::ir::TypeVisitable::visit_with(#bind, __visitor)?; + ::rustc_middle::ty::visit::TypeVisitable::visit_with(#bind, __visitor)?; } }); s.bind_with(|_| synstructure::BindStyle::Move); s.bound_impl( - quote!(::rustc_middle::ty::visit::ir::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>), + quote!(::rustc_middle::ty::visit::TypeVisitable<::rustc_middle::ty::TyCtxt<'tcx>>), quote! { - fn visit_with<__V: ::rustc_middle::ty::visit::TypeVisitor<'tcx>>( + fn visit_with<__V: ::rustc_middle::ty::visit::TypeVisitor<::rustc_middle::ty::TyCtxt<'tcx>>>( &self, __visitor: &mut __V ) -> ::std::ops::ControlFlow<__V::BreakTy> { diff --git a/compiler/rustc_middle/src/infer/canonical.rs b/compiler/rustc_middle/src/infer/canonical.rs index bb617e692ccea..e134ef8489c77 100644 --- a/compiler/rustc_middle/src/infer/canonical.rs +++ b/compiler/rustc_middle/src/infer/canonical.rs @@ -42,8 +42,8 @@ pub struct Canonical<'tcx, V> { pub type CanonicalVarInfos<'tcx> = &'tcx List>; -impl<'tcx> ty::ir::TypeFoldable> for CanonicalVarInfos<'tcx> { - fn try_fold_with>( +impl<'tcx> ty::TypeFoldable> for CanonicalVarInfos<'tcx> { + fn try_fold_with>>( self, folder: &mut F, ) -> Result { diff --git a/compiler/rustc_middle/src/macros.rs b/compiler/rustc_middle/src/macros.rs index 57d66ac6a039e..a8d71ce030c2a 100644 --- a/compiler/rustc_middle/src/macros.rs +++ b/compiler/rustc_middle/src/macros.rs @@ -69,8 +69,8 @@ macro_rules! CloneLiftImpls { macro_rules! TrivialTypeTraversalImpls { (for <$tcx:lifetime> { $($ty:ty,)+ }) => { $( - impl<$tcx> $crate::ty::fold::ir::TypeFoldable<$crate::ty::TyCtxt<$tcx>> for $ty { - fn try_fold_with>( + impl<$tcx> $crate::ty::fold::TypeFoldable<$crate::ty::TyCtxt<$tcx>> for $ty { + fn try_fold_with>>( self, _: &mut F, ) -> ::std::result::Result { @@ -78,7 +78,7 @@ macro_rules! TrivialTypeTraversalImpls { } #[inline] - fn fold_with>( + fn fold_with>>( self, _: &mut F, ) -> Self { @@ -86,9 +86,9 @@ macro_rules! TrivialTypeTraversalImpls { } } - impl<$tcx> $crate::ty::visit::ir::TypeVisitable<$crate::ty::TyCtxt<$tcx>> for $ty { + impl<$tcx> $crate::ty::visit::TypeVisitable<$crate::ty::TyCtxt<$tcx>> for $ty { #[inline] - fn visit_with>( + fn visit_with>>( &self, _: &mut F) -> ::std::ops::ControlFlow diff --git a/compiler/rustc_middle/src/mir/interpret/queries.rs b/compiler/rustc_middle/src/mir/interpret/queries.rs index b6c6e9d559c8c..856d821a5cf14 100644 --- a/compiler/rustc_middle/src/mir/interpret/queries.rs +++ b/compiler/rustc_middle/src/mir/interpret/queries.rs @@ -2,7 +2,7 @@ use super::{ErrorHandled, EvalToConstValueResult, EvalToValTreeResult, GlobalId} use crate::mir; use crate::ty::subst::InternalSubsts; -use crate::ty::visit::TypeVisitable; +use crate::ty::visit::TypeVisitableExt; use crate::ty::{self, query::TyCtxtAt, query::TyCtxtEnsure, TyCtxt}; use rustc_hir::def::DefKind; use rustc_hir::def_id::DefId; diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 46184cddd51f5..ccd8a33386693 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -7,10 +7,10 @@ use crate::mir::interpret::{ }; use crate::mir::visit::MirVisitable; use crate::ty::codec::{TyDecoder, TyEncoder}; -use crate::ty::fold::{ir::TypeFoldable, FallibleTypeFolder}; +use crate::ty::fold::{FallibleTypeFolder, TypeFoldable}; use crate::ty::print::{FmtPrinter, Printer}; -use crate::ty::visit::{TypeVisitable, TypeVisitor}; -use crate::ty::{self, ir, DefIdTree, List, Ty, TyCtxt}; +use crate::ty::visit::{TypeVisitable, TypeVisitableExt, TypeVisitor}; +use crate::ty::{self, DefIdTree, List, Ty, TyCtxt}; use crate::ty::{AdtDef, InstanceDef, ScalarInt, UserTypeAnnotationIndex}; use crate::ty::{GenericArg, InternalSubsts, SubstsRef}; @@ -2755,7 +2755,10 @@ impl UserTypeProjection { } impl<'tcx> TypeFoldable> for UserTypeProjection { - fn try_fold_with>(self, folder: &mut F) -> Result { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { Ok(UserTypeProjection { base: self.base.try_fold_with(folder)?, projs: self.projs.try_fold_with(folder)?, @@ -2763,8 +2766,11 @@ impl<'tcx> TypeFoldable> for UserTypeProjection { } } -impl<'tcx> ir::TypeVisitable> for UserTypeProjection { - fn visit_with>(&self, visitor: &mut Vs) -> ControlFlow { +impl<'tcx> TypeVisitable> for UserTypeProjection { + fn visit_with>>( + &self, + visitor: &mut Vs, + ) -> ControlFlow { self.base.visit_with(visitor) // Note: there's nothing in `self.proj` to visit. } diff --git a/compiler/rustc_middle/src/mir/type_foldable.rs b/compiler/rustc_middle/src/mir/type_foldable.rs index ce06a0ef0608f..d0936d950b361 100644 --- a/compiler/rustc_middle/src/mir/type_foldable.rs +++ b/compiler/rustc_middle/src/mir/type_foldable.rs @@ -31,19 +31,28 @@ TrivialTypeTraversalImpls! { } impl<'tcx> TypeFoldable> for &'tcx [InlineAsmTemplatePiece] { - fn try_fold_with>(self, _folder: &mut F) -> Result { + fn try_fold_with>>( + self, + _folder: &mut F, + ) -> Result { Ok(self) } } impl<'tcx> TypeFoldable> for &'tcx [Span] { - fn try_fold_with>(self, _folder: &mut F) -> Result { + fn try_fold_with>>( + self, + _folder: &mut F, + ) -> Result { Ok(self) } } impl<'tcx> TypeFoldable> for &'tcx ty::List> { - fn try_fold_with>(self, folder: &mut F) -> Result { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { ty::util::fold_list(self, folder, |tcx, v| tcx.intern_place_elems(v)) } } diff --git a/compiler/rustc_middle/src/traits/query.rs b/compiler/rustc_middle/src/traits/query.rs index 615154a55e586..c4f8718754f5f 100644 --- a/compiler/rustc_middle/src/traits/query.rs +++ b/compiler/rustc_middle/src/traits/query.rs @@ -14,7 +14,7 @@ use rustc_span::source_map::Span; pub mod type_op { use crate::ty::fold::TypeFoldable; - use crate::ty::{Predicate, Ty, UserType}; + use crate::ty::{Predicate, Ty, TyCtxt, UserType}; use std::fmt; #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable, Lift)] @@ -64,7 +64,7 @@ pub mod type_op { impl<'tcx, T> Normalize where - T: fmt::Debug + TypeFoldable<'tcx>, + T: fmt::Debug + TypeFoldable>, { pub fn new(value: T) -> Self { Self { value } diff --git a/compiler/rustc_middle/src/traits/solve.rs b/compiler/rustc_middle/src/traits/solve.rs index bddf84880d297..aadbce9e2ff3f 100644 --- a/compiler/rustc_middle/src/traits/solve.rs +++ b/compiler/rustc_middle/src/traits/solve.rs @@ -3,8 +3,7 @@ use std::ops::ControlFlow; use rustc_data_structures::intern::Interned; use crate::ty::{ - ir::{self, TypeFoldable, TypeVisitable}, - FallibleTypeFolder, Ty, TyCtxt, TypeFolder, TypeVisitor, + FallibleTypeFolder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeVisitable, TypeVisitor, }; #[derive(Debug, PartialEq, Eq, Copy, Clone, Hash)] @@ -27,8 +26,11 @@ pub struct ExternalConstraintsData<'tcx> { } impl<'tcx> TypeFoldable> for ExternalConstraints<'tcx> { - fn try_fold_with>(self, folder: &mut F) -> Result { - Ok(ir::FallibleTypeFolder::interner(folder).intern_external_constraints( + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { + Ok(FallibleTypeFolder::interner(folder).intern_external_constraints( ExternalConstraintsData { regions: (), opaque_types: self @@ -40,8 +42,8 @@ impl<'tcx> TypeFoldable> for ExternalConstraints<'tcx> { )) } - fn fold_with>(self, folder: &mut F) -> Self { - ir::TypeFolder::interner(folder).intern_external_constraints(ExternalConstraintsData { + fn fold_with>>(self, folder: &mut F) -> Self { + TypeFolder::interner(folder).intern_external_constraints(ExternalConstraintsData { regions: (), opaque_types: self.opaque_types.iter().map(|opaque| opaque.fold_with(folder)).collect(), }) @@ -49,7 +51,7 @@ impl<'tcx> TypeFoldable> for ExternalConstraints<'tcx> { } impl<'tcx> TypeVisitable> for ExternalConstraints<'tcx> { - fn visit_with>( + fn visit_with>>( &self, visitor: &mut V, ) -> std::ops::ControlFlow { diff --git a/compiler/rustc_middle/src/traits/specialization_graph.rs b/compiler/rustc_middle/src/traits/specialization_graph.rs index 4019cf8ceee64..c016f72275099 100644 --- a/compiler/rustc_middle/src/traits/specialization_graph.rs +++ b/compiler/rustc_middle/src/traits/specialization_graph.rs @@ -1,6 +1,6 @@ use crate::error::StrictCoherenceNeedsNegativeCoherence; use crate::ty::fast_reject::SimplifiedType; -use crate::ty::visit::TypeVisitable; +use crate::ty::visit::TypeVisitableExt; use crate::ty::{self, TyCtxt}; use rustc_data_structures::fx::FxIndexMap; use rustc_errors::ErrorGuaranteed; diff --git a/compiler/rustc_middle/src/ty/abstract_const.rs b/compiler/rustc_middle/src/ty/abstract_const.rs index b7f0a0be75ee2..f889ce82706b3 100644 --- a/compiler/rustc_middle/src/ty/abstract_const.rs +++ b/compiler/rustc_middle/src/ty/abstract_const.rs @@ -1,6 +1,7 @@ //! A subset of a mir body used for const evaluatability checking. use crate::ty::{ - self, ir::TypeFolder, Const, EarlyBinder, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, + self, Const, EarlyBinder, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, + TypeVisitableExt, }; use rustc_errors::ErrorGuaranteed; use rustc_hir::def_id::DefId; @@ -47,7 +48,7 @@ impl<'tcx> TyCtxt<'tcx> { Ok(ac?.map(|ac| EarlyBinder(ac))) } - pub fn expand_abstract_consts>(self, ac: T) -> T { + pub fn expand_abstract_consts>>(self, ac: T) -> T { struct Expander<'tcx> { tcx: TyCtxt<'tcx>, } diff --git a/compiler/rustc_middle/src/ty/consts/kind.rs b/compiler/rustc_middle/src/ty/consts/kind.rs index 52f4414e37bde..560caa041a702 100644 --- a/compiler/rustc_middle/src/ty/consts/kind.rs +++ b/compiler/rustc_middle/src/ty/consts/kind.rs @@ -4,7 +4,7 @@ use crate::mir::interpret::{AllocId, ConstValue, Scalar}; use crate::ty::abstract_const::CastKind; use crate::ty::subst::{InternalSubsts, SubstsRef}; use crate::ty::ParamEnv; -use crate::ty::{self, List, Ty, TyCtxt, TypeVisitable}; +use crate::ty::{self, List, Ty, TyCtxt, TypeVisitableExt}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_errors::ErrorGuaranteed; use rustc_hir::def_id::DefId; diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs index a029c1b209df4..fe8b593480412 100644 --- a/compiler/rustc_middle/src/ty/diagnostics.rs +++ b/compiler/rustc_middle/src/ty/diagnostics.rs @@ -3,10 +3,9 @@ use std::ops::ControlFlow; use crate::ty::{ - ir::{FallibleTypeFolder, TypeVisitor}, - visit::TypeVisitable, - AliasTy, Const, ConstKind, DefIdTree, InferConst, InferTy, Opaque, PolyTraitPredicate, - Projection, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, TypeSuperVisitable, + AliasTy, Const, ConstKind, DefIdTree, FallibleTypeFolder, InferConst, InferTy, Opaque, + PolyTraitPredicate, Projection, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, + TypeSuperVisitable, TypeVisitable, TypeVisitor, }; use rustc_data_structures::fx::FxHashMap; @@ -95,7 +94,7 @@ pub trait IsSuggestable<'tcx>: Sized { impl<'tcx, T> IsSuggestable<'tcx> for T where - T: TypeVisitable<'tcx> + TypeFoldable<'tcx>, + T: TypeVisitable> + TypeFoldable>, { fn is_suggestable(self, tcx: TyCtxt<'tcx>, infer_suggestable: bool) -> bool { self.visit_with(&mut IsSuggestableVisitor { tcx, infer_suggestable }).is_continue() diff --git a/compiler/rustc_middle/src/ty/erase_regions.rs b/compiler/rustc_middle/src/ty/erase_regions.rs index d3b031bf8755c..3837732483244 100644 --- a/compiler/rustc_middle/src/ty/erase_regions.rs +++ b/compiler/rustc_middle/src/ty/erase_regions.rs @@ -1,5 +1,5 @@ -use crate::ty::fold::{ir::TypeFolder, TypeFoldable, TypeSuperFoldable}; -use crate::ty::{self, Ty, TyCtxt, TypeFlags}; +use crate::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable}; +use crate::ty::{self, Ty, TyCtxt, TypeFlags, TypeVisitableExt}; pub(super) fn provide(providers: &mut ty::query::Providers) { *providers = ty::query::Providers { erase_regions_ty, ..*providers }; @@ -17,7 +17,7 @@ impl<'tcx> TyCtxt<'tcx> { /// subtyping, but they are anonymized and normalized as well).. pub fn erase_regions(self, value: T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { // If there's nothing to erase avoid performing the query at all if !value.has_type_flags(TypeFlags::HAS_LATE_BOUND | TypeFlags::HAS_FREE_REGIONS) { @@ -45,7 +45,7 @@ impl<'tcx> TypeFolder> for RegionEraserVisitor<'tcx> { fn fold_binder(&mut self, t: ty::Binder<'tcx, T>) -> ty::Binder<'tcx, T> where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { let u = self.tcx.anonymize_bound_vars(t); u.super_fold_with(self) diff --git a/compiler/rustc_middle/src/ty/fast_reject.rs b/compiler/rustc_middle/src/ty/fast_reject.rs index 106ce9990e1ed..59deade0a0714 100644 --- a/compiler/rustc_middle/src/ty/fast_reject.rs +++ b/compiler/rustc_middle/src/ty/fast_reject.rs @@ -1,6 +1,6 @@ use crate::mir::Mutability; use crate::ty::subst::GenericArgKind; -use crate::ty::{self, Ty, TyCtxt, TypeVisitable}; +use crate::ty::{self, Ty, TyCtxt, TypeVisitableExt}; use rustc_hir::def_id::DefId; use std::fmt::Debug; use std::hash::Hash; diff --git a/compiler/rustc_middle/src/ty/fold.rs b/compiler/rustc_middle/src/ty/fold.rs index ee36e60bff15e..e8a73832ce4c0 100644 --- a/compiler/rustc_middle/src/ty/fold.rs +++ b/compiler/rustc_middle/src/ty/fold.rs @@ -1,19 +1,10 @@ -use crate::ty::{self, Binder, BoundTy, Ty, TyCtxt, TypeVisitable}; +use crate::ty::{self, Binder, BoundTy, Ty, TyCtxt, TypeVisitableExt}; use rustc_data_structures::fx::FxIndexMap; use rustc_hir::def_id::DefId; use std::collections::BTreeMap; -pub trait TypeFoldable<'tcx> = ir::TypeFoldable> + TypeVisitable<'tcx>; -pub trait TypeSuperFoldable<'tcx> = ir::TypeSuperFoldable>; -pub trait TypeFolder<'tcx> = ir::TypeFolder>; -pub trait FallibleTypeFolder<'tcx> = ir::FallibleTypeFolder>; - -pub mod ir { - pub use rustc_type_ir::fold::{ - FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable, - }; -} +pub use rustc_type_ir::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable}; /////////////////////////////////////////////////////////////////////////// // Some sample folders @@ -30,7 +21,7 @@ where pub ct_op: H, } -impl<'tcx, F, G, H> ir::TypeFolder> for BottomUpFolder<'tcx, F, G, H> +impl<'tcx, F, G, H> TypeFolder> for BottomUpFolder<'tcx, F, G, H> where F: FnMut(Ty<'tcx>) -> Ty<'tcx>, G: FnMut(ty::Region<'tcx>) -> ty::Region<'tcx>, @@ -69,7 +60,7 @@ impl<'tcx> TyCtxt<'tcx> { mut f: impl FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx>, ) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { value.fold_with(&mut RegionFolder::new(self, &mut f)) } @@ -80,7 +71,7 @@ impl<'tcx> TyCtxt<'tcx> { mut f: impl FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx>, ) -> T where - T: TypeSuperFoldable<'tcx>, + T: TypeSuperFoldable>, { value.super_fold_with(&mut RegionFolder::new(self, &mut f)) } @@ -120,12 +111,12 @@ impl<'a, 'tcx> RegionFolder<'a, 'tcx> { } } -impl<'a, 'tcx> ir::TypeFolder> for RegionFolder<'a, 'tcx> { +impl<'a, 'tcx> TypeFolder> for RegionFolder<'a, 'tcx> { fn interner(&self) -> TyCtxt<'tcx> { self.tcx } - fn fold_binder>( + fn fold_binder>>( &mut self, t: ty::Binder<'tcx, T>, ) -> ty::Binder<'tcx, T> { @@ -194,7 +185,7 @@ impl<'tcx, D: BoundVarReplacerDelegate<'tcx>> BoundVarReplacer<'tcx, D> { } } -impl<'tcx, D> ir::TypeFolder> for BoundVarReplacer<'tcx, D> +impl<'tcx, D> TypeFolder> for BoundVarReplacer<'tcx, D> where D: BoundVarReplacerDelegate<'tcx>, { @@ -202,7 +193,7 @@ where self.tcx } - fn fold_binder>( + fn fold_binder>>( &mut self, t: ty::Binder<'tcx, T>, ) -> ty::Binder<'tcx, T> { @@ -280,7 +271,7 @@ impl<'tcx> TyCtxt<'tcx> { ) -> (T, BTreeMap>) where F: FnMut(ty::BoundRegion) -> ty::Region<'tcx>, - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { let mut region_map = BTreeMap::new(); let real_fld_r = |br: ty::BoundRegion| *region_map.entry(br).or_insert_with(|| fld_r(br)); @@ -295,7 +286,7 @@ impl<'tcx> TyCtxt<'tcx> { ) -> T where F: FnMut(ty::BoundRegion) -> ty::Region<'tcx>, - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { let value = value.skip_binder(); if !value.has_escaping_bound_vars() { @@ -314,7 +305,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Replaces all escaping bound vars. The `fld_r` closure replaces escaping /// bound regions; the `fld_t` closure replaces escaping bound types and the `fld_c` /// closure replaces escaping bound consts. - pub fn replace_escaping_bound_vars_uncached>( + pub fn replace_escaping_bound_vars_uncached>>( self, value: T, delegate: impl BoundVarReplacerDelegate<'tcx>, @@ -330,7 +321,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Replaces all types or regions bound by the given `Binder`. The `fld_r` /// closure replaces bound regions, the `fld_t` closure replaces bound /// types, and `fld_c` replaces bound constants. - pub fn replace_bound_vars_uncached>( + pub fn replace_bound_vars_uncached>>( self, value: Binder<'tcx, T>, delegate: impl BoundVarReplacerDelegate<'tcx>, @@ -346,7 +337,7 @@ impl<'tcx> TyCtxt<'tcx> { value: ty::Binder<'tcx, T>, ) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { self.replace_late_bound_regions_uncached(value, |br| { self.mk_re_free(all_outlive_scope, br.kind) @@ -355,7 +346,7 @@ impl<'tcx> TyCtxt<'tcx> { pub fn shift_bound_var_indices(self, bound_vars: usize, value: T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { let shift_bv = |bv: ty::BoundVar| ty::BoundVar::from_usize(bv.as_usize() + bound_vars); self.replace_escaping_bound_vars_uncached( @@ -381,7 +372,7 @@ impl<'tcx> TyCtxt<'tcx> { /// method lookup and a few other places where precise region relationships are not required. pub fn erase_late_bound_regions(self, value: Binder<'tcx, T>) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { self.replace_late_bound_regions(value, |_| self.lifetimes.re_erased).0 } @@ -389,7 +380,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Anonymize all bound variables in `value`, this is mostly used to improve caching. pub fn anonymize_bound_vars(self, value: Binder<'tcx, T>) -> Binder<'tcx, T> where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { struct Anonymize<'a, 'tcx> { tcx: TyCtxt<'tcx>, @@ -457,12 +448,12 @@ impl<'tcx> Shifter<'tcx> { } } -impl<'tcx> ir::TypeFolder> for Shifter<'tcx> { +impl<'tcx> TypeFolder> for Shifter<'tcx> { fn interner(&self) -> TyCtxt<'tcx> { self.tcx } - fn fold_binder>( + fn fold_binder>>( &mut self, t: ty::Binder<'tcx, T>, ) -> ty::Binder<'tcx, T> { @@ -525,7 +516,7 @@ pub fn shift_region<'tcx>( pub fn shift_vars<'tcx, T>(tcx: TyCtxt<'tcx>, value: T, amount: u32) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { debug!("shift_vars(value={:?}, amount={})", value, amount); diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index c68a344e92c8a..d07fa0e546f34 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -1,7 +1,7 @@ use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags; use crate::ty::print::{FmtPrinter, Printer}; use crate::ty::{self, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable}; -use crate::ty::{EarlyBinder, InternalSubsts, SubstsRef}; +use crate::ty::{EarlyBinder, InternalSubsts, SubstsRef, TypeVisitableExt}; use rustc_errors::ErrorGuaranteed; use rustc_hir::def::Namespace; use rustc_hir::def_id::{CrateNum, DefId}; @@ -589,7 +589,7 @@ impl<'tcx> Instance<'tcx> { pub fn subst_mir(&self, tcx: TyCtxt<'tcx>, v: &T) -> T where - T: TypeFoldable<'tcx> + Copy, + T: TypeFoldable> + Copy, { if let Some(substs) = self.substs_for_mir_body() { EarlyBinder(*v).subst(tcx, substs) @@ -606,7 +606,7 @@ impl<'tcx> Instance<'tcx> { v: T, ) -> T where - T: TypeFoldable<'tcx> + Clone, + T: TypeFoldable> + Clone, { if let Some(substs) = self.substs_for_mir_body() { tcx.subst_and_normalize_erasing_regions(substs, param_env, v) @@ -623,7 +623,7 @@ impl<'tcx> Instance<'tcx> { v: T, ) -> Result> where - T: TypeFoldable<'tcx> + Clone, + T: TypeFoldable> + Clone, { if let Some(substs) = self.substs_for_mir_body() { tcx.try_subst_and_normalize_erasing_regions(substs, param_env, v) @@ -674,7 +674,7 @@ fn polymorphize<'tcx>( tcx: TyCtxt<'tcx>, } - impl<'tcx> ty::ir::TypeFolder> for PolymorphizationFolder<'tcx> { + impl<'tcx> ty::TypeFolder> for PolymorphizationFolder<'tcx> { fn interner(&self) -> TyCtxt<'tcx> { self.tcx } diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 993191ee96a44..39a3e8ad54d9b 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -1,6 +1,6 @@ use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags; use crate::ty::normalize_erasing_regions::NormalizationError; -use crate::ty::{self, ReprOptions, Ty, TyCtxt, TypeVisitable}; +use crate::ty::{self, ReprOptions, Ty, TyCtxt, TypeVisitableExt}; use rustc_errors::{DiagnosticBuilder, Handler, IntoDiagnostic}; use rustc_hir as hir; use rustc_hir::def_id::DefId; @@ -1120,13 +1120,6 @@ impl From for FnAbiError<'_> { impl<'tcx> fmt::Display for FnAbiError<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - #[cfg(bootstrap)] - match self { - Self::Layout(err) => fmt::Display::fmt(err, f), - Self::AdjustForForeignAbi(err) => fmt::Display::fmt(err, f), - } - - #[cfg(not(bootstrap))] match self { Self::Layout(err) => err.fmt(f), Self::AdjustForForeignAbi(err) => err.fmt(f), diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index f61fe707ac934..7dcc3ff4e7b33 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -12,7 +12,7 @@ #![allow(rustc::usage_of_ty_tykind)] pub use self::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable}; -pub use self::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor}; +pub use self::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor}; pub use self::AssocItemContainer::*; pub use self::BorrowKind::*; pub use self::IntVarValue::*; @@ -145,10 +145,6 @@ mod structural_impls; mod sty; mod typeck_results; -pub mod ir { - pub use super::{fold::ir::*, visit::ir::*}; -} - // Data types pub type RegisteredTools = FxHashSet; @@ -921,14 +917,17 @@ impl<'a, 'tcx> HashStable> for Term<'tcx> { } } -impl<'tcx> ir::TypeFoldable> for Term<'tcx> { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for Term<'tcx> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { Ok(self.unpack().try_fold_with(folder)?.pack()) } } -impl<'tcx> ir::TypeVisitable> for Term<'tcx> { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeVisitable> for Term<'tcx> { + fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { self.unpack().visit_with(visitor) } } @@ -1626,8 +1625,8 @@ impl<'a, 'tcx> HashStable> for ParamEnv<'tcx> { } } -impl<'tcx> ir::TypeFoldable> for ParamEnv<'tcx> { - fn try_fold_with>( +impl<'tcx> TypeFoldable> for ParamEnv<'tcx> { + fn try_fold_with>>( self, folder: &mut F, ) -> Result { @@ -1639,8 +1638,8 @@ impl<'tcx> ir::TypeFoldable> for ParamEnv<'tcx> { } } -impl<'tcx> ir::TypeVisitable> for ParamEnv<'tcx> { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeVisitable> for ParamEnv<'tcx> { + fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { self.caller_bounds().visit_with(visitor)?; self.reveal().visit_with(visitor) } @@ -1765,7 +1764,7 @@ impl<'tcx> ParamEnv<'tcx> { /// `where Box: Copy`, which are clearly never /// satisfiable. We generally want to behave as if they were true, /// although the surrounding function is never reachable. - pub fn and>(self, value: T) -> ParamEnvAnd<'tcx, T> { + pub fn and>>(self, value: T) -> ParamEnvAnd<'tcx, T> { match self.reveal() { Reveal::UserFacing => ParamEnvAnd { param_env: self, value }, diff --git a/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs b/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs index 825e5fbe232fc..57c8f3075b001 100644 --- a/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs +++ b/compiler/rustc_middle/src/ty/normalize_erasing_regions.rs @@ -9,11 +9,8 @@ use crate::mir; use crate::traits::query::NoSolution; -use crate::ty::fold::{ - ir::{FallibleTypeFolder, TypeFolder}, - TypeFoldable, -}; -use crate::ty::{self, EarlyBinder, SubstsRef, Ty, TyCtxt}; +use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder}; +use crate::ty::{self, EarlyBinder, SubstsRef, Ty, TyCtxt, TypeVisitableExt}; #[derive(Debug, Copy, Clone, HashStable, TyEncodable, TyDecodable)] pub enum NormalizationError<'tcx> { @@ -41,7 +38,7 @@ impl<'tcx> TyCtxt<'tcx> { #[tracing::instrument(level = "debug", skip(self, param_env))] pub fn normalize_erasing_regions(self, param_env: ty::ParamEnv<'tcx>, value: T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { debug!( "normalize_erasing_regions::<{}>(value={:?}, param_env={:?})", @@ -73,7 +70,7 @@ impl<'tcx> TyCtxt<'tcx> { value: T, ) -> Result> where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { debug!( "try_normalize_erasing_regions::<{}>(value={:?}, param_env={:?})", @@ -110,7 +107,7 @@ impl<'tcx> TyCtxt<'tcx> { value: ty::Binder<'tcx, T>, ) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { let value = self.erase_late_bound_regions(value); self.normalize_erasing_regions(param_env, value) @@ -130,7 +127,7 @@ impl<'tcx> TyCtxt<'tcx> { value: ty::Binder<'tcx, T>, ) -> Result> where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { let value = self.erase_late_bound_regions(value); self.try_normalize_erasing_regions(param_env, value) @@ -148,7 +145,7 @@ impl<'tcx> TyCtxt<'tcx> { value: T, ) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { debug!( "subst_and_normalize_erasing_regions(\ @@ -172,7 +169,7 @@ impl<'tcx> TyCtxt<'tcx> { value: T, ) -> Result> where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { debug!( "subst_and_normalize_erasing_regions(\ diff --git a/compiler/rustc_middle/src/ty/opaque_types.rs b/compiler/rustc_middle/src/ty/opaque_types.rs index 8aeef4684b38e..195bd8a381809 100644 --- a/compiler/rustc_middle/src/ty/opaque_types.rs +++ b/compiler/rustc_middle/src/ty/opaque_types.rs @@ -1,9 +1,7 @@ use crate::error::ConstNotUsedTraitAlias; -use crate::ty::fold::{ir::TypeFolder, TypeSuperFoldable}; +use crate::ty::fold::{TypeFolder, TypeSuperFoldable}; use crate::ty::subst::{GenericArg, GenericArgKind}; -#[cfg(not(bootstrap))] -use crate::ty::TypeFoldable; -use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc_data_structures::fx::FxHashMap; use rustc_span::def_id::DefId; use rustc_span::Span; diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index a101127104de8..6a053c368d8ec 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -1,7 +1,7 @@ use crate::mir::interpret::{AllocRange, GlobalAlloc, Pointer, Provenance, Scalar}; use crate::ty::{ self, ConstInt, DefIdTree, ParamConst, ScalarInt, Term, TermKind, Ty, TyCtxt, TypeFoldable, - TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, + TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, }; use crate::ty::{GenericArg, GenericArgKind}; use rustc_apfloat::ieee::{Double, Single}; @@ -225,7 +225,7 @@ pub trait PrettyPrinter<'tcx>: fn in_binder(self, value: &ty::Binder<'tcx, T>) -> Result where - T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx>, + T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable>, { value.as_ref().skip_binder().print(self) } @@ -236,7 +236,7 @@ pub trait PrettyPrinter<'tcx>: f: F, ) -> Result where - T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx>, + T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable>, { f(value.as_ref().skip_binder(), self) } @@ -2033,7 +2033,7 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> { fn in_binder(self, value: &ty::Binder<'tcx, T>) -> Result where - T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx>, + T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable>, { self.pretty_in_binder(value) } @@ -2044,7 +2044,7 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> { f: C, ) -> Result where - T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx>, + T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable>, { self.pretty_wrap_binder(value, f) } @@ -2224,12 +2224,12 @@ struct RegionFolder<'a, 'tcx> { ), } -impl<'a, 'tcx> ty::ir::TypeFolder> for RegionFolder<'a, 'tcx> { +impl<'a, 'tcx> ty::TypeFolder> for RegionFolder<'a, 'tcx> { fn interner(&self) -> TyCtxt<'tcx> { self.tcx } - fn fold_binder>( + fn fold_binder>>( &mut self, t: ty::Binder<'tcx, T>, ) -> ty::Binder<'tcx, T> { @@ -2289,7 +2289,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { value: &ty::Binder<'tcx, T>, ) -> Result<(Self, T, BTreeMap>), fmt::Error> where - T: Print<'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable<'tcx>, + T: Print<'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable>, { fn name_by_region_index( index: usize, @@ -2452,7 +2452,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { pub fn pretty_in_binder(self, value: &ty::Binder<'tcx, T>) -> Result where - T: Print<'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable<'tcx>, + T: Print<'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable>, { let old_region_index = self.region_index; let (new, new_value, _) = self.name_all_regions(value)?; @@ -2468,7 +2468,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { f: C, ) -> Result where - T: Print<'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable<'tcx>, + T: Print<'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable>, { let old_region_index = self.region_index; let (new, new_value, _) = self.name_all_regions(value)?; @@ -2480,7 +2480,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { fn prepare_region_info(&mut self, value: &ty::Binder<'tcx, T>) where - T: TypeVisitable<'tcx>, + T: TypeVisitable>, { struct RegionNameCollector<'tcx> { used_region_names: FxHashSet, @@ -2496,7 +2496,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { } } - impl<'tcx> ty::visit::ir::TypeVisitor> for RegionNameCollector<'tcx> { + impl<'tcx> ty::visit::TypeVisitor> for RegionNameCollector<'tcx> { type BreakTy = (); fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow { @@ -2533,7 +2533,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> { impl<'tcx, T, P: PrettyPrinter<'tcx>> Print<'tcx, P> for ty::Binder<'tcx, T> where - T: Print<'tcx, P, Output = P, Error = P::Error> + TypeFoldable<'tcx>, + T: Print<'tcx, P, Output = P, Error = P::Error> + TypeFoldable>, { type Output = P; type Error = P::Error; diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs index 2ba25e8bfadc9..3dfa5e953b5c7 100644 --- a/compiler/rustc_middle/src/ty/relate.rs +++ b/compiler/rustc_middle/src/ty/relate.rs @@ -105,7 +105,7 @@ pub trait TypeRelation<'tcx>: Sized { T: Relate<'tcx>; } -pub trait Relate<'tcx>: TypeFoldable<'tcx> + PartialEq + Copy { +pub trait Relate<'tcx>: TypeFoldable> + PartialEq + Copy { fn relate>( relation: &mut R, a: Self, diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 573105fd8c007..fbe5d8ccff570 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -5,10 +5,10 @@ use crate::mir::interpret; use crate::mir::{Field, ProjectionKind}; -use crate::ty::fold::{ir::TypeSuperFoldable, FallibleTypeFolder, TypeFoldable}; +use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable}; use crate::ty::print::{with_no_trimmed_paths, FmtPrinter, Printer}; -use crate::ty::visit::{ir::TypeSuperVisitable, TypeVisitable, TypeVisitor}; -use crate::ty::{self, ir, AliasTy, InferConst, Lift, Term, TermKind, Ty, TyCtxt}; +use crate::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor}; +use crate::ty::{self, AliasTy, InferConst, Lift, Term, TermKind, Ty, TyCtxt}; use rustc_hir::def::Namespace; use rustc_index::vec::{Idx, IndexVec}; use rustc_target::abi::TyAndLayout; @@ -372,32 +372,41 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ParamEnv<'a> { // Traversal implementations. /// AdtDefs are basically the same as a DefId. -impl<'tcx> ir::TypeFoldable> for ty::AdtDef<'tcx> { - fn try_fold_with>(self, _folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for ty::AdtDef<'tcx> { + fn try_fold_with>>( + self, + _folder: &mut F, + ) -> Result { Ok(self) } } -impl<'tcx> ir::TypeVisitable> for ty::AdtDef<'tcx> { - fn visit_with>(&self, _visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeVisitable> for ty::AdtDef<'tcx> { + fn visit_with>>( + &self, + _visitor: &mut V, + ) -> ControlFlow { ControlFlow::Continue(()) } } -impl<'tcx, T: TypeFoldable<'tcx>> ir::TypeFoldable> for ty::Binder<'tcx, T> { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx, T: TypeFoldable>> TypeFoldable> for ty::Binder<'tcx, T> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { folder.try_fold_binder(self) } } -impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable> for ty::Binder<'tcx, T> { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx, T: TypeVisitable>> TypeVisitable> for ty::Binder<'tcx, T> { + fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { visitor.visit_binder(self) } } -impl<'tcx, T: TypeFoldable<'tcx>> TypeSuperFoldable> for ty::Binder<'tcx, T> { - fn try_super_fold_with>( +impl<'tcx, T: TypeFoldable>> TypeSuperFoldable> for ty::Binder<'tcx, T> { + fn try_super_fold_with>>( self, folder: &mut F, ) -> Result { @@ -405,44 +414,61 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeSuperFoldable> for ty::Binder } } -impl<'tcx, T: TypeVisitable<'tcx>> TypeSuperVisitable> for ty::Binder<'tcx, T> { - fn super_visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx, T: TypeVisitable>> TypeSuperVisitable> + for ty::Binder<'tcx, T> +{ + fn super_visit_with>>( + &self, + visitor: &mut V, + ) -> ControlFlow { self.as_ref().skip_binder().visit_with(visitor) } } -impl<'tcx> ir::TypeFoldable> for &'tcx ty::List> { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for &'tcx ty::List> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { ty::util::fold_list(self, folder, |tcx, v| tcx.intern_poly_existential_predicates(v)) } } -impl<'tcx> ir::TypeFoldable> for &'tcx ty::List> { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for &'tcx ty::List> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { ty::util::fold_list(self, folder, |tcx, v| tcx.intern_const_list(v)) } } -impl<'tcx> ir::TypeFoldable> for &'tcx ty::List { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for &'tcx ty::List { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { ty::util::fold_list(self, folder, |tcx, v| tcx.intern_projs(v)) } } -impl<'tcx> ir::TypeFoldable> for Ty<'tcx> { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for Ty<'tcx> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { folder.try_fold_ty(self) } } -impl<'tcx> ir::TypeVisitable> for Ty<'tcx> { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeVisitable> for Ty<'tcx> { + fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { visitor.visit_ty(*self) } } impl<'tcx> TypeSuperFoldable> for Ty<'tcx> { - fn try_super_fold_with>( + fn try_super_fold_with>>( self, folder: &mut F, ) -> Result { @@ -492,7 +518,10 @@ impl<'tcx> TypeSuperFoldable> for Ty<'tcx> { } impl<'tcx> TypeSuperVisitable> for Ty<'tcx> { - fn super_visit_with>(&self, visitor: &mut V) -> ControlFlow { + fn super_visit_with>>( + &self, + visitor: &mut V, + ) -> ControlFlow { match self.kind() { ty::RawPtr(ref tm) => tm.visit_with(visitor), ty::Array(typ, sz) => { @@ -535,20 +564,23 @@ impl<'tcx> TypeSuperVisitable> for Ty<'tcx> { } } -impl<'tcx> ir::TypeFoldable> for ty::Region<'tcx> { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for ty::Region<'tcx> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { folder.try_fold_region(self) } } -impl<'tcx> ir::TypeVisitable> for ty::Region<'tcx> { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeVisitable> for ty::Region<'tcx> { + fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { visitor.visit_region(*self) } } impl<'tcx> TypeSuperFoldable> for ty::Region<'tcx> { - fn try_super_fold_with>( + fn try_super_fold_with>>( self, _folder: &mut F, ) -> Result { @@ -557,25 +589,31 @@ impl<'tcx> TypeSuperFoldable> for ty::Region<'tcx> { } impl<'tcx> TypeSuperVisitable> for ty::Region<'tcx> { - fn super_visit_with>(&self, _visitor: &mut V) -> ControlFlow { + fn super_visit_with>>( + &self, + _visitor: &mut V, + ) -> ControlFlow { ControlFlow::Continue(()) } } -impl<'tcx> ir::TypeFoldable> for ty::Predicate<'tcx> { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for ty::Predicate<'tcx> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { folder.try_fold_predicate(self) } } -impl<'tcx> ir::TypeVisitable> for ty::Predicate<'tcx> { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeVisitable> for ty::Predicate<'tcx> { + fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { visitor.visit_predicate(*self) } } impl<'tcx> TypeSuperFoldable> for ty::Predicate<'tcx> { - fn try_super_fold_with>( + fn try_super_fold_with>>( self, folder: &mut F, ) -> Result { @@ -585,31 +623,40 @@ impl<'tcx> TypeSuperFoldable> for ty::Predicate<'tcx> { } impl<'tcx> TypeSuperVisitable> for ty::Predicate<'tcx> { - fn super_visit_with>(&self, visitor: &mut V) -> ControlFlow { + fn super_visit_with>>( + &self, + visitor: &mut V, + ) -> ControlFlow { self.kind().visit_with(visitor) } } -impl<'tcx> ir::TypeFoldable> for &'tcx ty::List> { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for &'tcx ty::List> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { ty::util::fold_list(self, folder, |tcx, v| tcx.intern_predicates(v)) } } -impl<'tcx> ir::TypeFoldable> for ty::Const<'tcx> { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for ty::Const<'tcx> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { folder.try_fold_const(self) } } -impl<'tcx> ir::TypeVisitable> for ty::Const<'tcx> { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeVisitable> for ty::Const<'tcx> { + fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { visitor.visit_const(*self) } } impl<'tcx> TypeSuperFoldable> for ty::Const<'tcx> { - fn try_super_fold_with>( + fn try_super_fold_with>>( self, folder: &mut F, ) -> Result { @@ -624,32 +671,44 @@ impl<'tcx> TypeSuperFoldable> for ty::Const<'tcx> { } impl<'tcx> TypeSuperVisitable> for ty::Const<'tcx> { - fn super_visit_with>(&self, visitor: &mut V) -> ControlFlow { + fn super_visit_with>>( + &self, + visitor: &mut V, + ) -> ControlFlow { self.ty().visit_with(visitor)?; self.kind().visit_with(visitor) } } -impl<'tcx> ir::TypeFoldable> for InferConst<'tcx> { - fn try_fold_with>(self, _folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for InferConst<'tcx> { + fn try_fold_with>>( + self, + _folder: &mut F, + ) -> Result { Ok(self) } } -impl<'tcx> ir::TypeVisitable> for InferConst<'tcx> { - fn visit_with>(&self, _visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeVisitable> for InferConst<'tcx> { + fn visit_with>>( + &self, + _visitor: &mut V, + ) -> ControlFlow { ControlFlow::Continue(()) } } impl<'tcx> TypeSuperVisitable> for ty::UnevaluatedConst<'tcx> { - fn super_visit_with>(&self, visitor: &mut V) -> ControlFlow { + fn super_visit_with>>( + &self, + visitor: &mut V, + ) -> ControlFlow { self.substs.visit_with(visitor) } } -impl<'tcx> ir::TypeVisitable> for TyAndLayout<'tcx, Ty<'tcx>> { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeVisitable> for TyAndLayout<'tcx, Ty<'tcx>> { + fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { visitor.visit_ty(self.ty) } } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 35ff71d888501..7563656f91bbf 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -7,10 +7,8 @@ use crate::ty::subst::{GenericArg, InternalSubsts, SubstsRef}; use crate::ty::visit::ValidateBoundVars; use crate::ty::InferTy::*; use crate::ty::{ - self, - ir::{FallibleTypeFolder, TypeVisitor}, - AdtDef, DefIdTree, Discr, Term, Ty, TyCtxt, TypeFlags, TypeFoldable, TypeSuperFoldable, - TypeSuperVisitable, TypeVisitable, + self, AdtDef, DefIdTree, Discr, FallibleTypeFolder, Term, Ty, TyCtxt, TypeFlags, TypeFoldable, + TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, }; use crate::ty::{List, ParamEnv}; use hir::def::DefKind; @@ -985,7 +983,7 @@ pub struct Binder<'tcx, T>(T, &'tcx List); impl<'tcx, T> Binder<'tcx, T> where - T: TypeVisitable<'tcx>, + T: TypeVisitable>, { /// Wraps `value` in a binder, asserting that `value` does not /// contain any bound vars that would be bound by the @@ -1053,14 +1051,14 @@ impl<'tcx, T> Binder<'tcx, T> { Binder(value, self.1) } - pub fn map_bound_ref>(&self, f: F) -> Binder<'tcx, U> + pub fn map_bound_ref>>(&self, f: F) -> Binder<'tcx, U> where F: FnOnce(&T) -> U, { self.as_ref().map_bound(f) } - pub fn map_bound>(self, f: F) -> Binder<'tcx, U> + pub fn map_bound>>(self, f: F) -> Binder<'tcx, U> where F: FnOnce(T) -> U, { @@ -1072,7 +1070,10 @@ impl<'tcx, T> Binder<'tcx, T> { Binder(value, self.1) } - pub fn try_map_bound, E>(self, f: F) -> Result, E> + pub fn try_map_bound>, E>( + self, + f: F, + ) -> Result, E> where F: FnOnce(T) -> Result, { @@ -1095,7 +1096,7 @@ impl<'tcx, T> Binder<'tcx, T> { /// in `bind`. This may be (debug) asserted in the future. pub fn rebind(&self, value: U) -> Binder<'tcx, U> where - U: TypeVisitable<'tcx>, + U: TypeVisitable>, { if cfg!(debug_assertions) { let mut validator = ValidateBoundVars::new(self.bound_vars()); @@ -1116,7 +1117,7 @@ impl<'tcx, T> Binder<'tcx, T> { /// would not be that useful.) pub fn no_bound_vars(self) -> Option where - T: TypeVisitable<'tcx>, + T: TypeVisitable>, { if self.0.has_escaping_bound_vars() { None } else { Some(self.skip_binder()) } } @@ -1164,7 +1165,7 @@ impl<'tcx> FallibleTypeFolder> for SkipBindersAt<'tcx> { fn try_fold_binder(&mut self, t: Binder<'tcx, T>) -> Result, Self::Error> where - T: ty::TypeFoldable<'tcx>, + T: ty::TypeFoldable>, { self.index.shift_in(1); let value = t.try_map_bound(|t| t.try_fold_with(self)); diff --git a/compiler/rustc_middle/src/ty/subst.rs b/compiler/rustc_middle/src/ty/subst.rs index 6b4a6a17aef5f..1ed3ef5745b6f 100644 --- a/compiler/rustc_middle/src/ty/subst.rs +++ b/compiler/rustc_middle/src/ty/subst.rs @@ -1,10 +1,10 @@ // Type substitutions. use crate::ty::codec::{TyDecoder, TyEncoder}; -use crate::ty::fold::{ir::TypeFolder, FallibleTypeFolder, TypeFoldable, TypeSuperFoldable}; +use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeSuperFoldable}; use crate::ty::sty::{ClosureSubsts, GeneratorSubsts, InlineConstSubsts}; -use crate::ty::visit::{TypeVisitable, TypeVisitor}; -use crate::ty::{self, ir, Lift, List, ParamConst, Ty, TyCtxt}; +use crate::ty::visit::{TypeVisitable, TypeVisitableExt, TypeVisitor}; +use crate::ty::{self, Lift, List, ParamConst, Ty, TyCtxt}; use rustc_data_structures::intern::Interned; use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg}; @@ -227,8 +227,11 @@ impl<'a, 'tcx> Lift<'tcx> for GenericArg<'a> { } } -impl<'tcx> ir::TypeFoldable> for GenericArg<'tcx> { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for GenericArg<'tcx> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { match self.unpack() { GenericArgKind::Lifetime(lt) => lt.try_fold_with(folder).map(Into::into), GenericArgKind::Type(ty) => ty.try_fold_with(folder).map(Into::into), @@ -237,8 +240,8 @@ impl<'tcx> ir::TypeFoldable> for GenericArg<'tcx> { } } -impl<'tcx> ir::TypeVisitable> for GenericArg<'tcx> { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeVisitable> for GenericArg<'tcx> { + fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { match self.unpack() { GenericArgKind::Lifetime(lt) => lt.visit_with(visitor), GenericArgKind::Type(ty) => ty.visit_with(visitor), @@ -473,8 +476,11 @@ impl<'tcx> InternalSubsts<'tcx> { } } -impl<'tcx> ir::TypeFoldable> for SubstsRef<'tcx> { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for SubstsRef<'tcx> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { // This code is hot enough that it's worth specializing for the most // common length lists, to avoid the overhead of `SmallVec` creation. // The match arms are in order of frequency. The 1, 2, and 0 cases are @@ -505,8 +511,11 @@ impl<'tcx> ir::TypeFoldable> for SubstsRef<'tcx> { } } -impl<'tcx> ir::TypeFoldable> for &'tcx ty::List> { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for &'tcx ty::List> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { // This code is fairly hot, though not as hot as `SubstsRef`. // // When compiling stage 2, I get the following results: @@ -537,9 +546,9 @@ impl<'tcx> ir::TypeFoldable> for &'tcx ty::List> { } } -impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable> for &'tcx ty::List { +impl<'tcx, T: TypeVisitable>> TypeVisitable> for &'tcx ty::List { #[inline] - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { + fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { self.iter().try_for_each(|t| t.visit_with(visitor)) } } @@ -555,8 +564,8 @@ impl<'tcx, T: TypeVisitable<'tcx>> ir::TypeVisitable> for &'tcx ty: pub struct EarlyBinder(pub T); /// For early binders, you should first call `subst` before using any visitors. -impl<'tcx, T> !ir::TypeFoldable> for ty::EarlyBinder {} -impl<'tcx, T> !ir::TypeVisitable> for ty::EarlyBinder {} +impl<'tcx, T> !TypeFoldable> for ty::EarlyBinder {} +impl<'tcx, T> !TypeVisitable> for ty::EarlyBinder {} impl EarlyBinder { pub fn as_ref(&self) -> EarlyBinder<&T> { @@ -617,7 +626,7 @@ impl EarlyBinder<(T, U)> { impl<'tcx, 's, I: IntoIterator> EarlyBinder where - I::Item: TypeFoldable<'tcx>, + I::Item: TypeFoldable>, { pub fn subst_iter( self, @@ -636,7 +645,7 @@ pub struct SubstIter<'s, 'tcx, I: IntoIterator> { impl<'tcx, I: IntoIterator> Iterator for SubstIter<'_, 'tcx, I> where - I::Item: TypeFoldable<'tcx>, + I::Item: TypeFoldable>, { type Item = I::Item; @@ -652,7 +661,7 @@ where impl<'tcx, I: IntoIterator> DoubleEndedIterator for SubstIter<'_, 'tcx, I> where I::IntoIter: DoubleEndedIterator, - I::Item: TypeFoldable<'tcx>, + I::Item: TypeFoldable>, { fn next_back(&mut self) -> Option { Some(EarlyBinder(self.it.next_back()?).subst(self.tcx, self.substs)) @@ -662,14 +671,14 @@ where impl<'tcx, I: IntoIterator> ExactSizeIterator for SubstIter<'_, 'tcx, I> where I::IntoIter: ExactSizeIterator, - I::Item: TypeFoldable<'tcx>, + I::Item: TypeFoldable>, { } impl<'tcx, 's, I: IntoIterator> EarlyBinder where I::Item: Deref, - ::Target: Copy + TypeFoldable<'tcx>, + ::Target: Copy + TypeFoldable>, { pub fn subst_iter_copied( self, @@ -689,7 +698,7 @@ pub struct SubstIterCopied<'a, 'tcx, I: IntoIterator> { impl<'tcx, I: IntoIterator> Iterator for SubstIterCopied<'_, 'tcx, I> where I::Item: Deref, - ::Target: Copy + TypeFoldable<'tcx>, + ::Target: Copy + TypeFoldable>, { type Item = ::Target; @@ -706,7 +715,7 @@ impl<'tcx, I: IntoIterator> DoubleEndedIterator for SubstIterCopied<'_, 'tcx, I> where I::IntoIter: DoubleEndedIterator, I::Item: Deref, - ::Target: Copy + TypeFoldable<'tcx>, + ::Target: Copy + TypeFoldable>, { fn next_back(&mut self) -> Option { Some(EarlyBinder(*self.it.next_back()?).subst(self.tcx, self.substs)) @@ -717,7 +726,7 @@ impl<'tcx, I: IntoIterator> ExactSizeIterator for SubstIterCopied<'_, 'tcx, I> where I::IntoIter: ExactSizeIterator, I::Item: Deref, - ::Target: Copy + TypeFoldable<'tcx>, + ::Target: Copy + TypeFoldable>, { } @@ -743,7 +752,7 @@ impl Iterator for EarlyBinderIter { } } -impl<'tcx, T: TypeFoldable<'tcx>> ty::EarlyBinder { +impl<'tcx, T: TypeFoldable>> ty::EarlyBinder { pub fn subst(self, tcx: TyCtxt<'tcx>, substs: &[GenericArg<'tcx>]) -> T { let mut folder = SubstFolder { tcx, substs, binders_passed: 0 }; self.0.fold_with(&mut folder) @@ -784,7 +793,7 @@ impl<'a, 'tcx> TypeFolder> for SubstFolder<'a, 'tcx> { self.tcx } - fn fold_binder>( + fn fold_binder>>( &mut self, t: ty::Binder<'tcx, T>, ) -> ty::Binder<'tcx, T> { @@ -977,7 +986,7 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> { /// As indicated in the diagram, here the same type `&'a i32` is substituted once, but in the /// first case we do not increase the De Bruijn index and in the second case we do. The reason /// is that only in the second case have we passed through a fn binder. - fn shift_vars_through_binders>(&self, val: T) -> T { + fn shift_vars_through_binders>>(&self, val: T) -> T { debug!( "shift_vars(val={:?}, binders_passed={:?}, has_escaping_bound_vars={:?})", val, diff --git a/compiler/rustc_middle/src/ty/trait_def.rs b/compiler/rustc_middle/src/ty/trait_def.rs index a4a82bf247d03..233c0df2d3c77 100644 --- a/compiler/rustc_middle/src/ty/trait_def.rs +++ b/compiler/rustc_middle/src/ty/trait_def.rs @@ -1,6 +1,6 @@ use crate::traits::specialization_graph; use crate::ty::fast_reject::{self, SimplifiedType, TreatParams}; -use crate::ty::visit::TypeVisitable; +use crate::ty::visit::TypeVisitableExt; use crate::ty::{Ident, Ty, TyCtxt}; use hir::def_id::LOCAL_CRATE; use rustc_hir as hir; diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index ca46cf29919f8..2ac3adda80b94 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -4,8 +4,8 @@ use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags; use crate::mir; use crate::ty::layout::IntegerExt; use crate::ty::{ - self, ir::TypeFolder, DefIdTree, FallibleTypeFolder, ToPredicate, Ty, TyCtxt, TypeFoldable, - TypeSuperFoldable, + self, DefIdTree, FallibleTypeFolder, ToPredicate, Ty, TyCtxt, TypeFoldable, TypeFolder, + TypeSuperFoldable, TypeVisitableExt, }; use crate::ty::{GenericArgKind, SubstsRef}; use rustc_apfloat::Float as _; @@ -1349,8 +1349,8 @@ pub fn fold_list<'tcx, F, T>( intern: impl FnOnce(TyCtxt<'tcx>, &[T]) -> &'tcx ty::List, ) -> Result<&'tcx ty::List, F::Error> where - F: FallibleTypeFolder<'tcx>, - T: TypeFoldable<'tcx> + PartialEq + Copy, + F: FallibleTypeFolder>, + T: TypeFoldable> + PartialEq + Copy, { let mut iter = list.iter(); // Look for the first element that changed diff --git a/compiler/rustc_middle/src/ty/visit.rs b/compiler/rustc_middle/src/ty/visit.rs index 8a93b59900e15..6814cadb9a8e4 100644 --- a/compiler/rustc_middle/src/ty/visit.rs +++ b/compiler/rustc_middle/src/ty/visit.rs @@ -5,15 +5,9 @@ use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::sso::SsoHashSet; use std::ops::ControlFlow; -pub trait TypeVisitable<'tcx> = ir::TypeVisitable> + TypeVisitableExt<'tcx>; -pub trait TypeSuperVisitable<'tcx> = ir::TypeSuperVisitable>; -pub trait TypeVisitor<'tcx> = ir::TypeVisitor>; +pub use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor}; -pub mod ir { - pub use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor}; -} - -pub trait TypeVisitableExt<'tcx>: ir::TypeVisitable> { +pub trait TypeVisitableExt<'tcx>: TypeVisitable> { /// 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 @@ -135,7 +129,7 @@ pub trait TypeVisitableExt<'tcx>: ir::TypeVisitable> { } } -impl<'tcx, T: ir::TypeVisitable>> TypeVisitableExt<'tcx> for T {} +impl<'tcx, T: TypeVisitable>> TypeVisitableExt<'tcx> for T {} /////////////////////////////////////////////////////////////////////////// // Region folder @@ -144,7 +138,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Invoke `callback` on every region appearing free in `value`. pub fn for_each_free_region( self, - value: &impl TypeVisitable<'tcx>, + value: &impl TypeVisitable>, mut callback: impl FnMut(ty::Region<'tcx>), ) { self.any_free_region_meets(value, |r| { @@ -156,7 +150,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Returns `true` if `callback` returns true for every region appearing free in `value`. pub fn all_free_regions_meet( self, - value: &impl TypeVisitable<'tcx>, + value: &impl TypeVisitable>, mut callback: impl FnMut(ty::Region<'tcx>) -> bool, ) -> bool { !self.any_free_region_meets(value, |r| !callback(r)) @@ -165,7 +159,7 @@ impl<'tcx> TyCtxt<'tcx> { /// Returns `true` if `callback` returns true for some region appearing free in `value`. pub fn any_free_region_meets( self, - value: &impl TypeVisitable<'tcx>, + value: &impl TypeVisitable>, callback: impl FnMut(ty::Region<'tcx>) -> bool, ) -> bool { struct RegionVisitor { @@ -190,13 +184,13 @@ impl<'tcx> TyCtxt<'tcx> { callback: F, } - impl<'tcx, F> ir::TypeVisitor> for RegionVisitor + impl<'tcx, F> TypeVisitor> for RegionVisitor where F: FnMut(ty::Region<'tcx>) -> bool, { type BreakTy = (); - fn visit_binder>( + fn visit_binder>>( &mut self, t: &Binder<'tcx, T>, ) -> ControlFlow { @@ -243,7 +237,7 @@ impl<'tcx> TyCtxt<'tcx> { value: &Binder<'tcx, T>, ) -> FxHashSet where - T: TypeVisitable<'tcx>, + T: TypeVisitable>, { self.collect_late_bound_regions(value, true) } @@ -254,7 +248,7 @@ impl<'tcx> TyCtxt<'tcx> { value: &Binder<'tcx, T>, ) -> FxHashSet where - T: TypeVisitable<'tcx>, + T: TypeVisitable>, { self.collect_late_bound_regions(value, false) } @@ -265,7 +259,7 @@ impl<'tcx> TyCtxt<'tcx> { just_constraint: bool, ) -> FxHashSet where - T: TypeVisitable<'tcx>, + T: TypeVisitable>, { let mut collector = LateBoundRegionsCollector::new(just_constraint); let result = value.as_ref().skip_binder().visit_with(&mut collector); @@ -292,10 +286,10 @@ impl<'tcx> ValidateBoundVars<'tcx> { } } -impl<'tcx> ir::TypeVisitor> for ValidateBoundVars<'tcx> { +impl<'tcx> TypeVisitor> for ValidateBoundVars<'tcx> { type BreakTy = (); - fn visit_binder>( + fn visit_binder>>( &mut self, t: &Binder<'tcx, T>, ) -> ControlFlow { @@ -404,10 +398,10 @@ struct HasEscapingVarsVisitor { outer_index: ty::DebruijnIndex, } -impl<'tcx> ir::TypeVisitor> for HasEscapingVarsVisitor { +impl<'tcx> TypeVisitor> for HasEscapingVarsVisitor { type BreakTy = FoundEscapingVars; - fn visit_binder>( + fn visit_binder>>( &mut self, t: &Binder<'tcx, T>, ) -> ControlFlow { @@ -481,7 +475,7 @@ impl std::fmt::Debug for HasTypeFlagsVisitor { } } -impl<'tcx> ir::TypeVisitor> for HasTypeFlagsVisitor { +impl<'tcx> TypeVisitor> for HasTypeFlagsVisitor { type BreakTy = FoundFlags; #[inline] @@ -551,8 +545,8 @@ impl LateBoundRegionsCollector { } } -impl<'tcx> ir::TypeVisitor> for LateBoundRegionsCollector { - fn visit_binder>( +impl<'tcx> TypeVisitor> for LateBoundRegionsCollector { + fn visit_binder>>( &mut self, t: &Binder<'tcx, T>, ) -> ControlFlow { @@ -613,7 +607,7 @@ impl MaxUniverse { } } -impl<'tcx> ir::TypeVisitor> for MaxUniverse { +impl<'tcx> TypeVisitor> for MaxUniverse { fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { if let ty::Placeholder(placeholder) = t.kind() { self.max_universe = ty::UniverseIndex::from_u32( diff --git a/compiler/rustc_mir_build/src/build/matches/util.rs b/compiler/rustc_mir_build/src/build/matches/util.rs index fbe08a7bd243d..c34105174ef2a 100644 --- a/compiler/rustc_mir_build/src/build/matches/util.rs +++ b/compiler/rustc_mir_build/src/build/matches/util.rs @@ -5,7 +5,7 @@ use crate::build::Builder; use rustc_middle::mir::*; use rustc_middle::thir::*; use rustc_middle::ty; -use rustc_middle::ty::TypeVisitable; +use rustc_middle::ty::TypeVisitableExt; use smallvec::SmallVec; impl<'a, 'tcx> Builder<'a, 'tcx> { diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index 933b1158fa6ea..53bef1eb772ea 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -20,7 +20,7 @@ use rustc_middle::mir::*; use rustc_middle::thir::{ self, BindingMode, Expr, ExprId, LintLevel, LocalVarId, Param, ParamId, PatKind, Thir, }; -use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable, TypeckResults}; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, TypeckResults}; use rustc_span::symbol::sym; use rustc_span::Span; use rustc_span::Symbol; diff --git a/compiler/rustc_mir_transform/src/const_prop.rs b/compiler/rustc_mir_transform/src/const_prop.rs index cff3da720fc5c..6b2eefce24d50 100644 --- a/compiler/rustc_mir_transform/src/const_prop.rs +++ b/compiler/rustc_mir_transform/src/const_prop.rs @@ -16,7 +16,7 @@ use rustc_middle::mir::visit::{ use rustc_middle::mir::*; use rustc_middle::ty::layout::{LayoutError, LayoutOf, LayoutOfHelpers, TyAndLayout}; use rustc_middle::ty::InternalSubsts; -use rustc_middle::ty::{self, ConstKind, Instance, ParamEnv, Ty, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, ConstKind, Instance, ParamEnv, Ty, TyCtxt, TypeVisitableExt}; use rustc_span::{def_id::DefId, Span}; use rustc_target::abi::{self, Align, HasDataLayout, Size, TargetDataLayout}; use rustc_target::spec::abi::Abi as CallAbi; diff --git a/compiler/rustc_mir_transform/src/const_prop_lint.rs b/compiler/rustc_mir_transform/src/const_prop_lint.rs index be41d611fe485..6c1980ff3ad93 100644 --- a/compiler/rustc_mir_transform/src/const_prop_lint.rs +++ b/compiler/rustc_mir_transform/src/const_prop_lint.rs @@ -21,7 +21,9 @@ use rustc_middle::mir::{ }; use rustc_middle::ty::layout::{LayoutError, LayoutOf, LayoutOfHelpers, TyAndLayout}; use rustc_middle::ty::InternalSubsts; -use rustc_middle::ty::{self, ConstInt, Instance, ParamEnv, ScalarInt, Ty, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{ + self, ConstInt, Instance, ParamEnv, ScalarInt, Ty, TyCtxt, TypeVisitableExt, +}; use rustc_session::lint; use rustc_span::Span; use rustc_target::abi::{HasDataLayout, Size, TargetDataLayout}; diff --git a/compiler/rustc_mir_transform/src/inline/cycle.rs b/compiler/rustc_mir_transform/src/inline/cycle.rs index b027f94925d2f..792457c80b0b7 100644 --- a/compiler/rustc_mir_transform/src/inline/cycle.rs +++ b/compiler/rustc_mir_transform/src/inline/cycle.rs @@ -2,7 +2,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_middle::mir::TerminatorKind; -use rustc_middle::ty::TypeVisitable; +use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::{self, subst::SubstsRef, InstanceDef, TyCtxt}; use rustc_session::Limit; diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 45cd4024c9f57..bdd1e8fb98f75 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -35,7 +35,7 @@ use rustc_middle::mir::{ TerminatorKind, }; use rustc_middle::ty::query::Providers; -use rustc_middle::ty::{self, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt}; use rustc_span::sym; #[macro_use] diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index 55a9f912e0858..ff409a8071611 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -189,7 +189,9 @@ use rustc_middle::ty::adjustment::{CustomCoerceUnsized, PointerCast}; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::query::TyCtxtAt; use rustc_middle::ty::subst::{GenericArgKind, InternalSubsts}; -use rustc_middle::ty::{self, GenericParamDefKind, Instance, Ty, TyCtxt, TypeFoldable, VtblEntry}; +use rustc_middle::ty::{ + self, GenericParamDefKind, Instance, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, VtblEntry, +}; use rustc_middle::{middle::codegen_fn_attrs::CodegenFnAttrFlags, mir::visit::TyContext}; use rustc_session::config::EntryFnType; use rustc_session::lint::builtin::LARGE_ASSIGNMENTS; @@ -658,7 +660,7 @@ struct MirNeighborCollector<'a, 'tcx> { impl<'a, 'tcx> MirNeighborCollector<'a, 'tcx> { pub fn monomorphize(&self, value: T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { debug!("monomorphize: self.instance={:?}", self.instance); self.instance.subst_mir_and_normalize_erasing_regions( diff --git a/compiler/rustc_monomorphize/src/partitioning/default.rs b/compiler/rustc_monomorphize/src/partitioning/default.rs index 62bafb981e778..2c56edd89bc31 100644 --- a/compiler/rustc_monomorphize/src/partitioning/default.rs +++ b/compiler/rustc_monomorphize/src/partitioning/default.rs @@ -9,7 +9,7 @@ use rustc_middle::middle::exported_symbols::{SymbolExportInfo, SymbolExportLevel use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, Linkage, Visibility}; use rustc_middle::mir::mono::{InstantiationMode, MonoItem}; use rustc_middle::ty::print::characteristic_def_id_of_type; -use rustc_middle::ty::{self, visit::TypeVisitable, DefIdTree, InstanceDef, TyCtxt}; +use rustc_middle::ty::{self, visit::TypeVisitableExt, DefIdTree, InstanceDef, TyCtxt}; use rustc_span::symbol::Symbol; use super::PartitioningCx; diff --git a/compiler/rustc_monomorphize/src/polymorphize.rs b/compiler/rustc_monomorphize/src/polymorphize.rs index 207ad332c22c2..b7c3dbcc09139 100644 --- a/compiler/rustc_monomorphize/src/polymorphize.rs +++ b/compiler/rustc_monomorphize/src/polymorphize.rs @@ -15,7 +15,7 @@ use rustc_middle::ty::{ self, query::Providers, subst::SubstsRef, - visit::{ir::TypeVisitor, TypeSuperVisitable, TypeVisitable}, + visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor}, Const, Ty, TyCtxt, UnusedGenericParams, }; use rustc_span::symbol::sym; diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 58dfca75c65f7..312c258769b91 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -28,7 +28,7 @@ use rustc_middle::span_bug; use rustc_middle::ty::query::Providers; use rustc_middle::ty::subst::InternalSubsts; use rustc_middle::ty::{self, Const, DefIdTree, GenericParamDefKind}; -use rustc_middle::ty::{ir::TypeVisitor, TraitRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable}; +use rustc_middle::ty::{TraitRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor}; use rustc_session::lint; use rustc_span::hygiene::Transparency; use rustc_span::symbol::{kw, sym, Ident}; @@ -81,7 +81,10 @@ trait DefIdVisitor<'tcx> { dummy: Default::default(), } } - fn visit(&mut self, ty_fragment: impl TypeVisitable<'tcx>) -> ControlFlow { + fn visit( + &mut self, + ty_fragment: impl TypeVisitable>, + ) -> ControlFlow { ty_fragment.visit_with(&mut self.skeleton()) } fn visit_trait(&mut self, trait_ref: TraitRef<'tcx>) -> ControlFlow { diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs index 744e8a4320e30..2368468c89123 100644 --- a/compiler/rustc_symbol_mangling/src/legacy.rs +++ b/compiler/rustc_symbol_mangling/src/legacy.rs @@ -3,7 +3,7 @@ use rustc_hir::def_id::CrateNum; use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData}; use rustc_middle::ty::print::{PrettyPrinter, Print, Printer}; use rustc_middle::ty::subst::{GenericArg, GenericArgKind}; -use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeVisitableExt}; use rustc_middle::util::common::record_time; use std::fmt::{self, Write}; diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index d53f0cea6b54e..2f20d42139c8d 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -8,7 +8,8 @@ use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData}; use rustc_middle::ty::layout::IntegerExt; use rustc_middle::ty::print::{Print, Printer}; use rustc_middle::ty::{ - self, EarlyBinder, FloatTy, Instance, IntTy, Ty, TyCtxt, TypeVisitable, UintTy, + self, EarlyBinder, FloatTy, Instance, IntTy, Ty, TyCtxt, TypeVisitable, TypeVisitableExt, + UintTy, }; use rustc_middle::ty::{GenericArg, GenericArgKind}; use rustc_span::symbol::kw; @@ -204,7 +205,7 @@ impl<'tcx> SymbolMangler<'tcx> { print_value: impl FnOnce(&'a mut Self, &T) -> Result<&'a mut Self, !>, ) -> Result<&'a mut Self, !> where - T: TypeVisitable<'tcx>, + T: TypeVisitable>, { // FIXME(non-lifetime-binders): What to do here? let regions = if value.has_late_bound_regions() { diff --git a/compiler/rustc_trait_selection/src/infer.rs b/compiler/rustc_trait_selection/src/infer.rs index c0bfe152a1e8c..015029b7ac422 100644 --- a/compiler/rustc_trait_selection/src/infer.rs +++ b/compiler/rustc_trait_selection/src/infer.rs @@ -6,7 +6,7 @@ use rustc_hir::lang_items::LangItem; use rustc_middle::arena::ArenaAllocatable; use rustc_middle::infer::canonical::{Canonical, CanonicalQueryResponse, QueryResponse}; use rustc_middle::traits::query::Fallible; -use rustc_middle::ty::{self, Ty, TypeFoldable}; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, TypeVisitableExt}; use rustc_middle::ty::{GenericArg, ToPredicate}; use rustc_span::{Span, DUMMY_SP}; @@ -104,8 +104,8 @@ pub trait InferCtxtBuilderExt<'tcx> { operation: impl FnOnce(&ObligationCtxt<'_, 'tcx>, K) -> Fallible, ) -> Fallible> where - K: TypeFoldable<'tcx>, - R: Debug + TypeFoldable<'tcx>, + K: TypeFoldable>, + R: Debug + TypeFoldable>, Canonical<'tcx, QueryResponse<'tcx, R>>: ArenaAllocatable<'tcx>; } @@ -125,15 +125,15 @@ impl<'tcx> InferCtxtBuilderExt<'tcx> for InferCtxtBuilder<'tcx> { /// In part because we would need a `for<'tcx>` sort of /// bound for the closure and in part because it is convenient to /// have `'tcx` be free on this function so that we can talk about - /// `K: TypeFoldable<'tcx>`.) + /// `K: TypeFoldable>`.) fn enter_canonical_trait_query( &mut self, canonical_key: &Canonical<'tcx, K>, operation: impl FnOnce(&ObligationCtxt<'_, 'tcx>, K) -> Fallible, ) -> Fallible> where - K: TypeFoldable<'tcx>, - R: Debug + TypeFoldable<'tcx>, + K: TypeFoldable>, + R: Debug + TypeFoldable>, Canonical<'tcx, QueryResponse<'tcx, R>>: ArenaAllocatable<'tcx>, { let (infcx, key, canonical_inference_vars) = diff --git a/compiler/rustc_trait_selection/src/solve/assembly.rs b/compiler/rustc_trait_selection/src/solve/assembly.rs index d55aebf1a2696..6172a9539f64d 100644 --- a/compiler/rustc_trait_selection/src/solve/assembly.rs +++ b/compiler/rustc_trait_selection/src/solve/assembly.rs @@ -82,7 +82,7 @@ pub(super) enum CandidateSource { } /// Methods used to assemble candidates for either trait or projection goals. -pub(super) trait GoalKind<'tcx>: TypeFoldable<'tcx> + Copy + Eq { +pub(super) trait GoalKind<'tcx>: TypeFoldable> + Copy + Eq { fn self_ty(self) -> Ty<'tcx>; fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self; diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs index 67addd732d0ad..c8097e81953d9 100644 --- a/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs +++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt.rs @@ -6,7 +6,10 @@ use rustc_infer::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime}; use rustc_infer::traits::query::NoSolution; use rustc_infer::traits::ObligationCause; use rustc_middle::infer::unify_key::{ConstVariableOrigin, ConstVariableOriginKind}; -use rustc_middle::ty::{self, ir::TypeVisitor, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable}; +use rustc_middle::ty::{ + self, Ty, TyCtxt, TypeFoldable, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, + TypeVisitor, +}; use rustc_span::DUMMY_SP; use std::ops::ControlFlow; @@ -137,7 +140,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { }) } - pub(super) fn instantiate_binder_with_infer + Copy>( + pub(super) fn instantiate_binder_with_infer> + Copy>( &self, value: ty::Binder<'tcx, T>, ) -> T { @@ -148,7 +151,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { ) } - pub(super) fn instantiate_binder_with_placeholders + Copy>( + pub(super) fn instantiate_binder_with_placeholders> + Copy>( &self, value: ty::Binder<'tcx, T>, ) -> T { @@ -157,7 +160,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { pub(super) fn resolve_vars_if_possible(&self, value: T) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { self.infcx.resolve_vars_if_possible(value) } diff --git a/compiler/rustc_trait_selection/src/solve/project_goals.rs b/compiler/rustc_trait_selection/src/solve/project_goals.rs index 9f83bfa1ccb9b..08c24ce13a5d0 100644 --- a/compiler/rustc_trait_selection/src/solve/project_goals.rs +++ b/compiler/rustc_trait_selection/src/solve/project_goals.rs @@ -14,7 +14,7 @@ use rustc_infer::traits::Reveal; use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams}; use rustc_middle::ty::ProjectionPredicate; use rustc_middle::ty::{self, Ty, TyCtxt}; -use rustc_middle::ty::{ToPredicate, TypeVisitable}; +use rustc_middle::ty::{ToPredicate, TypeVisitableExt}; use rustc_span::{sym, DUMMY_SP}; use std::iter; diff --git a/compiler/rustc_trait_selection/src/solve/trait_goals.rs b/compiler/rustc_trait_selection/src/solve/trait_goals.rs index 6d1381bbf0c9f..aff79739d45ff 100644 --- a/compiler/rustc_trait_selection/src/solve/trait_goals.rs +++ b/compiler/rustc_trait_selection/src/solve/trait_goals.rs @@ -10,7 +10,7 @@ use rustc_infer::traits::query::NoSolution; use rustc_infer::traits::util::supertraits; use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams}; use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt}; -use rustc_middle::ty::{TraitPredicate, TypeVisitable}; +use rustc_middle::ty::{TraitPredicate, TypeVisitableExt}; use rustc_span::DUMMY_SP; pub mod structural_traits; diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index 9776cc57af8e8..6f2b0856d516a 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -8,9 +8,8 @@ use crate::infer::region_constraints::{Constraint, RegionConstraintData}; use crate::infer::InferCtxt; use crate::traits::project::ProjectAndUnifyResult; use rustc_middle::mir::interpret::ErrorHandled; -use rustc_middle::ty::fold::{ir::TypeFolder, TypeSuperFoldable}; -#[cfg(not(bootstrap))] -use rustc_middle::ty::visit::TypeVisitable; +use rustc_middle::ty::fold::{TypeFolder, TypeSuperFoldable}; +use rustc_middle::ty::visit::TypeVisitableExt; use rustc_middle::ty::{ImplPolarity, Region, RegionVid}; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; diff --git a/compiler/rustc_trait_selection/src/traits/chalk_fulfill.rs b/compiler/rustc_trait_selection/src/traits/chalk_fulfill.rs index e26bef0b8b7f5..b42a49eb47b90 100644 --- a/compiler/rustc_trait_selection/src/traits/chalk_fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/chalk_fulfill.rs @@ -8,7 +8,7 @@ use crate::traits::{ SelectionError, TraitEngine, }; use rustc_data_structures::fx::FxIndexSet; -use rustc_middle::ty::TypeVisitable; +use rustc_middle::ty::TypeVisitableExt; pub struct FulfillmentContext<'tcx> { obligations: FxIndexSet>, diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index 44369670f5fb8..6b688c322c786 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -21,8 +21,8 @@ use rustc_infer::infer::{DefiningAnchor, InferCtxt, TyCtxtInferExt}; use rustc_infer::traits::util; use rustc_middle::traits::specialization_graph::OverlapMode; use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams}; -use rustc_middle::ty::visit::TypeVisitable; -use rustc_middle::ty::{self, ir::TypeVisitor, ImplSubject, Ty, TyCtxt}; +use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt}; +use rustc_middle::ty::{self, ImplSubject, Ty, TyCtxt, TypeVisitor}; use rustc_span::symbol::sym; use rustc_span::DUMMY_SP; use std::fmt::Debug; diff --git a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs index dd9b5b534d7e2..345e84990ed03 100644 --- a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs +++ b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs @@ -14,7 +14,7 @@ use rustc_middle::mir::interpret::ErrorHandled; use rustc_middle::traits::ObligationCause; use rustc_middle::ty::abstract_const::NotConstEvaluatable; -use rustc_middle::ty::{self, ir::TypeVisitor, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, TyCtxt, TypeVisitable, TypeVisitableExt, TypeVisitor}; use rustc_span::Span; use std::ops::ControlFlow; diff --git a/compiler/rustc_trait_selection/src/traits/engine.rs b/compiler/rustc_trait_selection/src/traits/engine.rs index 4a7f08a35bc61..b20636174eeac 100644 --- a/compiler/rustc_trait_selection/src/traits/engine.rs +++ b/compiler/rustc_trait_selection/src/traits/engine.rs @@ -104,7 +104,7 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> { }); } - pub fn normalize>( + pub fn normalize>>( &self, cause: &ObligationCause<'tcx>, param_env: ty::ParamEnv<'tcx>, @@ -220,7 +220,7 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> { answer: T, ) -> Fallible> where - T: Debug + TypeFoldable<'tcx>, + T: Debug + TypeFoldable>, Canonical<'tcx, QueryResponse<'tcx, T>>: ArenaAllocatable<'tcx>, { self.infcx.make_canonicalized_query_response( diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index a32ab16263a29..a844a1494e262 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -34,10 +34,11 @@ use rustc_infer::infer::{InferOk, TypeTrace}; use rustc_middle::traits::select::OverflowError; use rustc_middle::ty::abstract_const::NotConstEvaluatable; use rustc_middle::ty::error::{ExpectedFound, TypeError}; -use rustc_middle::ty::fold::{ir::TypeFolder, TypeSuperFoldable}; +use rustc_middle::ty::fold::{TypeFolder, TypeSuperFoldable}; use rustc_middle::ty::print::{with_forced_trimmed_paths, FmtPrinter, Print}; use rustc_middle::ty::{ self, SubtypePredicate, ToPolyTraitRef, ToPredicate, TraitRef, Ty, TyCtxt, TypeFoldable, + TypeVisitable, TypeVisitableExt, }; use rustc_session::config::TraitSolver; use rustc_session::Limit; @@ -108,7 +109,7 @@ pub trait TypeErrCtxtExt<'tcx> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> where T: fmt::Display - + TypeFoldable<'tcx> + + TypeFoldable> + Print<'tcx, FmtPrinter<'tcx, 'tcx>, Output = FmtPrinter<'tcx, 'tcx>>, >>::Error: std::fmt::Debug; @@ -121,7 +122,7 @@ pub trait TypeErrCtxtExt<'tcx> { ) -> ! where T: fmt::Display - + TypeFoldable<'tcx> + + TypeFoldable> + Print<'tcx, FmtPrinter<'tcx, 'tcx>, Output = FmtPrinter<'tcx, 'tcx>>, >>::Error: std::fmt::Debug; @@ -491,7 +492,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { ) -> ! where T: fmt::Display - + TypeFoldable<'tcx> + + TypeFoldable> + Print<'tcx, FmtPrinter<'tcx, 'tcx>, Output = FmtPrinter<'tcx, 'tcx>>, >>::Error: std::fmt::Debug, { @@ -511,7 +512,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { ) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> where T: fmt::Display - + TypeFoldable<'tcx> + + TypeFoldable> + Print<'tcx, FmtPrinter<'tcx, 'tcx>, Output = FmtPrinter<'tcx, 'tcx>>, >>::Error: std::fmt::Debug, { @@ -2970,7 +2971,7 @@ impl ArgKind { struct HasNumericInferVisitor; -impl<'tcx> ty::ir::TypeVisitor> for HasNumericInferVisitor { +impl<'tcx> ty::TypeVisitor> for HasNumericInferVisitor { type BreakTy = (); fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow { diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 824264c21d0d0..84945ff28fe57 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -30,10 +30,10 @@ use rustc_middle::hir::map; use rustc_middle::ty::error::TypeError::{self, Sorts}; use rustc_middle::ty::relate::TypeRelation; use rustc_middle::ty::{ - self, ir::TypeFolder, suggest_arbitrary_trait_bound, suggest_constraining_type_param, AdtKind, - DefIdTree, GeneratorDiagnosticData, GeneratorInteriorTypeCause, Infer, InferTy, InternalSubsts, - IsSuggestable, ToPredicate, Ty, TyCtxt, TypeAndMut, TypeFoldable, TypeSuperFoldable, - TypeckResults, + self, suggest_arbitrary_trait_bound, suggest_constraining_type_param, AdtKind, DefIdTree, + GeneratorDiagnosticData, GeneratorInteriorTypeCause, Infer, InferTy, InternalSubsts, + IsSuggestable, ToPredicate, Ty, TyCtxt, TypeAndMut, TypeFoldable, TypeFolder, + TypeSuperFoldable, TypeVisitableExt, TypeckResults, }; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::{sym, Ident, Symbol}; diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index deeed930e50e2..da2416b96467e 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -8,7 +8,7 @@ use rustc_middle::mir::interpret::ErrorHandled; use rustc_middle::ty::abstract_const::NotConstEvaluatable; use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::subst::SubstsRef; -use rustc_middle::ty::{self, Binder, Const, TypeVisitable}; +use rustc_middle::ty::{self, Binder, Const, TypeVisitableExt}; use std::marker::PhantomData; use super::const_evaluatable; diff --git a/compiler/rustc_trait_selection/src/traits/misc.rs b/compiler/rustc_trait_selection/src/traits/misc.rs index de730773794b6..b94346b09560a 100644 --- a/compiler/rustc_trait_selection/src/traits/misc.rs +++ b/compiler/rustc_trait_selection/src/traits/misc.rs @@ -8,7 +8,7 @@ use rustc_infer::infer::canonical::Canonical; use rustc_infer::infer::{RegionResolutionError, TyCtxtInferExt}; use rustc_infer::traits::query::NoSolution; use rustc_infer::{infer::outlives::env::OutlivesEnvironment, traits::FulfillmentError}; -use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt, TypeVisitableExt}; use rustc_span::DUMMY_SP; use super::outlives_bounds::InferCtxtExt; diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 2d299486ee685..c8b233bfe26aa 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -27,7 +27,7 @@ use crate::traits::error_reporting::TypeErrCtxtExt as _; use crate::traits::query::evaluate_obligation::InferCtxtExt as _; use rustc_errors::ErrorGuaranteed; use rustc_middle::ty::fold::TypeFoldable; -use rustc_middle::ty::visit::TypeVisitable; +use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt}; use rustc_middle::ty::{self, DefIdTree, ToPredicate, Ty, TyCtxt, TypeSuperVisitable}; use rustc_middle::ty::{InternalSubsts, SubstsRef}; use rustc_span::def_id::{DefId, CRATE_DEF_ID}; @@ -141,7 +141,7 @@ pub fn type_known_to_meet_bound_modulo_regions<'tcx>( fn pred_known_to_hold_modulo_regions<'tcx>( infcx: &InferCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, - pred: impl ToPredicate<'tcx> + TypeVisitable<'tcx>, + pred: impl ToPredicate<'tcx> + TypeVisitable>, span: Span, ) -> bool { let has_non_region_infer = pred.has_non_region_infer(); @@ -371,7 +371,7 @@ pub fn fully_normalize<'tcx, T>( value: T, ) -> Result>> where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { let ocx = ObligationCtxt::new(infcx); debug!(?value); @@ -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> for ReferencesOnlyParentGenerics<'tcx> { + impl<'tcx> ty::TypeVisitor> for ReferencesOnlyParentGenerics<'tcx> { type BreakTy = (); fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow { // If this is a parameter from the trait item's own generics, then bail diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index df1aeed941d7c..b87f75422ef60 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -19,7 +19,7 @@ use rustc_hir as hir; use rustc_hir::def_id::DefId; use rustc_middle::ty::subst::{GenericArg, InternalSubsts}; use rustc_middle::ty::{ - self, ir::TypeVisitor, EarlyBinder, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, + self, EarlyBinder, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor, }; use rustc_middle::ty::{Predicate, ToPredicate}; use rustc_session::lint::builtin::WHERE_CLAUSES_OBJECT_SAFETY; @@ -790,7 +790,7 @@ fn receiver_is_dispatchable<'tcx>( infcx.predicate_must_hold_modulo_regions(&obligation) } -fn contains_illegal_self_type_reference<'tcx, T: TypeVisitable<'tcx>>( +fn contains_illegal_self_type_reference<'tcx, T: TypeVisitable>>( tcx: TyCtxt<'tcx>, trait_def_id: DefId, value: T, diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index 9ccdeca842ccd..279725b16d8a6 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -30,8 +30,8 @@ use rustc_infer::infer::at::At; use rustc_infer::infer::resolve::OpportunisticRegionResolver; use rustc_infer::traits::ImplSourceBuiltinData; use rustc_middle::traits::select::OverflowError; -use rustc_middle::ty::fold::{ir::TypeFolder, TypeFoldable, TypeSuperFoldable}; -use rustc_middle::ty::visit::{MaxUniverse, TypeVisitable}; +use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable}; +use rustc_middle::ty::visit::{MaxUniverse, TypeVisitable, TypeVisitableExt}; use rustc_middle::ty::DefIdTree; use rustc_middle::ty::{self, Term, ToPredicate, Ty, TyCtxt}; use rustc_span::symbol::sym; @@ -53,11 +53,11 @@ pub trait NormalizeExt<'tcx> { /// /// This normalization should be used when the type contains inference variables or the /// projection may be fallible. - fn normalize>(&self, t: T) -> InferOk<'tcx, T>; + fn normalize>>(&self, t: T) -> InferOk<'tcx, T>; } impl<'tcx> NormalizeExt<'tcx> for At<'_, 'tcx> { - fn normalize>(&self, value: T) -> InferOk<'tcx, T> { + fn normalize>>(&self, value: T) -> InferOk<'tcx, T> { let mut selcx = SelectionContext::new(self.infcx); let Normalized { value, obligations } = normalize_with_depth(&mut selcx, self.param_env, self.cause.clone(), 0, value); @@ -312,7 +312,7 @@ pub(crate) fn normalize_with_depth<'a, 'b, 'tcx, T>( value: T, ) -> Normalized<'tcx, T> where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { let mut obligations = Vec::new(); let value = normalize_with_depth_to(selcx, param_env, cause, depth, value, &mut obligations); @@ -329,7 +329,7 @@ pub(crate) fn normalize_with_depth_to<'a, 'b, 'tcx, T>( obligations: &mut Vec>, ) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { debug!(obligations.len = obligations.len()); let mut normalizer = AssocTypeNormalizer::new(selcx, param_env, cause, depth, obligations); @@ -349,7 +349,7 @@ pub(crate) fn try_normalize_with_depth_to<'a, 'b, 'tcx, T>( obligations: &mut Vec>, ) -> T where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { debug!(obligations.len = obligations.len()); let mut normalizer = AssocTypeNormalizer::new_without_eager_inference_replacement( @@ -365,7 +365,10 @@ where result } -pub(crate) fn needs_normalization<'tcx, T: TypeVisitable<'tcx>>(value: &T, reveal: Reveal) -> bool { +pub(crate) fn needs_normalization<'tcx, T: TypeVisitable>>( + value: &T, + reveal: Reveal, +) -> bool { match reveal { Reveal::UserFacing => value .has_type_flags(ty::TypeFlags::HAS_TY_PROJECTION | ty::TypeFlags::HAS_CT_PROJECTION), @@ -427,7 +430,7 @@ impl<'a, 'b, 'tcx> AssocTypeNormalizer<'a, 'b, 'tcx> { } } - fn fold>(&mut self, value: T) -> T { + fn fold>>(&mut self, value: T) -> T { let value = self.selcx.infcx.resolve_vars_if_possible(value); debug!(?value); @@ -450,7 +453,7 @@ impl<'a, 'b, 'tcx> TypeFolder> for AssocTypeNormalizer<'a, 'b, 'tcx self.selcx.tcx() } - fn fold_binder>( + fn fold_binder>>( &mut self, t: ty::Binder<'tcx, T>, ) -> ty::Binder<'tcx, T> { @@ -669,7 +672,12 @@ pub struct BoundVarReplacer<'me, 'tcx> { /// /// FIXME(@lcnr): We may even consider experimenting with eagerly replacing bound vars during /// normalization as well, at which point this function will be unnecessary and can be removed. -pub fn with_replaced_escaping_bound_vars<'a, 'tcx, T: TypeFoldable<'tcx>, R: TypeFoldable<'tcx>>( +pub fn with_replaced_escaping_bound_vars< + 'a, + 'tcx, + T: TypeFoldable>, + R: TypeFoldable>, +>( infcx: &'a InferCtxt<'tcx>, universe_indices: &'a mut Vec>, value: T, @@ -695,7 +703,7 @@ pub fn with_replaced_escaping_bound_vars<'a, 'tcx, T: TypeFoldable<'tcx>, R: Typ impl<'me, 'tcx> BoundVarReplacer<'me, 'tcx> { /// Returns `Some` if we *were* able to replace bound vars. If there are any bound vars that /// use a binding level above `universe_indices.len()`, we fail. - pub fn replace_bound_vars>( + pub fn replace_bound_vars>>( infcx: &'me InferCtxt<'tcx>, universe_indices: &'me mut Vec>, value: T, @@ -742,7 +750,7 @@ impl<'tcx> TypeFolder> for BoundVarReplacer<'_, 'tcx> { self.infcx.tcx } - fn fold_binder>( + fn fold_binder>>( &mut self, t: ty::Binder<'tcx, T>, ) -> ty::Binder<'tcx, T> { @@ -823,7 +831,7 @@ pub struct PlaceholderReplacer<'me, 'tcx> { } impl<'me, 'tcx> PlaceholderReplacer<'me, 'tcx> { - pub fn replace_placeholders>( + pub fn replace_placeholders>>( infcx: &'me InferCtxt<'tcx>, mapped_regions: BTreeMap, mapped_types: BTreeMap, @@ -848,7 +856,7 @@ impl<'tcx> TypeFolder> for PlaceholderReplacer<'_, 'tcx> { self.infcx.tcx } - fn fold_binder>( + fn fold_binder>>( &mut self, t: ty::Binder<'tcx, T>, ) -> ty::Binder<'tcx, T> { diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs index a266013b8fd4f..b0cec3ce7a3ea 100644 --- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs @@ -11,9 +11,9 @@ use crate::traits::{ObligationCause, PredicateObligation, Reveal}; use rustc_data_structures::sso::SsoHashMap; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_infer::traits::Normalized; -use rustc_middle::ty::fold::{ir::FallibleTypeFolder, TypeFoldable, TypeSuperFoldable}; -use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable}; -use rustc_middle::ty::{self, ir::TypeVisitor, Ty, TyCtxt}; +use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable}; +use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt}; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitor}; use rustc_span::DUMMY_SP; use std::ops::ControlFlow; @@ -32,7 +32,7 @@ pub trait QueryNormalizeExt<'tcx> { /// use [`TyCtxt::normalize_erasing_regions`], which wraps this procedure. fn query_normalize(&self, value: T) -> Result, NoSolution> where - T: TypeFoldable<'tcx>; + T: TypeFoldable>; } impl<'cx, 'tcx> QueryNormalizeExt<'tcx> for At<'cx, 'tcx> { @@ -51,7 +51,7 @@ impl<'cx, 'tcx> QueryNormalizeExt<'tcx> for At<'cx, 'tcx> { /// and other details are still "under development". fn query_normalize(&self, value: T) -> Result, NoSolution> where - T: TypeFoldable<'tcx>, + T: TypeFoldable>, { debug!( "normalize::<{}>(value={:?}, param_env={:?}, cause={:?})", @@ -116,7 +116,7 @@ struct MaxEscapingBoundVarVisitor { } impl<'tcx> TypeVisitor> for MaxEscapingBoundVarVisitor { - fn visit_binder>( + fn visit_binder>>( &mut self, t: &ty::Binder<'tcx, T>, ) -> ControlFlow { @@ -177,7 +177,7 @@ impl<'cx, 'tcx> FallibleTypeFolder> for QueryNormalizer<'cx, 'tcx> self.infcx.tcx } - fn try_fold_binder>( + fn try_fold_binder>>( &mut self, t: ty::Binder<'tcx, T>, ) -> Result, Self::Error> { diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs index 97002b461aa9b..9e8bc8bce9a8f 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs @@ -54,8 +54,8 @@ pub struct TypeOpOutput<'tcx, Op: TypeOp<'tcx>> { /// which produces the resulting query region constraints. /// /// [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html -pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<'tcx> + 'tcx { - type QueryResponse: TypeFoldable<'tcx>; +pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable> + 'tcx { + type QueryResponse: TypeFoldable>; /// Give query the option for a simple fast path that never /// actually hits the tcx cache lookup etc. Return `Some(r)` with diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs index 8f0b4de31e6cf..5b216c0769236 100644 --- a/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs @@ -1,7 +1,7 @@ use crate::infer::canonical::{Canonical, CanonicalQueryResponse}; use crate::traits::query::Fallible; use rustc_middle::ty::fold::TypeFoldable; -use rustc_middle::ty::{self, Lift, ParamEnvAnd, Ty, TyCtxt}; +use rustc_middle::ty::{self, Lift, ParamEnvAnd, Ty, TyCtxt, TypeVisitableExt}; use std::fmt; pub use rustc_middle::traits::query::type_op::Normalize; @@ -24,7 +24,7 @@ where } } -pub trait Normalizable<'tcx>: fmt::Debug + TypeFoldable<'tcx> + Lift<'tcx> + Copy { +pub trait Normalizable<'tcx>: fmt::Debug + TypeFoldable> + Lift<'tcx> + Copy { fn type_op_method( tcx: TyCtxt<'tcx>, canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize>>, diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index dae602908a31f..4ad13dcb645eb 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -9,7 +9,7 @@ use hir::LangItem; use rustc_hir as hir; use rustc_infer::traits::ObligationCause; use rustc_infer::traits::{Obligation, SelectionError, TraitObligation}; -use rustc_middle::ty::{self, Ty, TypeVisitable}; +use rustc_middle::ty::{self, Ty, TypeVisitableExt}; use rustc_target::spec::abi::Abi; use crate::traits; diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 5c5b2d6dac3fb..270f513ce3cd1 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -12,7 +12,7 @@ use rustc_infer::infer::InferOk; use rustc_infer::infer::LateBoundRegionConversionTime::HigherRankedType; use rustc_middle::ty::{ self, Binder, GenericParamDefKind, InternalSubsts, SubstsRef, ToPolyTraitRef, ToPredicate, - TraitRef, Ty, TyCtxt, TypeVisitable, + TraitRef, Ty, TyCtxt, TypeVisitableExt, }; use rustc_session::config::TraitSolver; use rustc_span::def_id::DefId; diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 79c188d7f815b..e7e0f8838a432 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -49,7 +49,7 @@ use rustc_middle::ty::fold::BottomUpFolder; use rustc_middle::ty::relate::TypeRelation; use rustc_middle::ty::SubstsRef; use rustc_middle::ty::{self, EarlyBinder, PolyProjectionPredicate, ToPolyTraitRef, ToPredicate}; -use rustc_middle::ty::{Ty, TyCtxt, TypeFoldable}; +use rustc_middle::ty::{Ty, TyCtxt, TypeFoldable, TypeVisitableExt}; use rustc_session::config::TraitSolver; use rustc_span::symbol::sym; @@ -1406,7 +1406,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { /// The weird return type of this function allows it to be used with the `try` (`?`) /// operator within certain functions. #[inline(always)] - fn check_recursion_limit, V>( + fn check_recursion_limit>, V>( &self, obligation: &Obligation<'tcx, T>, error_obligation: &Obligation<'tcx, V>, diff --git a/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs b/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs index 2e4a5cfe4bcf9..61ed9ef2ec184 100644 --- a/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs +++ b/compiler/rustc_trait_selection/src/traits/specialize/specialization_graph.rs @@ -4,7 +4,7 @@ use crate::traits; use rustc_errors::ErrorGuaranteed; use rustc_hir::def_id::DefId; use rustc_middle::ty::fast_reject::{self, SimplifiedType, TreatParams}; -use rustc_middle::ty::{self, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt}; pub use rustc_middle::traits::specialization_graph::*; diff --git a/compiler/rustc_trait_selection/src/traits/structural_match.rs b/compiler/rustc_trait_selection/src/traits/structural_match.rs index 32dd8f25b4420..e38ae9381c1d7 100644 --- a/compiler/rustc_trait_selection/src/traits/structural_match.rs +++ b/compiler/rustc_trait_selection/src/traits/structural_match.rs @@ -1,8 +1,6 @@ use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; -#[cfg(not(bootstrap))] -use rustc_middle::ty::TypeVisitable; -use rustc_middle::ty::{self, ir::TypeVisitor, Ty, TyCtxt, TypeSuperVisitable}; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor}; use rustc_span::Span; use std::ops::ControlFlow; diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs index b5df583e3f4cb..0c55c35ffb489 100644 --- a/compiler/rustc_trait_selection/src/traits/util.rs +++ b/compiler/rustc_trait_selection/src/traits/util.rs @@ -4,7 +4,7 @@ use smallvec::SmallVec; use rustc_data_structures::fx::FxHashSet; use rustc_hir::def_id::DefId; -use rustc_middle::ty::{self, ImplSubject, ToPredicate, Ty, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, ImplSubject, ToPredicate, Ty, TyCtxt, TypeVisitableExt}; use rustc_middle::ty::{GenericArg, SubstsRef}; use super::NormalizeExt; diff --git a/compiler/rustc_trait_selection/src/traits/vtable.rs b/compiler/rustc_trait_selection/src/traits/vtable.rs index 9f5c5bbeac8de..a4e9928f8b2cf 100644 --- a/compiler/rustc_trait_selection/src/traits/vtable.rs +++ b/compiler/rustc_trait_selection/src/traits/vtable.rs @@ -4,7 +4,7 @@ use rustc_hir::def_id::DefId; use rustc_hir::lang_items::LangItem; use rustc_infer::traits::util::PredicateSet; use rustc_infer::traits::ImplSource; -use rustc_middle::ty::visit::TypeVisitable; +use rustc_middle::ty::visit::TypeVisitableExt; use rustc_middle::ty::InternalSubsts; use rustc_middle::ty::{self, GenericParamDefKind, ToPredicate, Ty, TyCtxt, VtblEntry}; use rustc_span::{sym, Span}; diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 6a881c233db09..d498af359c584 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -3,7 +3,7 @@ use crate::traits; use rustc_hir as hir; use rustc_hir::lang_items::LangItem; use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef}; -use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; use rustc_span::def_id::{DefId, LocalDefId, CRATE_DEF_ID}; use rustc_span::{Span, DUMMY_SP}; diff --git a/compiler/rustc_traits/src/chalk/db.rs b/compiler/rustc_traits/src/chalk/db.rs index e2b5d17e07300..f8c8f744e6d53 100644 --- a/compiler/rustc_traits/src/chalk/db.rs +++ b/compiler/rustc_traits/src/chalk/db.rs @@ -769,12 +769,12 @@ struct ReplaceOpaqueTyFolder<'tcx> { binder_index: ty::DebruijnIndex, } -impl<'tcx> ty::ir::TypeFolder> for ReplaceOpaqueTyFolder<'tcx> { +impl<'tcx> ty::TypeFolder> for ReplaceOpaqueTyFolder<'tcx> { fn interner(&self) -> TyCtxt<'tcx> { self.tcx } - fn fold_binder>( + fn fold_binder>>( &mut self, t: ty::Binder<'tcx, T>, ) -> ty::Binder<'tcx, T> { diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index 7635f4bfec3ba..fe80de5a06907 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -35,9 +35,8 @@ use rustc_ast::ast; use rustc_middle::traits::{ChalkEnvironmentAndGoal, ChalkRustInterner as RustInterner}; use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef}; use rustc_middle::ty::{ - self, - ir::{TypeFolder, TypeVisitor}, - Binder, Region, Ty, TyCtxt, TypeFoldable, TypeSuperFoldable, TypeSuperVisitable, TypeVisitable, + self, Binder, Region, Ty, TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, + TypeSuperVisitable, TypeVisitable, TypeVisitor, }; use rustc_span::def_id::DefId; @@ -880,7 +879,7 @@ impl<'tcx> LowerInto<'tcx, chalk_solve::rust_ir::AliasEqBound /// It's important to note that because of prior substitution, we may have /// late-bound regions, even outside of fn contexts, since this is the best way /// to prep types for chalk lowering. -pub(crate) fn collect_bound_vars<'tcx, T: TypeFoldable<'tcx>>( +pub(crate) fn collect_bound_vars<'tcx, T: TypeFoldable>>( interner: RustInterner<'tcx>, tcx: TyCtxt<'tcx>, ty: Binder<'tcx, T>, @@ -931,7 +930,7 @@ impl<'tcx> BoundVarsCollector<'tcx> { } impl<'tcx> TypeVisitor> for BoundVarsCollector<'tcx> { - fn visit_binder>( + fn visit_binder>>( &mut self, t: &Binder<'tcx, T>, ) -> ControlFlow { @@ -1016,7 +1015,10 @@ impl<'a, 'tcx> TypeFolder> for NamedBoundVarSubstitutor<'a, 'tcx> { self.tcx } - fn fold_binder>(&mut self, t: Binder<'tcx, T>) -> Binder<'tcx, T> { + fn fold_binder>>( + &mut self, + t: Binder<'tcx, T>, + ) -> Binder<'tcx, T> { self.binder_index.shift_in(1); let result = t.super_fold_with(self); self.binder_index.shift_out(1); @@ -1072,7 +1074,10 @@ impl<'tcx> TypeFolder> for ParamsSubstitutor<'tcx> { self.tcx } - fn fold_binder>(&mut self, t: Binder<'tcx, T>) -> Binder<'tcx, T> { + fn fold_binder>>( + &mut self, + t: Binder<'tcx, T>, + ) -> Binder<'tcx, T> { self.binder_index.shift_in(1); let result = t.super_fold_with(self); self.binder_index.shift_out(1); diff --git a/compiler/rustc_traits/src/chalk/mod.rs b/compiler/rustc_traits/src/chalk/mod.rs index f33f9edd6279e..5855a8e28dd1d 100644 --- a/compiler/rustc_traits/src/chalk/mod.rs +++ b/compiler/rustc_traits/src/chalk/mod.rs @@ -9,7 +9,7 @@ pub(crate) mod lowering; use rustc_middle::infer::canonical::{CanonicalTyVarKind, CanonicalVarKind}; use rustc_middle::traits::ChalkRustInterner; use rustc_middle::ty::query::Providers; -use rustc_middle::ty::{self, TyCtxt, TypeFoldable}; +use rustc_middle::ty::{self, TyCtxt, TypeFoldable, TypeVisitable}; use rustc_infer::infer::canonical::{ Canonical, CanonicalVarValues, Certainty, QueryRegionConstraints, QueryResponse, diff --git a/compiler/rustc_traits/src/implied_outlives_bounds.rs b/compiler/rustc_traits/src/implied_outlives_bounds.rs index abf0c1c5f3e9a..ddd4ca1436c09 100644 --- a/compiler/rustc_traits/src/implied_outlives_bounds.rs +++ b/compiler/rustc_traits/src/implied_outlives_bounds.rs @@ -7,7 +7,7 @@ use rustc_infer::infer::outlives::components::{push_outlives_components, Compone use rustc_infer::infer::TyCtxtInferExt; use rustc_infer::traits::query::OutlivesBound; use rustc_middle::ty::query::Providers; -use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt}; use rustc_span::def_id::CRATE_DEF_ID; use rustc_span::source_map::DUMMY_SP; use rustc_trait_selection::infer::InferCtxtBuilderExt; diff --git a/compiler/rustc_traits/src/normalize_erasing_regions.rs b/compiler/rustc_traits/src/normalize_erasing_regions.rs index 2c18a03405074..f0597f19225c8 100644 --- a/compiler/rustc_traits/src/normalize_erasing_regions.rs +++ b/compiler/rustc_traits/src/normalize_erasing_regions.rs @@ -1,7 +1,7 @@ use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::traits::query::NoSolution; use rustc_middle::ty::query::Providers; -use rustc_middle::ty::{self, ParamEnvAnd, TyCtxt, TypeFoldable}; +use rustc_middle::ty::{self, ParamEnvAnd, TyCtxt, TypeFoldable, TypeVisitableExt}; use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt; use rustc_trait_selection::traits::{Normalized, ObligationCause}; use std::sync::atomic::Ordering; @@ -22,7 +22,7 @@ pub(crate) fn provide(p: &mut Providers) { }; } -fn try_normalize_after_erasing_regions<'tcx, T: TypeFoldable<'tcx> + PartialEq + Copy>( +fn try_normalize_after_erasing_regions<'tcx, T: TypeFoldable> + PartialEq + Copy>( tcx: TyCtxt<'tcx>, goal: ParamEnvAnd<'tcx, T>, ) -> Result { diff --git a/compiler/rustc_traits/src/type_op.rs b/compiler/rustc_traits/src/type_op.rs index d34fce64dd7dc..e0fd487b3d37f 100644 --- a/compiler/rustc_traits/src/type_op.rs +++ b/compiler/rustc_traits/src/type_op.rs @@ -161,7 +161,7 @@ fn type_op_normalize<'tcx, T>( key: ParamEnvAnd<'tcx, Normalize>, ) -> Fallible where - T: fmt::Debug + TypeFoldable<'tcx> + Lift<'tcx>, + T: fmt::Debug + TypeFoldable> + Lift<'tcx>, { let (param_env, Normalize { value }) = key.into_parts(); let Normalized { value, obligations } = diff --git a/compiler/rustc_transmute/src/lib.rs b/compiler/rustc_transmute/src/lib.rs index b3b9a67b26e3d..4b4a8ebd079fc 100644 --- a/compiler/rustc_transmute/src/lib.rs +++ b/compiler/rustc_transmute/src/lib.rs @@ -117,7 +117,7 @@ mod rustc { c: Const<'tcx>, ) -> Option { use rustc_middle::ty::ScalarInt; - use rustc_middle::ty::TypeVisitable; + use rustc_middle::ty::TypeVisitableExt; use rustc_span::symbol::sym; let c = c.eval(tcx, param_env); diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs index 852156c24f42a..ae824a31f759f 100644 --- a/compiler/rustc_ty_utils/src/consts.rs +++ b/compiler/rustc_ty_utils/src/consts.rs @@ -5,7 +5,7 @@ use rustc_middle::mir::interpret::{LitToConstError, LitToConstInput}; use rustc_middle::thir::visit; use rustc_middle::thir::visit::Visitor; use rustc_middle::ty::abstract_const::CastKind; -use rustc_middle::ty::{self, Expr, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, Expr, TyCtxt, TypeVisitableExt}; use rustc_middle::{mir, thir}; use rustc_span::Span; use rustc_target::abi::VariantIdx; diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index de7230b0cfaed..2eaeca73da75f 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -3,7 +3,7 @@ use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_infer::infer::TyCtxtInferExt; use rustc_middle::traits::CodegenObligationError; use rustc_middle::ty::subst::SubstsRef; -use rustc_middle::ty::{self, Instance, TyCtxt, TypeVisitable}; +use rustc_middle::ty::{self, Instance, TyCtxt, TypeVisitableExt}; use rustc_span::sym; use rustc_trait_selection::traits; use traits::{translate_substs, Reveal}; diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index 1a62794b0b441..a400fbfe683ef 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -7,7 +7,7 @@ use rustc_middle::ty::layout::{ IntegerExt, LayoutCx, LayoutError, LayoutOf, TyAndLayout, MAX_SIMD_LANES, }; use rustc_middle::ty::{ - self, subst::SubstsRef, AdtDef, EarlyBinder, ReprOptions, Ty, TyCtxt, TypeVisitable, + self, subst::SubstsRef, AdtDef, EarlyBinder, ReprOptions, Ty, TyCtxt, TypeVisitableExt, }; use rustc_session::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo}; use rustc_span::symbol::Symbol; diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index f1af0073e4da9..a47e7ce23e3c0 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -2,11 +2,9 @@ use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; use rustc_hir as hir; use rustc_hir::def::DefKind; use rustc_index::bit_set::BitSet; -#[cfg(not(bootstrap))] -use rustc_middle::ty::ir::TypeVisitable; use rustc_middle::ty::{ - self, ir::TypeVisitor, Binder, EarlyBinder, Predicate, PredicateKind, ToPredicate, Ty, TyCtxt, - TypeSuperVisitable, + self, Binder, EarlyBinder, Predicate, PredicateKind, ToPredicate, Ty, TyCtxt, + TypeSuperVisitable, TypeVisitable, TypeVisitor, }; use rustc_session::config::TraitSolver; use rustc_span::def_id::{DefId, CRATE_DEF_ID}; diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 5541136ef490d..58223f322b21e 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -22,9 +22,9 @@ use rustc_hir::PredicateOrigin; use rustc_hir_analysis::hir_ty_to_ty; use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData}; use rustc_middle::middle::resolve_bound_vars as rbv; -use rustc_middle::ty::fold::ir::TypeFolder; +use rustc_middle::ty::fold::TypeFolder; use rustc_middle::ty::InternalSubsts; -use rustc_middle::ty::TypeVisitable; +use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::{self, AdtKind, DefIdTree, EarlyBinder, Ty, TyCtxt}; use rustc_middle::{bug, span_bug}; use rustc_span::hygiene::{AstPass, MacroKind}; diff --git a/src/tools/clippy/clippy_lints/src/dereference.rs b/src/tools/clippy/clippy_lints/src/dereference.rs index b4543aa2544f8..ef46e23123b92 100644 --- a/src/tools/clippy/clippy_lints/src/dereference.rs +++ b/src/tools/clippy/clippy_lints/src/dereference.rs @@ -27,7 +27,7 @@ use rustc_middle::mir::{Rvalue, StatementKind}; use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability}; use rustc_middle::ty::{ self, Binder, BoundVariableKind, Clause, EarlyBinder, FnSig, GenericArgKind, List, ParamTy, PredicateKind, - ProjectionPredicate, Ty, TyCtxt, TypeVisitable, TypeckResults, + ProjectionPredicate, Ty, TyCtxt, TypeVisitableExt, TypeckResults, }; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::{symbol::sym, Span, Symbol}; diff --git a/src/tools/clippy/clippy_lints/src/eta_reduction.rs b/src/tools/clippy/clippy_lints/src/eta_reduction.rs index ddade65c515c6..b2071f4dcb1e2 100644 --- a/src/tools/clippy/clippy_lints/src/eta_reduction.rs +++ b/src/tools/clippy/clippy_lints/src/eta_reduction.rs @@ -11,7 +11,7 @@ use rustc_hir::{Closure, Expr, ExprKind, Param, PatKind, Unsafety}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow}; use rustc_middle::ty::binding::BindingMode; -use rustc_middle::ty::{self, EarlyBinder, SubstsRef, Ty, TypeVisitable}; +use rustc_middle::ty::{self, EarlyBinder, SubstsRef, Ty, TypeVisitableExt}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::symbol::sym; diff --git a/src/tools/clippy/clippy_lints/src/mut_key.rs b/src/tools/clippy/clippy_lints/src/mut_key.rs index 3cc765108d7cc..5a533261cad8c 100644 --- a/src/tools/clippy/clippy_lints/src/mut_key.rs +++ b/src/tools/clippy/clippy_lints/src/mut_key.rs @@ -3,7 +3,7 @@ use clippy_utils::{def_path_def_ids, trait_ref_of_method}; use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; -use rustc_middle::ty::TypeVisitable; +use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::{Adt, Array, Ref, Slice, Tuple, Ty}; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::def_id::LocalDefId; diff --git a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs index 996ea6ed72316..da3b6fa9899df 100644 --- a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs +++ b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs @@ -18,7 +18,7 @@ use rustc_hir_typeck::expr_use_visitor as euv; use rustc_infer::infer::TyCtxtInferExt; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::mir::FakeReadCause; -use rustc_middle::ty::{self, TypeVisitable}; +use rustc_middle::ty::{self, TypeVisitableExt}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::kw; diff --git a/src/tools/clippy/clippy_lints/src/transmute/transmute_ptr_to_ref.rs b/src/tools/clippy/clippy_lints/src/transmute/transmute_ptr_to_ref.rs index 54ac04df1c12a..6bdb9aa5a26d2 100644 --- a/src/tools/clippy/clippy_lints/src/transmute/transmute_ptr_to_ref.rs +++ b/src/tools/clippy/clippy_lints/src/transmute/transmute_ptr_to_ref.rs @@ -6,7 +6,7 @@ use clippy_utils::sugg; use rustc_errors::Applicability; use rustc_hir::{self as hir, Expr, GenericArg, Mutability, Path, TyKind}; use rustc_lint::LateContext; -use rustc_middle::ty::{self, Ty, TypeVisitable}; +use rustc_middle::ty::{self, Ty, TypeVisitableExt}; /// Checks for `transmute_ptr_to_ref` lint. /// Returns `true` if it's triggered, otherwise returns `false`. diff --git a/src/tools/clippy/clippy_lints/src/transmute/useless_transmute.rs b/src/tools/clippy/clippy_lints/src/transmute/useless_transmute.rs index 871c3fadbba71..56207fe767c57 100644 --- a/src/tools/clippy/clippy_lints/src/transmute/useless_transmute.rs +++ b/src/tools/clippy/clippy_lints/src/transmute/useless_transmute.rs @@ -4,7 +4,7 @@ use clippy_utils::sugg; use rustc_errors::Applicability; use rustc_hir::Expr; use rustc_lint::LateContext; -use rustc_middle::ty::{self, Ty, TypeVisitable}; +use rustc_middle::ty::{self, Ty, TypeVisitableExt}; /// Checks for `useless_transmute` lint. /// Returns `true` if it's triggered, otherwise returns `false`. diff --git a/src/tools/clippy/clippy_lints/src/types/redundant_allocation.rs b/src/tools/clippy/clippy_lints/src/types/redundant_allocation.rs index f9b9a66b5fa46..f7adc9d35558b 100644 --- a/src/tools/clippy/clippy_lints/src/types/redundant_allocation.rs +++ b/src/tools/clippy/clippy_lints/src/types/redundant_allocation.rs @@ -5,7 +5,7 @@ use rustc_errors::Applicability; use rustc_hir::{self as hir, def_id::DefId, QPath, TyKind}; use rustc_hir_analysis::hir_ty_to_ty; use rustc_lint::LateContext; -use rustc_middle::ty::TypeVisitable; +use rustc_middle::ty::TypeVisitableExt; use rustc_span::symbol::sym; use super::{utils, REDUNDANT_ALLOCATION}; diff --git a/src/tools/clippy/clippy_lints/src/types/vec_box.rs b/src/tools/clippy/clippy_lints/src/types/vec_box.rs index 7a3c7cd8a99fc..d3062f3d2e360 100644 --- a/src/tools/clippy/clippy_lints/src/types/vec_box.rs +++ b/src/tools/clippy/clippy_lints/src/types/vec_box.rs @@ -7,7 +7,7 @@ use rustc_hir::{self as hir, def_id::DefId, GenericArg, QPath, TyKind}; use rustc_hir_analysis::hir_ty_to_ty; use rustc_lint::LateContext; use rustc_middle::ty::layout::LayoutOf; -use rustc_middle::ty::TypeVisitable; +use rustc_middle::ty::TypeVisitableExt; use rustc_span::symbol::sym; use super::VEC_BOX; diff --git a/src/tools/clippy/clippy_lints/src/zero_sized_map_values.rs b/src/tools/clippy/clippy_lints/src/zero_sized_map_values.rs index 6cf2a955fd5c6..93e4b023c5c79 100644 --- a/src/tools/clippy/clippy_lints/src/zero_sized_map_values.rs +++ b/src/tools/clippy/clippy_lints/src/zero_sized_map_values.rs @@ -5,7 +5,7 @@ use rustc_hir::{self as hir, HirId, ItemKind, Node}; use rustc_hir_analysis::hir_ty_to_ty; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::layout::LayoutOf as _; -use rustc_middle::ty::{Adt, Ty, TypeVisitable}; +use rustc_middle::ty::{Adt, Ty, TypeVisitableExt}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::sym; diff --git a/src/tools/clippy/clippy_utils/src/lib.rs b/src/tools/clippy/clippy_utils/src/lib.rs index b2edd1bbfef43..f02f8ecb43d72 100644 --- a/src/tools/clippy/clippy_utils/src/lib.rs +++ b/src/tools/clippy/clippy_utils/src/lib.rs @@ -104,7 +104,7 @@ use rustc_middle::ty::fast_reject::SimplifiedType::{ PtrSimplifiedType, SliceSimplifiedType, StrSimplifiedType, UintSimplifiedType, }; use rustc_middle::ty::{ - layout::IntegerExt, BorrowKind, ClosureKind, DefIdTree, Ty, TyCtxt, TypeAndMut, TypeVisitable, UpvarCapture, + layout::IntegerExt, BorrowKind, ClosureKind, DefIdTree, Ty, TyCtxt, TypeAndMut, TypeVisitableExt, UpvarCapture, }; use rustc_middle::ty::{FloatTy, IntTy, UintTy}; use rustc_span::hygiene::{ExpnKind, MacroKind}; diff --git a/src/tools/clippy/clippy_utils/src/mir/possible_borrower.rs b/src/tools/clippy/clippy_utils/src/mir/possible_borrower.rs index e9dc7351b58ef..920ce8e655be0 100644 --- a/src/tools/clippy/clippy_utils/src/mir/possible_borrower.rs +++ b/src/tools/clippy/clippy_utils/src/mir/possible_borrower.rs @@ -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, TyCtxt}; +use rustc_middle::ty::{self, visit::TypeVisitor, TyCtxt}; use rustc_mir_dataflow::{impls::MaybeStorageLive, Analysis, ResultsCursor}; use std::borrow::Cow; use std::ops::ControlFlow; diff --git a/src/tools/clippy/clippy_utils/src/ty.rs b/src/tools/clippy/clippy_utils/src/ty.rs index 2ed301fcc2291..34b9bb5994efa 100644 --- a/src/tools/clippy/clippy_utils/src/ty.rs +++ b/src/tools/clippy/clippy_utils/src/ty.rs @@ -17,8 +17,8 @@ use rustc_lint::LateContext; use rustc_middle::mir::interpret::{ConstValue, Scalar}; use rustc_middle::ty::{ self, AdtDef, AliasTy, AssocKind, Binder, BoundRegion, DefIdTree, FnSig, IntTy, List, ParamEnv, Predicate, - PredicateKind, Region, RegionKind, SubstsRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, ir::TypeVisitor, UintTy, - VariantDef, VariantDiscr, + PredicateKind, Region, RegionKind, SubstsRef, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor, UintTy, + VariantDef, VariantDiscr, TypeVisitableExt, }; use rustc_middle::ty::{GenericArg, GenericArgKind}; use rustc_span::symbol::Ident; @@ -847,7 +847,7 @@ pub fn for_each_top_level_late_bound_region( ControlFlow::Continue(()) } } - fn visit_binder>(&mut self, t: &Binder<'tcx, T>) -> ControlFlow { + fn visit_binder>>(&mut self, t: &Binder<'tcx, T>) -> ControlFlow { self.index += 1; let res = t.super_visit_with(self); self.index -= 1; diff --git a/tests/ui/impl-trait/normalize-tait-in-const.rs b/tests/ui/impl-trait/normalize-tait-in-const.rs index 020bcbb8396c9..d2e34c00b6422 100644 --- a/tests/ui/impl-trait/normalize-tait-in-const.rs +++ b/tests/ui/impl-trait/normalize-tait-in-const.rs @@ -2,6 +2,7 @@ // failure-status: 101 // normalize-stderr-test "note: .*\n\n" -> "" // normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" +// normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " // rustc-env:RUST_BACKTRACE=0 #![feature(type_alias_impl_trait)] diff --git a/tests/ui/impl-trait/normalize-tait-in-const.stderr b/tests/ui/impl-trait/normalize-tait-in-const.stderr index 99eed29207b4a..84b00918724e0 100644 --- a/tests/ui/impl-trait/normalize-tait-in-const.stderr +++ b/tests/ui/impl-trait/normalize-tait-in-const.stderr @@ -1,4 +1,4 @@ -error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:201:90: Failed to normalize fn(&'a Alias<'b>) {foo} as std::ops::FnOnce<(&&S,)>>::Output, maybe try to call `try_normalize_erasing_regions` instead +error: internal compiler error: compiler/rustc_middle/src/ty/normalize_erasing_regions.rs:LL:CC: Failed to normalize fn(&'a Alias<'b>) {foo} as std::ops::FnOnce<(&&S,)>>::Output, maybe try to call `try_normalize_erasing_regions` instead query stack during panic: #0 [eval_to_allocation_raw] const-evaluating + checking `BAR`