Auto merge of #108340 - eggyal:remove_traversal_trait_aliases, r=oli-obk
Remove type-traversal trait aliases
#107924 moved the type traversal (folding and visiting) traits into the type library, but created trait aliases in `rustc_middle` to minimise both the API churn for trait consumers and the arising boilerplate. As mentioned in that PR, an alternative approach of defining subtraits with blanket implementations of the respective supertraits was also considered at that time but was ruled out as not adding much value.
Unfortunately, it has since emerged that rust-analyzer has difficulty with these trait aliases at present, resulting in a degraded contributor experience (see the recent [r-a has become useless](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/r-a.20has.20become.20useless) topic on the #t-compiler/help Zulip stream).
This PR removes the trait aliases, and accordingly the underlying type library traits are now used directly; they are parameterised by `TyCtxt<'tcx>` rather than just the `'tcx` lifetime, and imports have been updated to reflect the fact that the trait aliases' explicitly named traits are no longer automatically brought into scope. These changes also roll-back the (no-longer required) workarounds to #107747 that were made in b409329c62
.
Since this PR is just a find+replace together with the changes necessary for compilation & tidy to pass, it's currently just one mega-commit. Let me know if you'd like it broken up.
r? `@oli-obk`
This commit is contained in:
commit
fdbc4329cb
192 changed files with 658 additions and 569 deletions
|
@ -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<R>,
|
||||
) -> Fallible<CanonicalQueryResponse<'tcx, R>>
|
||||
where
|
||||
K: TypeFoldable<'tcx>,
|
||||
R: Debug + TypeFoldable<'tcx>,
|
||||
K: TypeFoldable<TyCtxt<'tcx>>,
|
||||
R: Debug + TypeFoldable<TyCtxt<'tcx>>,
|
||||
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<TyCtxt<'tcx>>`.)
|
||||
fn enter_canonical_trait_query<K, R>(
|
||||
&mut self,
|
||||
canonical_key: &Canonical<'tcx, K>,
|
||||
operation: impl FnOnce(&ObligationCtxt<'_, 'tcx>, K) -> Fallible<R>,
|
||||
) -> Fallible<CanonicalQueryResponse<'tcx, R>>
|
||||
where
|
||||
K: TypeFoldable<'tcx>,
|
||||
R: Debug + TypeFoldable<'tcx>,
|
||||
K: TypeFoldable<TyCtxt<'tcx>>,
|
||||
R: Debug + TypeFoldable<TyCtxt<'tcx>>,
|
||||
Canonical<'tcx, QueryResponse<'tcx, R>>: ArenaAllocatable<'tcx>,
|
||||
{
|
||||
let (infcx, key, canonical_inference_vars) =
|
||||
|
|
|
@ -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<TyCtxt<'tcx>> + Copy + Eq {
|
||||
fn self_ty(self) -> Ty<'tcx>;
|
||||
|
||||
fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self;
|
||||
|
|
|
@ -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<T: TypeFoldable<'tcx> + Copy>(
|
||||
pub(super) fn instantiate_binder_with_infer<T: TypeFoldable<TyCtxt<'tcx>> + Copy>(
|
||||
&self,
|
||||
value: ty::Binder<'tcx, T>,
|
||||
) -> T {
|
||||
|
@ -148,7 +151,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||
)
|
||||
}
|
||||
|
||||
pub(super) fn instantiate_binder_with_placeholders<T: TypeFoldable<'tcx> + Copy>(
|
||||
pub(super) fn instantiate_binder_with_placeholders<T: TypeFoldable<TyCtxt<'tcx>> + Copy>(
|
||||
&self,
|
||||
value: ty::Binder<'tcx, T>,
|
||||
) -> T {
|
||||
|
@ -157,7 +160,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||
|
||||
pub(super) fn resolve_vars_if_possible<T>(&self, value: T) -> T
|
||||
where
|
||||
T: TypeFoldable<'tcx>,
|
||||
T: TypeFoldable<TyCtxt<'tcx>>,
|
||||
{
|
||||
self.infcx.resolve_vars_if_possible(value)
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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<PredicateObligation<'tcx>>,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -104,7 +104,7 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn normalize<T: TypeFoldable<'tcx>>(
|
||||
pub fn normalize<T: TypeFoldable<TyCtxt<'tcx>>>(
|
||||
&self,
|
||||
cause: &ObligationCause<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
|
@ -220,7 +220,7 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> {
|
|||
answer: T,
|
||||
) -> Fallible<CanonicalQueryResponse<'tcx, T>>
|
||||
where
|
||||
T: Debug + TypeFoldable<'tcx>,
|
||||
T: Debug + TypeFoldable<TyCtxt<'tcx>>,
|
||||
Canonical<'tcx, QueryResponse<'tcx, T>>: ArenaAllocatable<'tcx>,
|
||||
{
|
||||
self.infcx.make_canonicalized_query_response(
|
||||
|
|
|
@ -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<TyCtxt<'tcx>>
|
||||
+ Print<'tcx, FmtPrinter<'tcx, 'tcx>, Output = FmtPrinter<'tcx, 'tcx>>,
|
||||
<T as Print<'tcx, FmtPrinter<'tcx, 'tcx>>>::Error: std::fmt::Debug;
|
||||
|
||||
|
@ -121,7 +122,7 @@ pub trait TypeErrCtxtExt<'tcx> {
|
|||
) -> !
|
||||
where
|
||||
T: fmt::Display
|
||||
+ TypeFoldable<'tcx>
|
||||
+ TypeFoldable<TyCtxt<'tcx>>
|
||||
+ Print<'tcx, FmtPrinter<'tcx, 'tcx>, Output = FmtPrinter<'tcx, 'tcx>>,
|
||||
<T as Print<'tcx, 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<TyCtxt<'tcx>>
|
||||
+ Print<'tcx, FmtPrinter<'tcx, 'tcx>, Output = FmtPrinter<'tcx, 'tcx>>,
|
||||
<T as Print<'tcx, 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<TyCtxt<'tcx>>
|
||||
+ Print<'tcx, FmtPrinter<'tcx, 'tcx>, Output = FmtPrinter<'tcx, 'tcx>>,
|
||||
<T as Print<'tcx, FmtPrinter<'tcx, 'tcx>>>::Error: std::fmt::Debug,
|
||||
{
|
||||
|
@ -2970,7 +2971,7 @@ impl ArgKind {
|
|||
|
||||
struct HasNumericInferVisitor;
|
||||
|
||||
impl<'tcx> ty::ir::TypeVisitor<TyCtxt<'tcx>> for HasNumericInferVisitor {
|
||||
impl<'tcx> ty::TypeVisitor<TyCtxt<'tcx>> for HasNumericInferVisitor {
|
||||
type BreakTy = ();
|
||||
|
||||
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<TyCtxt<'tcx>>,
|
||||
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<T, Vec<FulfillmentError<'tcx>>>
|
||||
where
|
||||
T: TypeFoldable<'tcx>,
|
||||
T: TypeFoldable<TyCtxt<'tcx>>,
|
||||
{
|
||||
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<TyCtxt<'tcx>> for ReferencesOnlyParentGenerics<'tcx> {
|
||||
impl<'tcx> ty::TypeVisitor<TyCtxt<'tcx>> for ReferencesOnlyParentGenerics<'tcx> {
|
||||
type BreakTy = ();
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
// If this is a parameter from the trait item's own generics, then bail
|
||||
|
|
|
@ -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<TyCtxt<'tcx>>>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
trait_def_id: DefId,
|
||||
value: T,
|
||||
|
|
|
@ -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<T: TypeFoldable<'tcx>>(&self, t: T) -> InferOk<'tcx, T>;
|
||||
fn normalize<T: TypeFoldable<TyCtxt<'tcx>>>(&self, t: T) -> InferOk<'tcx, T>;
|
||||
}
|
||||
|
||||
impl<'tcx> NormalizeExt<'tcx> for At<'_, 'tcx> {
|
||||
fn normalize<T: TypeFoldable<'tcx>>(&self, value: T) -> InferOk<'tcx, T> {
|
||||
fn normalize<T: TypeFoldable<TyCtxt<'tcx>>>(&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<TyCtxt<'tcx>>,
|
||||
{
|
||||
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<PredicateObligation<'tcx>>,
|
||||
) -> T
|
||||
where
|
||||
T: TypeFoldable<'tcx>,
|
||||
T: TypeFoldable<TyCtxt<'tcx>>,
|
||||
{
|
||||
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<PredicateObligation<'tcx>>,
|
||||
) -> T
|
||||
where
|
||||
T: TypeFoldable<'tcx>,
|
||||
T: TypeFoldable<TyCtxt<'tcx>>,
|
||||
{
|
||||
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<TyCtxt<'tcx>>>(
|
||||
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<T: TypeFoldable<'tcx>>(&mut self, value: T) -> T {
|
||||
fn fold<T: TypeFoldable<TyCtxt<'tcx>>>(&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<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx
|
|||
self.selcx.tcx()
|
||||
}
|
||||
|
||||
fn fold_binder<T: TypeFoldable<'tcx>>(
|
||||
fn fold_binder<T: TypeFoldable<TyCtxt<'tcx>>>(
|
||||
&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<TyCtxt<'tcx>>,
|
||||
R: TypeFoldable<TyCtxt<'tcx>>,
|
||||
>(
|
||||
infcx: &'a InferCtxt<'tcx>,
|
||||
universe_indices: &'a mut Vec<Option<ty::UniverseIndex>>,
|
||||
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<T: TypeFoldable<'tcx>>(
|
||||
pub fn replace_bound_vars<T: TypeFoldable<TyCtxt<'tcx>>>(
|
||||
infcx: &'me InferCtxt<'tcx>,
|
||||
universe_indices: &'me mut Vec<Option<ty::UniverseIndex>>,
|
||||
value: T,
|
||||
|
@ -742,7 +750,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for BoundVarReplacer<'_, 'tcx> {
|
|||
self.infcx.tcx
|
||||
}
|
||||
|
||||
fn fold_binder<T: TypeFoldable<'tcx>>(
|
||||
fn fold_binder<T: TypeFoldable<TyCtxt<'tcx>>>(
|
||||
&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<T: TypeFoldable<'tcx>>(
|
||||
pub fn replace_placeholders<T: TypeFoldable<TyCtxt<'tcx>>>(
|
||||
infcx: &'me InferCtxt<'tcx>,
|
||||
mapped_regions: BTreeMap<ty::PlaceholderRegion, ty::BoundRegion>,
|
||||
mapped_types: BTreeMap<ty::PlaceholderType, ty::BoundTy>,
|
||||
|
@ -848,7 +856,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for PlaceholderReplacer<'_, 'tcx> {
|
|||
self.infcx.tcx
|
||||
}
|
||||
|
||||
fn fold_binder<T: TypeFoldable<'tcx>>(
|
||||
fn fold_binder<T: TypeFoldable<TyCtxt<'tcx>>>(
|
||||
&mut self,
|
||||
t: ty::Binder<'tcx, T>,
|
||||
) -> ty::Binder<'tcx, T> {
|
||||
|
|
|
@ -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<T>(&self, value: T) -> Result<Normalized<'tcx, T>, NoSolution>
|
||||
where
|
||||
T: TypeFoldable<'tcx>;
|
||||
T: TypeFoldable<TyCtxt<'tcx>>;
|
||||
}
|
||||
|
||||
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<T>(&self, value: T) -> Result<Normalized<'tcx, T>, NoSolution>
|
||||
where
|
||||
T: TypeFoldable<'tcx>,
|
||||
T: TypeFoldable<TyCtxt<'tcx>>,
|
||||
{
|
||||
debug!(
|
||||
"normalize::<{}>(value={:?}, param_env={:?}, cause={:?})",
|
||||
|
@ -116,7 +116,7 @@ struct MaxEscapingBoundVarVisitor {
|
|||
}
|
||||
|
||||
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for MaxEscapingBoundVarVisitor {
|
||||
fn visit_binder<T: TypeVisitable<'tcx>>(
|
||||
fn visit_binder<T: TypeVisitable<TyCtxt<'tcx>>>(
|
||||
&mut self,
|
||||
t: &ty::Binder<'tcx, T>,
|
||||
) -> ControlFlow<Self::BreakTy> {
|
||||
|
@ -177,7 +177,7 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx>
|
|||
self.infcx.tcx
|
||||
}
|
||||
|
||||
fn try_fold_binder<T: TypeFoldable<'tcx>>(
|
||||
fn try_fold_binder<T: TypeFoldable<TyCtxt<'tcx>>>(
|
||||
&mut self,
|
||||
t: ty::Binder<'tcx, T>,
|
||||
) -> Result<ty::Binder<'tcx, T>, Self::Error> {
|
||||
|
|
|
@ -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<TyCtxt<'tcx>> + 'tcx {
|
||||
type QueryResponse: TypeFoldable<TyCtxt<'tcx>>;
|
||||
|
||||
/// Give query the option for a simple fast path that never
|
||||
/// actually hits the tcx cache lookup etc. Return `Some(r)` with
|
||||
|
|
|
@ -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<TyCtxt<'tcx>> + Lift<'tcx> + Copy {
|
||||
fn type_op_method(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<T: Display + TypeFoldable<'tcx>, V>(
|
||||
fn check_recursion_limit<T: Display + TypeFoldable<TyCtxt<'tcx>>, V>(
|
||||
&self,
|
||||
obligation: &Obligation<'tcx, T>,
|
||||
error_obligation: &Obligation<'tcx, V>,
|
||||
|
|
|
@ -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::*;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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};
|
||||
|
|
|
@ -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};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue