mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
Add tcx lifetime to Binder
This commit is contained in:
parent
74851f4cf3
commit
62a49c3bb8
@ -293,7 +293,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
|
|||||||
self.tcx
|
self.tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_binder<T>(&mut self, t: ty::Binder<T>) -> ty::Binder<T>
|
fn fold_binder<T>(&mut self, t: ty::Binder<'tcx, T>) -> ty::Binder<'tcx, T>
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
|
@ -545,9 +545,9 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
|
|||||||
|
|
||||||
fn binders<T>(
|
fn binders<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
a: ty::Binder<T>,
|
a: ty::Binder<'tcx, T>,
|
||||||
b: ty::Binder<T>,
|
b: ty::Binder<'tcx, T>,
|
||||||
) -> RelateResult<'tcx, ty::Binder<T>>
|
) -> RelateResult<'tcx, ty::Binder<'tcx, T>>
|
||||||
where
|
where
|
||||||
T: Relate<'tcx>,
|
T: Relate<'tcx>,
|
||||||
{
|
{
|
||||||
@ -840,9 +840,9 @@ impl TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
|
|||||||
|
|
||||||
fn binders<T>(
|
fn binders<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
a: ty::Binder<T>,
|
a: ty::Binder<'tcx, T>,
|
||||||
b: ty::Binder<T>,
|
b: ty::Binder<'tcx, T>,
|
||||||
) -> RelateResult<'tcx, ty::Binder<T>>
|
) -> RelateResult<'tcx, ty::Binder<'tcx, T>>
|
||||||
where
|
where
|
||||||
T: Relate<'tcx>,
|
T: Relate<'tcx>,
|
||||||
{
|
{
|
||||||
|
@ -124,9 +124,9 @@ impl TypeRelation<'tcx> for Equate<'combine, 'infcx, 'tcx> {
|
|||||||
|
|
||||||
fn binders<T>(
|
fn binders<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
a: ty::Binder<T>,
|
a: ty::Binder<'tcx, T>,
|
||||||
b: ty::Binder<T>,
|
b: ty::Binder<'tcx, T>,
|
||||||
) -> RelateResult<'tcx, ty::Binder<T>>
|
) -> RelateResult<'tcx, ty::Binder<'tcx, T>>
|
||||||
where
|
where
|
||||||
T: Relate<'tcx>,
|
T: Relate<'tcx>,
|
||||||
{
|
{
|
||||||
|
@ -514,7 +514,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
|
|
||||||
fn print_dyn_existential(
|
fn print_dyn_existential(
|
||||||
self,
|
self,
|
||||||
_predicates: &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>>,
|
_predicates: &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
|
||||||
) -> Result<Self::DynExistential, Self::Error> {
|
) -> Result<Self::DynExistential, Self::Error> {
|
||||||
Err(NonTrivialPath)
|
Err(NonTrivialPath)
|
||||||
}
|
}
|
||||||
|
@ -85,9 +85,9 @@ impl TypeRelation<'tcx> for Glb<'combine, 'infcx, 'tcx> {
|
|||||||
|
|
||||||
fn binders<T>(
|
fn binders<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
a: ty::Binder<T>,
|
a: ty::Binder<'tcx, T>,
|
||||||
b: ty::Binder<T>,
|
b: ty::Binder<'tcx, T>,
|
||||||
) -> RelateResult<'tcx, ty::Binder<T>>
|
) -> RelateResult<'tcx, ty::Binder<'tcx, T>>
|
||||||
where
|
where
|
||||||
T: Relate<'tcx>,
|
T: Relate<'tcx>,
|
||||||
{
|
{
|
||||||
|
@ -11,10 +11,10 @@ use rustc_middle::ty::{self, Binder, TypeFoldable};
|
|||||||
impl<'a, 'tcx> CombineFields<'a, 'tcx> {
|
impl<'a, 'tcx> CombineFields<'a, 'tcx> {
|
||||||
pub fn higher_ranked_sub<T>(
|
pub fn higher_ranked_sub<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
a: Binder<T>,
|
a: Binder<'tcx, T>,
|
||||||
b: Binder<T>,
|
b: Binder<'tcx, T>,
|
||||||
a_is_expected: bool,
|
a_is_expected: bool,
|
||||||
) -> RelateResult<'tcx, Binder<T>>
|
) -> RelateResult<'tcx, Binder<'tcx, T>>
|
||||||
where
|
where
|
||||||
T: Relate<'tcx>,
|
T: Relate<'tcx>,
|
||||||
{
|
{
|
||||||
@ -69,7 +69,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
/// the [rustc dev guide].
|
/// the [rustc dev guide].
|
||||||
///
|
///
|
||||||
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html
|
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/traits/hrtb.html
|
||||||
pub fn replace_bound_vars_with_placeholders<T>(&self, binder: ty::Binder<T>) -> T
|
pub fn replace_bound_vars_with_placeholders<T>(&self, binder: ty::Binder<'tcx, T>) -> T
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
|
@ -85,9 +85,9 @@ impl TypeRelation<'tcx> for Lub<'combine, 'infcx, 'tcx> {
|
|||||||
|
|
||||||
fn binders<T>(
|
fn binders<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
a: ty::Binder<T>,
|
a: ty::Binder<'tcx, T>,
|
||||||
b: ty::Binder<T>,
|
b: ty::Binder<'tcx, T>,
|
||||||
) -> RelateResult<'tcx, ty::Binder<T>>
|
) -> RelateResult<'tcx, ty::Binder<'tcx, T>>
|
||||||
where
|
where
|
||||||
T: Relate<'tcx>,
|
T: Relate<'tcx>,
|
||||||
{
|
{
|
||||||
|
@ -1406,7 +1406,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
span: Span,
|
span: Span,
|
||||||
lbrct: LateBoundRegionConversionTime,
|
lbrct: LateBoundRegionConversionTime,
|
||||||
value: ty::Binder<T>,
|
value: ty::Binder<'tcx, T>,
|
||||||
) -> (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
|
) -> (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
|
@ -157,7 +157,7 @@ where
|
|||||||
|
|
||||||
fn create_scope(
|
fn create_scope(
|
||||||
&mut self,
|
&mut self,
|
||||||
value: ty::Binder<impl Relate<'tcx>>,
|
value: ty::Binder<'tcx, impl Relate<'tcx>>,
|
||||||
universally_quantified: UniversallyQuantified,
|
universally_quantified: UniversallyQuantified,
|
||||||
) -> BoundRegionScope<'tcx> {
|
) -> BoundRegionScope<'tcx> {
|
||||||
let mut scope = BoundRegionScope::default();
|
let mut scope = BoundRegionScope::default();
|
||||||
@ -608,9 +608,9 @@ where
|
|||||||
|
|
||||||
fn binders<T>(
|
fn binders<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
a: ty::Binder<T>,
|
a: ty::Binder<'tcx, T>,
|
||||||
b: ty::Binder<T>,
|
b: ty::Binder<'tcx, T>,
|
||||||
) -> RelateResult<'tcx, ty::Binder<T>>
|
) -> RelateResult<'tcx, ty::Binder<'tcx, T>>
|
||||||
where
|
where
|
||||||
T: Relate<'tcx>,
|
T: Relate<'tcx>,
|
||||||
{
|
{
|
||||||
@ -744,7 +744,7 @@ struct ScopeInstantiator<'me, 'tcx> {
|
|||||||
impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
|
impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
|
||||||
fn visit_binder<T: TypeFoldable<'tcx>>(
|
fn visit_binder<T: TypeFoldable<'tcx>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
t: &ty::Binder<T>,
|
t: &ty::Binder<'tcx, T>,
|
||||||
) -> ControlFlow<Self::BreakTy> {
|
) -> ControlFlow<Self::BreakTy> {
|
||||||
self.target_index.shift_in(1);
|
self.target_index.shift_in(1);
|
||||||
t.super_visit_with(self);
|
t.super_visit_with(self);
|
||||||
@ -997,9 +997,9 @@ where
|
|||||||
|
|
||||||
fn binders<T>(
|
fn binders<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
a: ty::Binder<T>,
|
a: ty::Binder<'tcx, T>,
|
||||||
_: ty::Binder<T>,
|
_: ty::Binder<'tcx, T>,
|
||||||
) -> RelateResult<'tcx, ty::Binder<T>>
|
) -> RelateResult<'tcx, ty::Binder<'tcx, T>>
|
||||||
where
|
where
|
||||||
T: Relate<'tcx>,
|
T: Relate<'tcx>,
|
||||||
{
|
{
|
||||||
|
@ -162,9 +162,9 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> {
|
|||||||
|
|
||||||
fn binders<T>(
|
fn binders<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
a: ty::Binder<T>,
|
a: ty::Binder<'tcx, T>,
|
||||||
b: ty::Binder<T>,
|
b: ty::Binder<'tcx, T>,
|
||||||
) -> RelateResult<'tcx, ty::Binder<T>>
|
) -> RelateResult<'tcx, ty::Binder<'tcx, T>>
|
||||||
where
|
where
|
||||||
T: Relate<'tcx>,
|
T: Relate<'tcx>,
|
||||||
{
|
{
|
||||||
|
@ -128,7 +128,7 @@ impl<'tcx> FulfillmentError<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TraitObligation<'tcx> {
|
impl<'tcx> TraitObligation<'tcx> {
|
||||||
pub fn self_ty(&self) -> ty::Binder<Ty<'tcx>> {
|
pub fn self_ty(&self) -> ty::Binder<'tcx, Ty<'tcx>> {
|
||||||
self.predicate.map_bound(|p| p.self_ty())
|
self.predicate.map_bound(|p| p.self_ty())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -909,7 +909,7 @@ impl<'tcx> LateContext<'tcx> {
|
|||||||
|
|
||||||
fn print_dyn_existential(
|
fn print_dyn_existential(
|
||||||
self,
|
self,
|
||||||
_predicates: &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>>,
|
_predicates: &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
|
||||||
) -> Result<Self::DynExistential, Self::Error> {
|
) -> Result<Self::DynExistential, Self::Error> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ impl<'tcx> HashStable<StableHashingContext<'tcx>> for ty::BoundVar {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T> HashStable<StableHashingContext<'a>> for ty::Binder<T>
|
impl<'a, 'tcx, T> HashStable<StableHashingContext<'a>> for ty::Binder<'tcx, T>
|
||||||
where
|
where
|
||||||
T: HashStable<StableHashingContext<'a>>,
|
T: HashStable<StableHashingContext<'a>>,
|
||||||
{
|
{
|
||||||
|
@ -277,7 +277,7 @@ impl<'tcx, V> Canonical<'tcx, V> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub type QueryOutlivesConstraint<'tcx> =
|
pub type QueryOutlivesConstraint<'tcx> =
|
||||||
ty::Binder<ty::OutlivesPredicate<GenericArg<'tcx>, Region<'tcx>>>;
|
ty::Binder<'tcx, ty::OutlivesPredicate<GenericArg<'tcx>, Region<'tcx>>>;
|
||||||
|
|
||||||
TrivialTypeFoldableAndLiftImpls! {
|
TrivialTypeFoldableAndLiftImpls! {
|
||||||
for <'tcx> {
|
for <'tcx> {
|
||||||
|
@ -112,9 +112,9 @@ impl TypeRelation<'tcx> for Match<'tcx> {
|
|||||||
|
|
||||||
fn binders<T>(
|
fn binders<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
a: ty::Binder<T>,
|
a: ty::Binder<'tcx, T>,
|
||||||
b: ty::Binder<T>,
|
b: ty::Binder<'tcx, T>,
|
||||||
) -> RelateResult<'tcx, ty::Binder<T>>
|
) -> RelateResult<'tcx, ty::Binder<'tcx, T>>
|
||||||
where
|
where
|
||||||
T: Relate<'tcx>,
|
T: Relate<'tcx>,
|
||||||
{
|
{
|
||||||
|
@ -120,7 +120,7 @@ impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Ty<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for ty::Binder<ty::PredicateKind<'tcx>> {
|
impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for ty::Binder<'tcx, ty::PredicateKind<'tcx>> {
|
||||||
fn encode(&self, e: &mut E) -> Result<(), E::Error> {
|
fn encode(&self, e: &mut E) -> Result<(), E::Error> {
|
||||||
encode_with_shorthand(e, &self.skip_binder(), TyEncoder::predicate_shorthands)
|
encode_with_shorthand(e, &self.skip_binder(), TyEncoder::predicate_shorthands)
|
||||||
}
|
}
|
||||||
@ -226,8 +226,8 @@ impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Ty<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ty::Binder<ty::PredicateKind<'tcx>> {
|
impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ty::Binder<'tcx, ty::PredicateKind<'tcx>> {
|
||||||
fn decode(decoder: &mut D) -> Result<ty::Binder<ty::PredicateKind<'tcx>>, D::Error> {
|
fn decode(decoder: &mut D) -> Result<ty::Binder<'tcx, ty::PredicateKind<'tcx>>, D::Error> {
|
||||||
// Handle shorthands first, if we have an usize > 0x80.
|
// Handle shorthands first, if we have an usize > 0x80.
|
||||||
Ok(ty::Binder::bind(if decoder.positioned_at_shorthand() {
|
Ok(ty::Binder::bind(if decoder.positioned_at_shorthand() {
|
||||||
let pos = decoder.read_usize()?;
|
let pos = decoder.read_usize()?;
|
||||||
@ -319,7 +319,7 @@ impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for ty::List<Ty<'tcx>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D>
|
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D>
|
||||||
for ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>>
|
for ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>
|
||||||
{
|
{
|
||||||
fn decode(decoder: &mut D) -> Result<&'tcx Self, D::Error> {
|
fn decode(decoder: &mut D) -> Result<&'tcx Self, D::Error> {
|
||||||
let len = decoder.read_usize()?;
|
let len = decoder.read_usize()?;
|
||||||
@ -382,7 +382,7 @@ impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for [mir::abstract_const::N
|
|||||||
impl_decodable_via_ref! {
|
impl_decodable_via_ref! {
|
||||||
&'tcx ty::TypeckResults<'tcx>,
|
&'tcx ty::TypeckResults<'tcx>,
|
||||||
&'tcx ty::List<Ty<'tcx>>,
|
&'tcx ty::List<Ty<'tcx>>,
|
||||||
&'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>>,
|
&'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
|
||||||
&'tcx Allocation,
|
&'tcx Allocation,
|
||||||
&'tcx mir::Body<'tcx>,
|
&'tcx mir::Body<'tcx>,
|
||||||
&'tcx mir::UnsafetyCheckResult,
|
&'tcx mir::UnsafetyCheckResult,
|
||||||
@ -488,12 +488,12 @@ macro_rules! implement_ty_decoder {
|
|||||||
macro_rules! impl_binder_encode_decode {
|
macro_rules! impl_binder_encode_decode {
|
||||||
($($t:ty),+ $(,)?) => {
|
($($t:ty),+ $(,)?) => {
|
||||||
$(
|
$(
|
||||||
impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for ty::Binder<$t> {
|
impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for ty::Binder<'tcx, $t> {
|
||||||
fn encode(&self, e: &mut E) -> Result<(), E::Error> {
|
fn encode(&self, e: &mut E) -> Result<(), E::Error> {
|
||||||
self.as_ref().skip_binder().encode(e)
|
self.as_ref().skip_binder().encode(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ty::Binder<$t> {
|
impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for ty::Binder<'tcx, $t> {
|
||||||
fn decode(decoder: &mut D) -> Result<Self, D::Error> {
|
fn decode(decoder: &mut D) -> Result<Self, D::Error> {
|
||||||
Ok(ty::Binder::bind(Decodable::decode(decoder)?))
|
Ok(ty::Binder::bind(Decodable::decode(decoder)?))
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,8 @@ pub struct CtxtInterners<'tcx> {
|
|||||||
substs: InternedSet<'tcx, InternalSubsts<'tcx>>,
|
substs: InternedSet<'tcx, InternalSubsts<'tcx>>,
|
||||||
canonical_var_infos: InternedSet<'tcx, List<CanonicalVarInfo<'tcx>>>,
|
canonical_var_infos: InternedSet<'tcx, List<CanonicalVarInfo<'tcx>>>,
|
||||||
region: InternedSet<'tcx, RegionKind>,
|
region: InternedSet<'tcx, RegionKind>,
|
||||||
poly_existential_predicates: InternedSet<'tcx, List<ty::Binder<ExistentialPredicate<'tcx>>>>,
|
poly_existential_predicates:
|
||||||
|
InternedSet<'tcx, List<ty::Binder<'tcx, ExistentialPredicate<'tcx>>>>,
|
||||||
predicate: InternedSet<'tcx, PredicateInner<'tcx>>,
|
predicate: InternedSet<'tcx, PredicateInner<'tcx>>,
|
||||||
predicates: InternedSet<'tcx, List<Predicate<'tcx>>>,
|
predicates: InternedSet<'tcx, List<Predicate<'tcx>>>,
|
||||||
projs: InternedSet<'tcx, List<ProjectionKind>>,
|
projs: InternedSet<'tcx, List<ProjectionKind>>,
|
||||||
@ -136,7 +137,10 @@ impl<'tcx> CtxtInterners<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
fn intern_predicate(&self, kind: Binder<PredicateKind<'tcx>>) -> &'tcx PredicateInner<'tcx> {
|
fn intern_predicate(
|
||||||
|
&self,
|
||||||
|
kind: Binder<'tcx, PredicateKind<'tcx>>,
|
||||||
|
) -> &'tcx PredicateInner<'tcx> {
|
||||||
self.predicate
|
self.predicate
|
||||||
.intern(kind, |kind| {
|
.intern(kind, |kind| {
|
||||||
let flags = super::flags::FlagComputation::for_predicate(kind);
|
let flags = super::flags::FlagComputation::for_predicate(kind);
|
||||||
@ -449,7 +453,7 @@ pub struct TypeckResults<'tcx> {
|
|||||||
|
|
||||||
/// Stores the type, expression, span and optional scope span of all types
|
/// Stores the type, expression, span and optional scope span of all types
|
||||||
/// that are live across the yield of this generator (if a generator).
|
/// that are live across the yield of this generator (if a generator).
|
||||||
pub generator_interior_types: ty::Binder<Vec<GeneratorInteriorTypeCause<'tcx>>>,
|
pub generator_interior_types: ty::Binder<'tcx, Vec<GeneratorInteriorTypeCause<'tcx>>>,
|
||||||
|
|
||||||
/// We sometimes treat byte string literals (which are of type `&[u8; N]`)
|
/// We sometimes treat byte string literals (which are of type `&[u8; N]`)
|
||||||
/// as `&[u8]`, depending on the pattern in which they are used.
|
/// as `&[u8]`, depending on the pattern in which they are used.
|
||||||
@ -1616,7 +1620,7 @@ nop_lift! {allocation; &'a Allocation => &'tcx Allocation}
|
|||||||
nop_lift! {predicate; &'a PredicateInner<'a> => &'tcx PredicateInner<'tcx>}
|
nop_lift! {predicate; &'a PredicateInner<'a> => &'tcx PredicateInner<'tcx>}
|
||||||
|
|
||||||
nop_list_lift! {type_list; Ty<'a> => Ty<'tcx>}
|
nop_list_lift! {type_list; Ty<'a> => Ty<'tcx>}
|
||||||
nop_list_lift! {poly_existential_predicates; ty::Binder<ExistentialPredicate<'a>> => ty::Binder<ExistentialPredicate<'tcx>>}
|
nop_list_lift! {poly_existential_predicates; ty::Binder<'a, ExistentialPredicate<'a>> => ty::Binder<'tcx, ExistentialPredicate<'tcx>>}
|
||||||
nop_list_lift! {predicates; Predicate<'a> => Predicate<'tcx>}
|
nop_list_lift! {predicates; Predicate<'a> => Predicate<'tcx>}
|
||||||
nop_list_lift! {canonical_var_infos; CanonicalVarInfo<'a> => CanonicalVarInfo<'tcx>}
|
nop_list_lift! {canonical_var_infos; CanonicalVarInfo<'a> => CanonicalVarInfo<'tcx>}
|
||||||
nop_list_lift! {projs; ProjectionKind => ProjectionKind}
|
nop_list_lift! {projs; ProjectionKind => ProjectionKind}
|
||||||
@ -1965,8 +1969,8 @@ impl<'tcx> Hash for Interned<'tcx, PredicateInner<'tcx>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Borrow<Binder<PredicateKind<'tcx>>> for Interned<'tcx, PredicateInner<'tcx>> {
|
impl<'tcx> Borrow<Binder<'tcx, PredicateKind<'tcx>>> for Interned<'tcx, PredicateInner<'tcx>> {
|
||||||
fn borrow<'a>(&'a self) -> &'a Binder<PredicateKind<'tcx>> {
|
fn borrow<'a>(&'a self) -> &'a Binder<'tcx, PredicateKind<'tcx>> {
|
||||||
&self.0.kind
|
&self.0.kind
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2072,7 +2076,7 @@ slice_interners!(
|
|||||||
substs: _intern_substs(GenericArg<'tcx>),
|
substs: _intern_substs(GenericArg<'tcx>),
|
||||||
canonical_var_infos: _intern_canonical_var_infos(CanonicalVarInfo<'tcx>),
|
canonical_var_infos: _intern_canonical_var_infos(CanonicalVarInfo<'tcx>),
|
||||||
poly_existential_predicates:
|
poly_existential_predicates:
|
||||||
_intern_poly_existential_predicates(ty::Binder<ExistentialPredicate<'tcx>>),
|
_intern_poly_existential_predicates(ty::Binder<'tcx, ExistentialPredicate<'tcx>>),
|
||||||
predicates: _intern_predicates(Predicate<'tcx>),
|
predicates: _intern_predicates(Predicate<'tcx>),
|
||||||
projs: _intern_projs(ProjectionKind),
|
projs: _intern_projs(ProjectionKind),
|
||||||
place_elems: _intern_place_elems(PlaceElem<'tcx>),
|
place_elems: _intern_place_elems(PlaceElem<'tcx>),
|
||||||
@ -2158,7 +2162,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn mk_predicate(self, binder: Binder<PredicateKind<'tcx>>) -> Predicate<'tcx> {
|
pub fn mk_predicate(self, binder: Binder<'tcx, PredicateKind<'tcx>>) -> Predicate<'tcx> {
|
||||||
let inner = self.interners.intern_predicate(binder);
|
let inner = self.interners.intern_predicate(binder);
|
||||||
Predicate { inner }
|
Predicate { inner }
|
||||||
}
|
}
|
||||||
@ -2167,7 +2171,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
pub fn reuse_or_mk_predicate(
|
pub fn reuse_or_mk_predicate(
|
||||||
self,
|
self,
|
||||||
pred: Predicate<'tcx>,
|
pred: Predicate<'tcx>,
|
||||||
binder: Binder<PredicateKind<'tcx>>,
|
binder: Binder<'tcx, PredicateKind<'tcx>>,
|
||||||
) -> Predicate<'tcx> {
|
) -> Predicate<'tcx> {
|
||||||
if pred.kind() != binder { self.mk_predicate(binder) } else { pred }
|
if pred.kind() != binder { self.mk_predicate(binder) } else { pred }
|
||||||
}
|
}
|
||||||
@ -2334,7 +2338,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn mk_dynamic(
|
pub fn mk_dynamic(
|
||||||
self,
|
self,
|
||||||
obj: &'tcx List<ty::Binder<ExistentialPredicate<'tcx>>>,
|
obj: &'tcx List<ty::Binder<'tcx, ExistentialPredicate<'tcx>>>,
|
||||||
reg: ty::Region<'tcx>,
|
reg: ty::Region<'tcx>,
|
||||||
) -> Ty<'tcx> {
|
) -> Ty<'tcx> {
|
||||||
self.mk_ty(Dynamic(obj, reg))
|
self.mk_ty(Dynamic(obj, reg))
|
||||||
@ -2361,7 +2365,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn mk_generator_witness(self, types: ty::Binder<&'tcx List<Ty<'tcx>>>) -> Ty<'tcx> {
|
pub fn mk_generator_witness(self, types: ty::Binder<'tcx, &'tcx List<Ty<'tcx>>>) -> Ty<'tcx> {
|
||||||
self.mk_ty(GeneratorWitness(types))
|
self.mk_ty(GeneratorWitness(types))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2466,8 +2470,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
|
|
||||||
pub fn intern_poly_existential_predicates(
|
pub fn intern_poly_existential_predicates(
|
||||||
self,
|
self,
|
||||||
eps: &[ty::Binder<ExistentialPredicate<'tcx>>],
|
eps: &[ty::Binder<'tcx, ExistentialPredicate<'tcx>>],
|
||||||
) -> &'tcx List<ty::Binder<ExistentialPredicate<'tcx>>> {
|
) -> &'tcx List<ty::Binder<'tcx, ExistentialPredicate<'tcx>>> {
|
||||||
assert!(!eps.is_empty());
|
assert!(!eps.is_empty());
|
||||||
assert!(
|
assert!(
|
||||||
eps.array_windows()
|
eps.array_windows()
|
||||||
@ -2533,8 +2537,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
|
|
||||||
pub fn mk_poly_existential_predicates<
|
pub fn mk_poly_existential_predicates<
|
||||||
I: InternAs<
|
I: InternAs<
|
||||||
[ty::Binder<ExistentialPredicate<'tcx>>],
|
[ty::Binder<'tcx, ExistentialPredicate<'tcx>>],
|
||||||
&'tcx List<ty::Binder<ExistentialPredicate<'tcx>>>,
|
&'tcx List<ty::Binder<'tcx, ExistentialPredicate<'tcx>>>,
|
||||||
>,
|
>,
|
||||||
>(
|
>(
|
||||||
self,
|
self,
|
||||||
|
@ -43,7 +43,7 @@ impl TypeFolder<'tcx> for RegionEraserVisitor<'tcx> {
|
|||||||
if ty.needs_infer() { ty.super_fold_with(self) } else { self.tcx.erase_regions_ty(ty) }
|
if ty.needs_infer() { ty.super_fold_with(self) } else { self.tcx.erase_regions_ty(ty) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_binder<T>(&mut self, t: ty::Binder<T>) -> ty::Binder<T>
|
fn fold_binder<T>(&mut self, t: ty::Binder<'tcx, T>) -> ty::Binder<'tcx, T>
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,9 @@ pub enum TypeError<'tcx> {
|
|||||||
CyclicTy(Ty<'tcx>),
|
CyclicTy(Ty<'tcx>),
|
||||||
CyclicConst(&'tcx ty::Const<'tcx>),
|
CyclicConst(&'tcx ty::Const<'tcx>),
|
||||||
ProjectionMismatched(ExpectedFound<DefId>),
|
ProjectionMismatched(ExpectedFound<DefId>),
|
||||||
ExistentialMismatch(ExpectedFound<&'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>>>),
|
ExistentialMismatch(
|
||||||
|
ExpectedFound<&'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>>,
|
||||||
|
),
|
||||||
ObjectUnsafeCoercion(DefId),
|
ObjectUnsafeCoercion(DefId),
|
||||||
ConstMismatch(ExpectedFound<&'tcx ty::Const<'tcx>>),
|
ConstMismatch(ExpectedFound<&'tcx ty::Const<'tcx>>),
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ impl FlagComputation {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn for_predicate(binder: ty::Binder<ty::PredicateKind<'_>>) -> FlagComputation {
|
pub fn for_predicate(binder: ty::Binder<'tcx, ty::PredicateKind<'_>>) -> FlagComputation {
|
||||||
let mut result = FlagComputation::new();
|
let mut result = FlagComputation::new();
|
||||||
result.add_predicate(binder);
|
result.add_predicate(binder);
|
||||||
result
|
result
|
||||||
@ -53,7 +53,7 @@ impl FlagComputation {
|
|||||||
|
|
||||||
/// Adds the flags/depth from a set of types that appear within the current type, but within a
|
/// Adds the flags/depth from a set of types that appear within the current type, but within a
|
||||||
/// region binder.
|
/// region binder.
|
||||||
fn bound_computation<T, F>(&mut self, value: ty::Binder<T>, f: F)
|
fn bound_computation<T, F>(&mut self, value: ty::Binder<'_, T>, f: F)
|
||||||
where
|
where
|
||||||
F: FnOnce(&mut Self, T),
|
F: FnOnce(&mut Self, T),
|
||||||
{
|
{
|
||||||
@ -204,7 +204,7 @@ impl FlagComputation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_predicate(&mut self, binder: ty::Binder<ty::PredicateKind<'_>>) {
|
fn add_predicate(&mut self, binder: ty::Binder<'tcx, ty::PredicateKind<'_>>) {
|
||||||
self.bound_computation(binder, |computation, atom| computation.add_predicate_atom(atom));
|
self.bound_computation(binder, |computation, atom| computation.add_predicate_atom(atom));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ impl TypeFoldable<'tcx> for hir::Constness {
|
|||||||
pub trait TypeFolder<'tcx>: Sized {
|
pub trait TypeFolder<'tcx>: Sized {
|
||||||
fn tcx<'a>(&'a self) -> TyCtxt<'tcx>;
|
fn tcx<'a>(&'a self) -> TyCtxt<'tcx>;
|
||||||
|
|
||||||
fn fold_binder<T>(&mut self, t: Binder<T>) -> Binder<T>
|
fn fold_binder<T>(&mut self, t: Binder<'tcx, T>) -> Binder<'tcx, T>
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
@ -184,7 +184,10 @@ pub trait TypeFolder<'tcx>: Sized {
|
|||||||
pub trait TypeVisitor<'tcx>: Sized {
|
pub trait TypeVisitor<'tcx>: Sized {
|
||||||
type BreakTy = !;
|
type BreakTy = !;
|
||||||
|
|
||||||
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<Self::BreakTy> {
|
fn visit_binder<T: TypeFoldable<'tcx>>(
|
||||||
|
&mut self,
|
||||||
|
t: &Binder<'tcx, T>,
|
||||||
|
) -> ControlFlow<Self::BreakTy> {
|
||||||
t.super_visit_with(self)
|
t.super_visit_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +325,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
|
|
||||||
fn visit_binder<T: TypeFoldable<'tcx>>(
|
fn visit_binder<T: TypeFoldable<'tcx>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
t: &Binder<T>,
|
t: &Binder<'tcx, T>,
|
||||||
) -> ControlFlow<Self::BreakTy> {
|
) -> ControlFlow<Self::BreakTy> {
|
||||||
self.outer_index.shift_in(1);
|
self.outer_index.shift_in(1);
|
||||||
let result = t.as_ref().skip_binder().visit_with(self);
|
let result = t.as_ref().skip_binder().visit_with(self);
|
||||||
@ -400,7 +403,10 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionFolder<'a, 'tcx> {
|
|||||||
self.tcx
|
self.tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: ty::Binder<T>) -> ty::Binder<T> {
|
fn fold_binder<T: TypeFoldable<'tcx>>(
|
||||||
|
&mut self,
|
||||||
|
t: ty::Binder<'tcx, T>,
|
||||||
|
) -> ty::Binder<'tcx, T> {
|
||||||
self.current_index.shift_in(1);
|
self.current_index.shift_in(1);
|
||||||
let t = t.super_fold_with(self);
|
let t = t.super_fold_with(self);
|
||||||
self.current_index.shift_out(1);
|
self.current_index.shift_out(1);
|
||||||
@ -460,7 +466,10 @@ impl<'a, 'tcx> TypeFolder<'tcx> for BoundVarReplacer<'a, 'tcx> {
|
|||||||
self.tcx
|
self.tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: ty::Binder<T>) -> ty::Binder<T> {
|
fn fold_binder<T: TypeFoldable<'tcx>>(
|
||||||
|
&mut self,
|
||||||
|
t: ty::Binder<'tcx, T>,
|
||||||
|
) -> ty::Binder<'tcx, T> {
|
||||||
self.current_index.shift_in(1);
|
self.current_index.shift_in(1);
|
||||||
let t = t.super_fold_with(self);
|
let t = t.super_fold_with(self);
|
||||||
self.current_index.shift_out(1);
|
self.current_index.shift_out(1);
|
||||||
@ -538,7 +547,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
/// contain escaping bound types.
|
/// contain escaping bound types.
|
||||||
pub fn replace_late_bound_regions<T, F>(
|
pub fn replace_late_bound_regions<T, F>(
|
||||||
self,
|
self,
|
||||||
value: Binder<T>,
|
value: Binder<'tcx, T>,
|
||||||
mut fld_r: F,
|
mut fld_r: F,
|
||||||
) -> (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
|
) -> (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
|
||||||
where
|
where
|
||||||
@ -588,7 +597,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
/// types.
|
/// types.
|
||||||
pub fn replace_bound_vars<T, F, G, H>(
|
pub fn replace_bound_vars<T, F, G, H>(
|
||||||
self,
|
self,
|
||||||
value: Binder<T>,
|
value: Binder<'tcx, T>,
|
||||||
mut fld_r: F,
|
mut fld_r: F,
|
||||||
fld_t: G,
|
fld_t: G,
|
||||||
fld_c: H,
|
fld_c: H,
|
||||||
@ -607,7 +616,11 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
|
|
||||||
/// Replaces any late-bound regions bound in `value` with
|
/// Replaces any late-bound regions bound in `value` with
|
||||||
/// free variants attached to `all_outlive_scope`.
|
/// free variants attached to `all_outlive_scope`.
|
||||||
pub fn liberate_late_bound_regions<T>(self, all_outlive_scope: DefId, value: ty::Binder<T>) -> T
|
pub fn liberate_late_bound_regions<T>(
|
||||||
|
self,
|
||||||
|
all_outlive_scope: DefId,
|
||||||
|
value: ty::Binder<'tcx, T>,
|
||||||
|
) -> T
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
@ -626,7 +639,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
/// variables will also be equated.
|
/// variables will also be equated.
|
||||||
pub fn collect_constrained_late_bound_regions<T>(
|
pub fn collect_constrained_late_bound_regions<T>(
|
||||||
self,
|
self,
|
||||||
value: &Binder<T>,
|
value: &Binder<'tcx, T>,
|
||||||
) -> FxHashSet<ty::BoundRegionKind>
|
) -> FxHashSet<ty::BoundRegionKind>
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
@ -637,7 +650,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
/// Returns a set of all late-bound regions that appear in `value` anywhere.
|
/// Returns a set of all late-bound regions that appear in `value` anywhere.
|
||||||
pub fn collect_referenced_late_bound_regions<T>(
|
pub fn collect_referenced_late_bound_regions<T>(
|
||||||
self,
|
self,
|
||||||
value: &Binder<T>,
|
value: &Binder<'tcx, T>,
|
||||||
) -> FxHashSet<ty::BoundRegionKind>
|
) -> FxHashSet<ty::BoundRegionKind>
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
@ -647,7 +660,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
|
|
||||||
fn collect_late_bound_regions<T>(
|
fn collect_late_bound_regions<T>(
|
||||||
self,
|
self,
|
||||||
value: &Binder<T>,
|
value: &Binder<'tcx, T>,
|
||||||
just_constraint: bool,
|
just_constraint: bool,
|
||||||
) -> FxHashSet<ty::BoundRegionKind>
|
) -> FxHashSet<ty::BoundRegionKind>
|
||||||
where
|
where
|
||||||
@ -661,7 +674,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
|
|
||||||
/// Replaces any late-bound regions bound in `value` with `'erased`. Useful in codegen but also
|
/// Replaces any late-bound regions bound in `value` with `'erased`. Useful in codegen but also
|
||||||
/// method lookup and a few other places where precise region relationships are not required.
|
/// method lookup and a few other places where precise region relationships are not required.
|
||||||
pub fn erase_late_bound_regions<T>(self, value: Binder<T>) -> T
|
pub fn erase_late_bound_regions<T>(self, value: Binder<'tcx, T>) -> T
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
@ -676,7 +689,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
/// `FnSig`s or `TraitRef`s which are equivalent up to region naming will become
|
/// `FnSig`s or `TraitRef`s which are equivalent up to region naming will become
|
||||||
/// structurally identical. For example, `for<'a, 'b> fn(&'a isize, &'b isize)` and
|
/// structurally identical. For example, `for<'a, 'b> fn(&'a isize, &'b isize)` and
|
||||||
/// `for<'a, 'b> fn(&'b isize, &'a isize)` will become identical after anonymization.
|
/// `for<'a, 'b> fn(&'b isize, &'a isize)` will become identical after anonymization.
|
||||||
pub fn anonymize_late_bound_regions<T>(self, sig: Binder<T>) -> Binder<T>
|
pub fn anonymize_late_bound_regions<T>(self, sig: Binder<'tcx, T>) -> Binder<'tcx, T>
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
@ -719,7 +732,10 @@ impl TypeFolder<'tcx> for Shifter<'tcx> {
|
|||||||
self.tcx
|
self.tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: ty::Binder<T>) -> ty::Binder<T> {
|
fn fold_binder<T: TypeFoldable<'tcx>>(
|
||||||
|
&mut self,
|
||||||
|
t: ty::Binder<'tcx, T>,
|
||||||
|
) -> ty::Binder<'tcx, T> {
|
||||||
self.current_index.shift_in(1);
|
self.current_index.shift_in(1);
|
||||||
let t = t.super_fold_with(self);
|
let t = t.super_fold_with(self);
|
||||||
self.current_index.shift_out(1);
|
self.current_index.shift_out(1);
|
||||||
@ -828,7 +844,10 @@ struct HasEscapingVarsVisitor {
|
|||||||
impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
|
impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
|
||||||
type BreakTy = FoundEscapingVars;
|
type BreakTy = FoundEscapingVars;
|
||||||
|
|
||||||
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<Self::BreakTy> {
|
fn visit_binder<T: TypeFoldable<'tcx>>(
|
||||||
|
&mut self,
|
||||||
|
t: &Binder<'tcx, T>,
|
||||||
|
) -> ControlFlow<Self::BreakTy> {
|
||||||
self.outer_index.shift_in(1);
|
self.outer_index.shift_in(1);
|
||||||
let result = t.super_visit_with(self);
|
let result = t.super_visit_with(self);
|
||||||
self.outer_index.shift_out(1);
|
self.outer_index.shift_out(1);
|
||||||
@ -898,7 +917,10 @@ crate struct CountBoundVars {
|
|||||||
impl<'tcx> TypeVisitor<'tcx> for CountBoundVars {
|
impl<'tcx> TypeVisitor<'tcx> for CountBoundVars {
|
||||||
type BreakTy = ();
|
type BreakTy = ();
|
||||||
|
|
||||||
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<Self::BreakTy> {
|
fn visit_binder<T: TypeFoldable<'tcx>>(
|
||||||
|
&mut self,
|
||||||
|
t: &Binder<'tcx, T>,
|
||||||
|
) -> ControlFlow<Self::BreakTy> {
|
||||||
self.outer_index.shift_in(1);
|
self.outer_index.shift_in(1);
|
||||||
let result = t.super_visit_with(self);
|
let result = t.super_visit_with(self);
|
||||||
self.outer_index.shift_out(1);
|
self.outer_index.shift_out(1);
|
||||||
@ -1022,7 +1044,10 @@ impl LateBoundRegionsCollector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector {
|
impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector {
|
||||||
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<Self::BreakTy> {
|
fn visit_binder<T: TypeFoldable<'tcx>>(
|
||||||
|
&mut self,
|
||||||
|
t: &Binder<'tcx, T>,
|
||||||
|
) -> ControlFlow<Self::BreakTy> {
|
||||||
self.current_index.shift_in(1);
|
self.current_index.shift_in(1);
|
||||||
let result = t.super_visit_with(self);
|
let result = t.super_visit_with(self);
|
||||||
self.current_index.shift_out(1);
|
self.current_index.shift_out(1);
|
||||||
|
@ -359,7 +359,7 @@ impl ty::EarlyBoundRegion {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
crate struct PredicateInner<'tcx> {
|
crate struct PredicateInner<'tcx> {
|
||||||
kind: Binder<PredicateKind<'tcx>>,
|
kind: Binder<'tcx, PredicateKind<'tcx>>,
|
||||||
flags: TypeFlags,
|
flags: TypeFlags,
|
||||||
/// See the comment for the corresponding field of [TyS].
|
/// See the comment for the corresponding field of [TyS].
|
||||||
outer_exclusive_binder: ty::DebruijnIndex,
|
outer_exclusive_binder: ty::DebruijnIndex,
|
||||||
@ -389,9 +389,9 @@ impl Hash for Predicate<'_> {
|
|||||||
impl<'tcx> Eq for Predicate<'tcx> {}
|
impl<'tcx> Eq for Predicate<'tcx> {}
|
||||||
|
|
||||||
impl<'tcx> Predicate<'tcx> {
|
impl<'tcx> Predicate<'tcx> {
|
||||||
/// Gets the inner `Binder<PredicateKind<'tcx>>`.
|
/// Gets the inner `Binder<'tcx, PredicateKind<'tcx>>`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn kind(self) -> Binder<PredicateKind<'tcx>> {
|
pub fn kind(self) -> Binder<'tcx, PredicateKind<'tcx>> {
|
||||||
self.inner.kind
|
self.inner.kind
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -556,7 +556,7 @@ pub struct TraitPredicate<'tcx> {
|
|||||||
pub trait_ref: TraitRef<'tcx>,
|
pub trait_ref: TraitRef<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type PolyTraitPredicate<'tcx> = ty::Binder<TraitPredicate<'tcx>>;
|
pub type PolyTraitPredicate<'tcx> = ty::Binder<'tcx, TraitPredicate<'tcx>>;
|
||||||
|
|
||||||
impl<'tcx> TraitPredicate<'tcx> {
|
impl<'tcx> TraitPredicate<'tcx> {
|
||||||
pub fn def_id(self) -> DefId {
|
pub fn def_id(self) -> DefId {
|
||||||
@ -574,7 +574,7 @@ impl<'tcx> PolyTraitPredicate<'tcx> {
|
|||||||
self.skip_binder().def_id()
|
self.skip_binder().def_id()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn self_ty(self) -> ty::Binder<Ty<'tcx>> {
|
pub fn self_ty(self) -> ty::Binder<'tcx, Ty<'tcx>> {
|
||||||
self.map_bound(|trait_ref| trait_ref.self_ty())
|
self.map_bound(|trait_ref| trait_ref.self_ty())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -584,8 +584,8 @@ impl<'tcx> PolyTraitPredicate<'tcx> {
|
|||||||
pub struct OutlivesPredicate<A, B>(pub A, pub B); // `A: B`
|
pub struct OutlivesPredicate<A, B>(pub A, pub B); // `A: B`
|
||||||
pub type RegionOutlivesPredicate<'tcx> = OutlivesPredicate<ty::Region<'tcx>, ty::Region<'tcx>>;
|
pub type RegionOutlivesPredicate<'tcx> = OutlivesPredicate<ty::Region<'tcx>, ty::Region<'tcx>>;
|
||||||
pub type TypeOutlivesPredicate<'tcx> = OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>>;
|
pub type TypeOutlivesPredicate<'tcx> = OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>>;
|
||||||
pub type PolyRegionOutlivesPredicate<'tcx> = ty::Binder<RegionOutlivesPredicate<'tcx>>;
|
pub type PolyRegionOutlivesPredicate<'tcx> = ty::Binder<'tcx, RegionOutlivesPredicate<'tcx>>;
|
||||||
pub type PolyTypeOutlivesPredicate<'tcx> = ty::Binder<TypeOutlivesPredicate<'tcx>>;
|
pub type PolyTypeOutlivesPredicate<'tcx> = ty::Binder<'tcx, TypeOutlivesPredicate<'tcx>>;
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, TyEncodable, TyDecodable)]
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, TyEncodable, TyDecodable)]
|
||||||
#[derive(HashStable, TypeFoldable)]
|
#[derive(HashStable, TypeFoldable)]
|
||||||
@ -594,7 +594,7 @@ pub struct SubtypePredicate<'tcx> {
|
|||||||
pub a: Ty<'tcx>,
|
pub a: Ty<'tcx>,
|
||||||
pub b: Ty<'tcx>,
|
pub b: Ty<'tcx>,
|
||||||
}
|
}
|
||||||
pub type PolySubtypePredicate<'tcx> = ty::Binder<SubtypePredicate<'tcx>>;
|
pub type PolySubtypePredicate<'tcx> = ty::Binder<'tcx, SubtypePredicate<'tcx>>;
|
||||||
|
|
||||||
/// This kind of predicate has no *direct* correspondent in the
|
/// This kind of predicate has no *direct* correspondent in the
|
||||||
/// syntax, but it roughly corresponds to the syntactic forms:
|
/// syntax, but it roughly corresponds to the syntactic forms:
|
||||||
@ -615,7 +615,7 @@ pub struct ProjectionPredicate<'tcx> {
|
|||||||
pub ty: Ty<'tcx>,
|
pub ty: Ty<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type PolyProjectionPredicate<'tcx> = Binder<ProjectionPredicate<'tcx>>;
|
pub type PolyProjectionPredicate<'tcx> = Binder<'tcx, ProjectionPredicate<'tcx>>;
|
||||||
|
|
||||||
impl<'tcx> PolyProjectionPredicate<'tcx> {
|
impl<'tcx> PolyProjectionPredicate<'tcx> {
|
||||||
/// Returns the `DefId` of the trait of the associated item being projected.
|
/// Returns the `DefId` of the trait of the associated item being projected.
|
||||||
@ -637,7 +637,7 @@ impl<'tcx> PolyProjectionPredicate<'tcx> {
|
|||||||
self.map_bound(|predicate| predicate.projection_ty.trait_ref(tcx))
|
self.map_bound(|predicate| predicate.projection_ty.trait_ref(tcx))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ty(&self) -> Binder<Ty<'tcx>> {
|
pub fn ty(&self) -> Binder<'tcx, Ty<'tcx>> {
|
||||||
self.map_bound(|predicate| predicate.ty)
|
self.map_bound(|predicate| predicate.ty)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,7 +671,7 @@ pub trait ToPredicate<'tcx> {
|
|||||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx>;
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToPredicate<'tcx> for Binder<PredicateKind<'tcx>> {
|
impl ToPredicate<'tcx> for Binder<'tcx, PredicateKind<'tcx>> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
tcx.mk_predicate(self)
|
tcx.mk_predicate(self)
|
||||||
@ -694,11 +694,11 @@ impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<TraitRef<'tcx>> {
|
|||||||
|
|
||||||
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<PolyTraitRef<'tcx>> {
|
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<PolyTraitRef<'tcx>> {
|
||||||
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
fn to_predicate(self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
|
||||||
ConstnessAnd {
|
self.value
|
||||||
value: self.value.map_bound(|trait_ref| ty::TraitPredicate { trait_ref }),
|
.map_bound(|trait_ref| {
|
||||||
constness: self.constness,
|
PredicateKind::Trait(ty::TraitPredicate { trait_ref }, self.constness)
|
||||||
}
|
})
|
||||||
.to_predicate(tcx)
|
.to_predicate(tcx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If you have a `Binder<T>`, you can do this to strip out the
|
/// If you have a `Binder<'tcx, T>`, you can do this to strip out the
|
||||||
/// late-bound regions and then normalize the result, yielding up
|
/// late-bound regions and then normalize the result, yielding up
|
||||||
/// a `T` (with regions erased). This is appropriate when the
|
/// a `T` (with regions erased). This is appropriate when the
|
||||||
/// binder is being instantiated at the call site.
|
/// binder is being instantiated at the call site.
|
||||||
@ -49,7 +49,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
pub fn normalize_erasing_late_bound_regions<T>(
|
pub fn normalize_erasing_late_bound_regions<T>(
|
||||||
self,
|
self,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
value: ty::Binder<T>,
|
value: ty::Binder<'tcx, T>,
|
||||||
) -> T
|
) -> T
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
|
@ -63,7 +63,7 @@ pub trait Printer<'tcx>: Sized {
|
|||||||
|
|
||||||
fn print_dyn_existential(
|
fn print_dyn_existential(
|
||||||
self,
|
self,
|
||||||
predicates: &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>>,
|
predicates: &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
|
||||||
) -> Result<Self::DynExistential, Self::Error>;
|
) -> Result<Self::DynExistential, Self::Error>;
|
||||||
|
|
||||||
fn print_const(self, ct: &'tcx ty::Const<'tcx>) -> Result<Self::Const, Self::Error>;
|
fn print_const(self, ct: &'tcx ty::Const<'tcx>) -> Result<Self::Const, Self::Error>;
|
||||||
@ -346,7 +346,7 @@ impl<'tcx, P: Printer<'tcx>> Print<'tcx, P> for Ty<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, P: Printer<'tcx>> Print<'tcx, P>
|
impl<'tcx, P: Printer<'tcx>> Print<'tcx, P>
|
||||||
for &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>>
|
for &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>
|
||||||
{
|
{
|
||||||
type Output = P::DynExistential;
|
type Output = P::DynExistential;
|
||||||
type Error = P::Error;
|
type Error = P::Error;
|
||||||
|
@ -202,7 +202,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||||||
self.print_def_path(def_id, substs)
|
self.print_def_path(def_id, substs)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn in_binder<T>(self, value: &ty::Binder<T>) -> Result<Self, Self::Error>
|
fn in_binder<T>(self, value: &ty::Binder<'tcx, T>) -> Result<Self, Self::Error>
|
||||||
where
|
where
|
||||||
T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx>,
|
T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
@ -211,7 +211,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||||||
|
|
||||||
fn wrap_binder<T, F: Fn(&T, Self) -> Result<Self, fmt::Error>>(
|
fn wrap_binder<T, F: Fn(&T, Self) -> Result<Self, fmt::Error>>(
|
||||||
self,
|
self,
|
||||||
value: &ty::Binder<T>,
|
value: &ty::Binder<'tcx, T>,
|
||||||
f: F,
|
f: F,
|
||||||
) -> Result<Self, Self::Error>
|
) -> Result<Self, Self::Error>
|
||||||
where
|
where
|
||||||
@ -765,7 +765,7 @@ pub trait PrettyPrinter<'tcx>:
|
|||||||
|
|
||||||
fn pretty_print_dyn_existential(
|
fn pretty_print_dyn_existential(
|
||||||
mut self,
|
mut self,
|
||||||
predicates: &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>>,
|
predicates: &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
|
||||||
) -> Result<Self::DynExistential, Self::Error> {
|
) -> Result<Self::DynExistential, Self::Error> {
|
||||||
// Generate the main trait ref, including associated types.
|
// Generate the main trait ref, including associated types.
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
@ -1432,7 +1432,7 @@ impl<F: fmt::Write> Printer<'tcx> for FmtPrinter<'_, 'tcx, F> {
|
|||||||
|
|
||||||
fn print_dyn_existential(
|
fn print_dyn_existential(
|
||||||
self,
|
self,
|
||||||
predicates: &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>>,
|
predicates: &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
|
||||||
) -> Result<Self::DynExistential, Self::Error> {
|
) -> Result<Self::DynExistential, Self::Error> {
|
||||||
self.pretty_print_dyn_existential(predicates)
|
self.pretty_print_dyn_existential(predicates)
|
||||||
}
|
}
|
||||||
@ -1571,7 +1571,7 @@ impl<F: fmt::Write> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx, F> {
|
|||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn in_binder<T>(self, value: &ty::Binder<T>) -> Result<Self, Self::Error>
|
fn in_binder<T>(self, value: &ty::Binder<'tcx, T>) -> Result<Self, Self::Error>
|
||||||
where
|
where
|
||||||
T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx>,
|
T: Print<'tcx, Self, Output = Self, Error = Self::Error> + TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
@ -1580,7 +1580,7 @@ impl<F: fmt::Write> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx, F> {
|
|||||||
|
|
||||||
fn wrap_binder<T, C: Fn(&T, Self) -> Result<Self, Self::Error>>(
|
fn wrap_binder<T, C: Fn(&T, Self) -> Result<Self, Self::Error>>(
|
||||||
self,
|
self,
|
||||||
value: &ty::Binder<T>,
|
value: &ty::Binder<'tcx, T>,
|
||||||
f: C,
|
f: C,
|
||||||
) -> Result<Self, Self::Error>
|
) -> Result<Self, Self::Error>
|
||||||
where
|
where
|
||||||
@ -1763,7 +1763,7 @@ impl<F: fmt::Write> FmtPrinter<'_, '_, F> {
|
|||||||
impl<F: fmt::Write> FmtPrinter<'_, 'tcx, F> {
|
impl<F: fmt::Write> FmtPrinter<'_, 'tcx, F> {
|
||||||
pub fn name_all_regions<T>(
|
pub fn name_all_regions<T>(
|
||||||
mut self,
|
mut self,
|
||||||
value: &ty::Binder<T>,
|
value: &ty::Binder<'tcx, T>,
|
||||||
) -> Result<(Self, (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)), fmt::Error>
|
) -> Result<(Self, (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)), fmt::Error>
|
||||||
where
|
where
|
||||||
T: Print<'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable<'tcx>,
|
T: Print<'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable<'tcx>,
|
||||||
@ -1830,7 +1830,7 @@ impl<F: fmt::Write> FmtPrinter<'_, 'tcx, F> {
|
|||||||
Ok((self, new_value))
|
Ok((self, new_value))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pretty_in_binder<T>(self, value: &ty::Binder<T>) -> Result<Self, fmt::Error>
|
pub fn pretty_in_binder<T>(self, value: &ty::Binder<'tcx, T>) -> Result<Self, fmt::Error>
|
||||||
where
|
where
|
||||||
T: Print<'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable<'tcx>,
|
T: Print<'tcx, Self, Output = Self, Error = fmt::Error> + TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
@ -1844,7 +1844,7 @@ impl<F: fmt::Write> FmtPrinter<'_, 'tcx, F> {
|
|||||||
|
|
||||||
pub fn pretty_wrap_binder<T, C: Fn(&T, Self) -> Result<Self, fmt::Error>>(
|
pub fn pretty_wrap_binder<T, C: Fn(&T, Self) -> Result<Self, fmt::Error>>(
|
||||||
self,
|
self,
|
||||||
value: &ty::Binder<T>,
|
value: &ty::Binder<'tcx, T>,
|
||||||
f: C,
|
f: C,
|
||||||
) -> Result<Self, fmt::Error>
|
) -> Result<Self, fmt::Error>
|
||||||
where
|
where
|
||||||
@ -1858,7 +1858,7 @@ impl<F: fmt::Write> FmtPrinter<'_, 'tcx, F> {
|
|||||||
Ok(inner)
|
Ok(inner)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_late_bound_region_info<T>(&mut self, value: &ty::Binder<T>)
|
fn prepare_late_bound_region_info<T>(&mut self, value: &ty::Binder<'tcx, T>)
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
@ -1879,7 +1879,7 @@ impl<F: fmt::Write> FmtPrinter<'_, 'tcx, F> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, T, P: PrettyPrinter<'tcx>> Print<'tcx, P> for ty::Binder<T>
|
impl<'tcx, T, P: PrettyPrinter<'tcx>> Print<'tcx, P> for ty::Binder<'tcx, T>
|
||||||
where
|
where
|
||||||
T: Print<'tcx, P, Output = P, Error = P::Error> + TypeFoldable<'tcx>,
|
T: Print<'tcx, P, Output = P, Error = P::Error> + TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
@ -1966,28 +1966,28 @@ impl ty::TraitRef<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ty::Binder<ty::TraitRef<'tcx>> {
|
impl ty::Binder<'tcx, ty::TraitRef<'tcx>> {
|
||||||
pub fn print_only_trait_path(self) -> ty::Binder<TraitRefPrintOnlyTraitPath<'tcx>> {
|
pub fn print_only_trait_path(self) -> ty::Binder<'tcx, TraitRefPrintOnlyTraitPath<'tcx>> {
|
||||||
self.map_bound(|tr| tr.print_only_trait_path())
|
self.map_bound(|tr| tr.print_only_trait_path())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
forward_display_to_print! {
|
forward_display_to_print! {
|
||||||
Ty<'tcx>,
|
Ty<'tcx>,
|
||||||
&'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>>,
|
&'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
|
||||||
&'tcx ty::Const<'tcx>,
|
&'tcx ty::Const<'tcx>,
|
||||||
|
|
||||||
// HACK(eddyb) these are exhaustive instead of generic,
|
// HACK(eddyb) these are exhaustive instead of generic,
|
||||||
// because `for<'tcx>` isn't possible yet.
|
// because `for<'tcx>` isn't possible yet.
|
||||||
ty::Binder<ty::ExistentialPredicate<'tcx>>,
|
ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>,
|
||||||
ty::Binder<ty::TraitRef<'tcx>>,
|
ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||||
ty::Binder<TraitRefPrintOnlyTraitPath<'tcx>>,
|
ty::Binder<'tcx, TraitRefPrintOnlyTraitPath<'tcx>>,
|
||||||
ty::Binder<ty::FnSig<'tcx>>,
|
ty::Binder<'tcx, ty::FnSig<'tcx>>,
|
||||||
ty::Binder<ty::TraitPredicate<'tcx>>,
|
ty::Binder<'tcx, ty::TraitPredicate<'tcx>>,
|
||||||
ty::Binder<ty::SubtypePredicate<'tcx>>,
|
ty::Binder<'tcx, ty::SubtypePredicate<'tcx>>,
|
||||||
ty::Binder<ty::ProjectionPredicate<'tcx>>,
|
ty::Binder<'tcx, ty::ProjectionPredicate<'tcx>>,
|
||||||
ty::Binder<ty::OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>>>,
|
ty::Binder<'tcx, ty::OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>>>,
|
||||||
ty::Binder<ty::OutlivesPredicate<ty::Region<'tcx>, ty::Region<'tcx>>>,
|
ty::Binder<'tcx, ty::OutlivesPredicate<ty::Region<'tcx>, ty::Region<'tcx>>>,
|
||||||
|
|
||||||
ty::OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>>,
|
ty::OutlivesPredicate<Ty<'tcx>, ty::Region<'tcx>>,
|
||||||
ty::OutlivesPredicate<ty::Region<'tcx>, ty::Region<'tcx>>
|
ty::OutlivesPredicate<ty::Region<'tcx>, ty::Region<'tcx>>
|
||||||
|
@ -93,9 +93,9 @@ pub trait TypeRelation<'tcx>: Sized {
|
|||||||
|
|
||||||
fn binders<T>(
|
fn binders<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
a: ty::Binder<T>,
|
a: ty::Binder<'tcx, T>,
|
||||||
b: ty::Binder<T>,
|
b: ty::Binder<'tcx, T>,
|
||||||
) -> RelateResult<'tcx, ty::Binder<T>>
|
) -> RelateResult<'tcx, ty::Binder<'tcx, T>>
|
||||||
where
|
where
|
||||||
T: Relate<'tcx>;
|
T: Relate<'tcx>;
|
||||||
}
|
}
|
||||||
@ -594,7 +594,7 @@ fn check_const_value_eq<R: TypeRelation<'tcx>>(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>> {
|
impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>> {
|
||||||
fn relate<R: TypeRelation<'tcx>>(
|
fn relate<R: TypeRelation<'tcx>>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: Self,
|
a: Self,
|
||||||
@ -684,12 +684,12 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::Const<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for ty::Binder<T> {
|
impl<'tcx, T: Relate<'tcx>> Relate<'tcx> for ty::Binder<'tcx, T> {
|
||||||
fn relate<R: TypeRelation<'tcx>>(
|
fn relate<R: TypeRelation<'tcx>>(
|
||||||
relation: &mut R,
|
relation: &mut R,
|
||||||
a: ty::Binder<T>,
|
a: ty::Binder<'tcx, T>,
|
||||||
b: ty::Binder<T>,
|
b: ty::Binder<'tcx, T>,
|
||||||
) -> RelateResult<'tcx, ty::Binder<T>> {
|
) -> RelateResult<'tcx, ty::Binder<'tcx, T>> {
|
||||||
relation.binders(a, b)
|
relation.binders(a, b)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -454,10 +454,14 @@ impl<'a, 'tcx> Lift<'tcx> for ty::PredicateKind<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::Binder<T> {
|
impl<'a, 'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::Binder<'a, T>
|
||||||
type Lifted = ty::Binder<T::Lifted>;
|
where
|
||||||
|
<T as Lift<'tcx>>::Lifted: TypeFoldable<'tcx>,
|
||||||
|
{
|
||||||
|
type Lifted = ty::Binder<'tcx, T::Lifted>;
|
||||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||||
self.map_bound(|v| tcx.lift(v)).transpose()
|
// FIXME: need to lift inner values
|
||||||
|
tcx.lift(self.skip_binder()).map(|v| ty::Binder::bind(v))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -749,7 +753,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Box<[T]> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
|
impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<'tcx, T> {
|
||||||
fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
|
fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
|
||||||
self.map_bound(|ty| ty.fold_with(folder))
|
self.map_bound(|ty| ty.fold_with(folder))
|
||||||
}
|
}
|
||||||
@ -767,7 +771,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>> {
|
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>> {
|
||||||
fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
|
fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
|
||||||
ty::util::fold_list(self, folder, |tcx, v| tcx.intern_poly_existential_predicates(v))
|
ty::util::fold_list(self, folder, |tcx, v| tcx.intern_poly_existential_predicates(v))
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ pub enum TyKind<'tcx> {
|
|||||||
FnPtr(PolyFnSig<'tcx>),
|
FnPtr(PolyFnSig<'tcx>),
|
||||||
|
|
||||||
/// A trait object. Written as `dyn for<'b> Trait<'b, Assoc = u32> + Send + 'a`.
|
/// A trait object. Written as `dyn for<'b> Trait<'b, Assoc = u32> + Send + 'a`.
|
||||||
Dynamic(&'tcx List<Binder<ExistentialPredicate<'tcx>>>, ty::Region<'tcx>),
|
Dynamic(&'tcx List<Binder<'tcx, ExistentialPredicate<'tcx>>>, ty::Region<'tcx>),
|
||||||
|
|
||||||
/// The anonymous type of a closure. Used to represent the type of
|
/// The anonymous type of a closure. Used to represent the type of
|
||||||
/// `|a| a`.
|
/// `|a| a`.
|
||||||
@ -173,7 +173,7 @@ pub enum TyKind<'tcx> {
|
|||||||
|
|
||||||
/// A type representing the types stored inside a generator.
|
/// A type representing the types stored inside a generator.
|
||||||
/// This should only appear in GeneratorInteriors.
|
/// This should only appear in GeneratorInteriors.
|
||||||
GeneratorWitness(Binder<&'tcx List<Ty<'tcx>>>),
|
GeneratorWitness(Binder<'tcx, &'tcx List<Ty<'tcx>>>),
|
||||||
|
|
||||||
/// The never type `!`.
|
/// The never type `!`.
|
||||||
Never,
|
Never,
|
||||||
@ -747,7 +747,7 @@ impl<'tcx> ExistentialPredicate<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Binder<ExistentialPredicate<'tcx>> {
|
impl<'tcx> Binder<'tcx, ExistentialPredicate<'tcx>> {
|
||||||
pub fn with_self_ty(&self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> ty::Predicate<'tcx> {
|
pub fn with_self_ty(&self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> ty::Predicate<'tcx> {
|
||||||
use crate::ty::ToPredicate;
|
use crate::ty::ToPredicate;
|
||||||
match self.skip_binder() {
|
match self.skip_binder() {
|
||||||
@ -768,7 +768,7 @@ impl<'tcx> Binder<ExistentialPredicate<'tcx>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> List<ty::Binder<ExistentialPredicate<'tcx>>> {
|
impl<'tcx> List<ty::Binder<'tcx, ExistentialPredicate<'tcx>>> {
|
||||||
/// Returns the "principal `DefId`" of this set of existential predicates.
|
/// Returns the "principal `DefId`" of this set of existential predicates.
|
||||||
///
|
///
|
||||||
/// A Rust trait object type consists (in addition to a lifetime bound)
|
/// A Rust trait object type consists (in addition to a lifetime bound)
|
||||||
@ -794,7 +794,7 @@ impl<'tcx> List<ty::Binder<ExistentialPredicate<'tcx>>> {
|
|||||||
/// is `{Send, Sync}`, while there is no principal. These trait objects
|
/// is `{Send, Sync}`, while there is no principal. These trait objects
|
||||||
/// have a "trivial" vtable consisting of just the size, alignment,
|
/// have a "trivial" vtable consisting of just the size, alignment,
|
||||||
/// and destructor.
|
/// and destructor.
|
||||||
pub fn principal(&self) -> Option<ty::Binder<ExistentialTraitRef<'tcx>>> {
|
pub fn principal(&self) -> Option<ty::Binder<'tcx, ExistentialTraitRef<'tcx>>> {
|
||||||
self[0]
|
self[0]
|
||||||
.map_bound(|this| match this {
|
.map_bound(|this| match this {
|
||||||
ExistentialPredicate::Trait(tr) => Some(tr),
|
ExistentialPredicate::Trait(tr) => Some(tr),
|
||||||
@ -810,7 +810,7 @@ impl<'tcx> List<ty::Binder<ExistentialPredicate<'tcx>>> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn projection_bounds<'a>(
|
pub fn projection_bounds<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
) -> impl Iterator<Item = ty::Binder<ExistentialProjection<'tcx>>> + 'a {
|
) -> impl Iterator<Item = ty::Binder<'tcx, ExistentialProjection<'tcx>>> + 'a {
|
||||||
self.iter().filter_map(|predicate| {
|
self.iter().filter_map(|predicate| {
|
||||||
predicate
|
predicate
|
||||||
.map_bound(|pred| match pred {
|
.map_bound(|pred| match pred {
|
||||||
@ -875,10 +875,10 @@ impl<'tcx> TraitRef<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type PolyTraitRef<'tcx> = Binder<TraitRef<'tcx>>;
|
pub type PolyTraitRef<'tcx> = Binder<'tcx, TraitRef<'tcx>>;
|
||||||
|
|
||||||
impl<'tcx> PolyTraitRef<'tcx> {
|
impl<'tcx> PolyTraitRef<'tcx> {
|
||||||
pub fn self_ty(&self) -> Binder<Ty<'tcx>> {
|
pub fn self_ty(&self) -> Binder<'tcx, Ty<'tcx>> {
|
||||||
self.map_bound_ref(|tr| tr.self_ty())
|
self.map_bound_ref(|tr| tr.self_ty())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -931,7 +931,7 @@ impl<'tcx> ExistentialTraitRef<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type PolyExistentialTraitRef<'tcx> = Binder<ExistentialTraitRef<'tcx>>;
|
pub type PolyExistentialTraitRef<'tcx> = Binder<'tcx, ExistentialTraitRef<'tcx>>;
|
||||||
|
|
||||||
impl<'tcx> PolyExistentialTraitRef<'tcx> {
|
impl<'tcx> PolyExistentialTraitRef<'tcx> {
|
||||||
pub fn def_id(&self) -> DefId {
|
pub fn def_id(&self) -> DefId {
|
||||||
@ -950,16 +950,16 @@ impl<'tcx> PolyExistentialTraitRef<'tcx> {
|
|||||||
/// Binder is a binder for higher-ranked lifetimes or types. It is part of the
|
/// Binder is a binder for higher-ranked lifetimes or types. It is part of the
|
||||||
/// compiler's representation for things like `for<'a> Fn(&'a isize)`
|
/// compiler's representation for things like `for<'a> Fn(&'a isize)`
|
||||||
/// (which would be represented by the type `PolyTraitRef ==
|
/// (which would be represented by the type `PolyTraitRef ==
|
||||||
/// Binder<TraitRef>`). Note that when we instantiate,
|
/// Binder<'tcx, TraitRef>`). Note that when we instantiate,
|
||||||
/// erase, or otherwise "discharge" these bound vars, we change the
|
/// erase, or otherwise "discharge" these bound vars, we change the
|
||||||
/// type from `Binder<T>` to just `T` (see
|
/// type from `Binder<'tcx, T>` to just `T` (see
|
||||||
/// e.g., `liberate_late_bound_regions`).
|
/// e.g., `liberate_late_bound_regions`).
|
||||||
///
|
///
|
||||||
/// `Decodable` and `Encodable` are implemented for `Binder<T>` using the `impl_binder_encode_decode!` macro.
|
/// `Decodable` and `Encodable` are implemented for `Binder<T>` using the `impl_binder_encode_decode!` macro.
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||||
pub struct Binder<T>(T, u32);
|
pub struct Binder<'tcx, T>(T, u32, std::marker::PhantomData<&'tcx ()>);
|
||||||
|
|
||||||
impl<'tcx, T> Binder<T>
|
impl<'tcx, T> Binder<'tcx, T>
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
@ -967,13 +967,13 @@ where
|
|||||||
/// contain any bound vars that would be bound by the
|
/// contain any bound vars that would be bound by the
|
||||||
/// binder. This is commonly used to 'inject' a value T into a
|
/// binder. This is commonly used to 'inject' a value T into a
|
||||||
/// different binding level.
|
/// different binding level.
|
||||||
pub fn dummy(value: T) -> Binder<T> {
|
pub fn dummy(value: T) -> Binder<'tcx, T> {
|
||||||
debug_assert!(!value.has_escaping_bound_vars());
|
debug_assert!(!value.has_escaping_bound_vars());
|
||||||
Binder(value, 0)
|
Binder(value, 0, std::marker::PhantomData)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wraps `value` in a binder, binding higher-ranked vars (if any).
|
/// Wraps `value` in a binder, binding higher-ranked vars (if any).
|
||||||
pub fn bind(value: T) -> Binder<T> {
|
pub fn bind(value: T) -> Binder<'tcx, T> {
|
||||||
use crate::ty::fold::CountBoundVars;
|
use crate::ty::fold::CountBoundVars;
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
let mut counter = CountBoundVars {
|
let mut counter = CountBoundVars {
|
||||||
@ -1006,11 +1006,11 @@ where
|
|||||||
let bound_consts = counter.bound_consts.len();
|
let bound_consts = counter.bound_consts.len();
|
||||||
|
|
||||||
let bound_vars = bound_tys + bound_regions + bound_consts;
|
let bound_vars = bound_tys + bound_regions + bound_consts;
|
||||||
Binder(value, bound_vars as u32)
|
Binder(value, bound_vars as u32, std::marker::PhantomData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Binder<T> {
|
impl<'tcx, T> Binder<'tcx, T> {
|
||||||
/// Skips the binder and returns the "bound" value. This is a
|
/// Skips the binder and returns the "bound" value. This is a
|
||||||
/// risky thing to do because it's easy to get confused about
|
/// risky thing to do because it's easy to get confused about
|
||||||
/// De Bruijn indices and the like. It is usually better to
|
/// De Bruijn indices and the like. It is usually better to
|
||||||
@ -1035,22 +1035,22 @@ impl<T> Binder<T> {
|
|||||||
self.1
|
self.1
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_ref(&self) -> Binder<&T> {
|
pub fn as_ref(&self) -> Binder<'tcx, &T> {
|
||||||
Binder(&self.0, self.1)
|
Binder(&self.0, self.1, std::marker::PhantomData)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn map_bound_ref<F, U>(&self, f: F) -> Binder<U>
|
pub fn map_bound_ref<F, U>(&self, f: F) -> Binder<'tcx, U>
|
||||||
where
|
where
|
||||||
F: FnOnce(&T) -> U,
|
F: FnOnce(&T) -> U,
|
||||||
{
|
{
|
||||||
self.as_ref().map_bound(f)
|
self.as_ref().map_bound(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn map_bound<F, U>(self, f: F) -> Binder<U>
|
pub fn map_bound<F, U>(self, f: F) -> Binder<'tcx, U>
|
||||||
where
|
where
|
||||||
F: FnOnce(T) -> U,
|
F: FnOnce(T) -> U,
|
||||||
{
|
{
|
||||||
Binder(f(self.0), self.1)
|
Binder(f(self.0), self.1, std::marker::PhantomData)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wraps a `value` in a binder, using the same bound variables as the
|
/// Wraps a `value` in a binder, using the same bound variables as the
|
||||||
@ -1062,8 +1062,8 @@ impl<T> Binder<T> {
|
|||||||
/// don't actually track bound vars. However, semantically, it is different
|
/// don't actually track bound vars. However, semantically, it is different
|
||||||
/// because bound vars aren't allowed to change here, whereas they are
|
/// because bound vars aren't allowed to change here, whereas they are
|
||||||
/// in `bind`. This may be (debug) asserted in the future.
|
/// in `bind`. This may be (debug) asserted in the future.
|
||||||
pub fn rebind<U>(&self, value: U) -> Binder<U> {
|
pub fn rebind<U>(&self, value: U) -> Binder<'tcx, U> {
|
||||||
Binder(value, self.1)
|
Binder(value, self.1, std::marker::PhantomData)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Unwraps and returns the value within, but only if it contains
|
/// Unwraps and returns the value within, but only if it contains
|
||||||
@ -1076,7 +1076,7 @@ impl<T> Binder<T> {
|
|||||||
/// binders, but that would require adjusting the debruijn
|
/// binders, but that would require adjusting the debruijn
|
||||||
/// indices, and given the shallow binding structure we often use,
|
/// indices, and given the shallow binding structure we often use,
|
||||||
/// would not be that useful.)
|
/// would not be that useful.)
|
||||||
pub fn no_bound_vars<'tcx>(self) -> Option<T>
|
pub fn no_bound_vars(self) -> Option<T>
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
@ -1090,11 +1090,11 @@ impl<T> Binder<T> {
|
|||||||
/// `f` should consider bound regions at depth 1 to be free, and
|
/// `f` should consider bound regions at depth 1 to be free, and
|
||||||
/// anything it produces with bound regions at depth 1 will be
|
/// anything it produces with bound regions at depth 1 will be
|
||||||
/// bound in the resulting return value.
|
/// bound in the resulting return value.
|
||||||
pub fn fuse<U, F, R>(self, u: Binder<U>, f: F) -> Binder<R>
|
pub fn fuse<U, F, R>(self, u: Binder<'tcx, U>, f: F) -> Binder<'tcx, R>
|
||||||
where
|
where
|
||||||
F: FnOnce(T, U) -> R,
|
F: FnOnce(T, U) -> R,
|
||||||
{
|
{
|
||||||
Binder(f(self.0, u.0), self.1)
|
Binder(f(self.0, u.0), self.1, std::marker::PhantomData)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Splits the contents into two things that share the same binder
|
/// Splits the contents into two things that share the same binder
|
||||||
@ -1103,19 +1103,19 @@ impl<T> Binder<T> {
|
|||||||
/// `f` should consider bound regions at depth 1 to be free, and
|
/// `f` should consider bound regions at depth 1 to be free, and
|
||||||
/// anything it produces with bound regions at depth 1 will be
|
/// anything it produces with bound regions at depth 1 will be
|
||||||
/// bound in the resulting return values.
|
/// bound in the resulting return values.
|
||||||
pub fn split<U, V, F>(self, f: F) -> (Binder<U>, Binder<V>)
|
pub fn split<U, V, F>(self, f: F) -> (Binder<'tcx, U>, Binder<'tcx, V>)
|
||||||
where
|
where
|
||||||
F: FnOnce(T) -> (U, V),
|
F: FnOnce(T) -> (U, V),
|
||||||
{
|
{
|
||||||
let (u, v) = f(self.0);
|
let (u, v) = f(self.0);
|
||||||
(Binder(u, self.1), Binder(v, self.1))
|
(Binder(u, self.1, std::marker::PhantomData), Binder(v, self.1, std::marker::PhantomData))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Binder<Option<T>> {
|
impl<'tcx, T> Binder<'tcx, Option<T>> {
|
||||||
pub fn transpose(self) -> Option<Binder<T>> {
|
pub fn transpose(self) -> Option<Binder<'tcx, T>> {
|
||||||
let bound_vars = self.1;
|
let bound_vars = self.1;
|
||||||
self.0.map(|v| Binder(v, bound_vars))
|
self.0.map(|v| Binder(v, bound_vars, std::marker::PhantomData))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1178,7 +1178,7 @@ pub struct GenSig<'tcx> {
|
|||||||
pub return_ty: Ty<'tcx>,
|
pub return_ty: Ty<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type PolyGenSig<'tcx> = Binder<GenSig<'tcx>>;
|
pub type PolyGenSig<'tcx> = Binder<'tcx, GenSig<'tcx>>;
|
||||||
|
|
||||||
/// Signature of a function type, which we have arbitrarily
|
/// Signature of a function type, which we have arbitrarily
|
||||||
/// decided to use to refer to the input/output types.
|
/// decided to use to refer to the input/output types.
|
||||||
@ -1216,22 +1216,22 @@ impl<'tcx> FnSig<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type PolyFnSig<'tcx> = Binder<FnSig<'tcx>>;
|
pub type PolyFnSig<'tcx> = Binder<'tcx, FnSig<'tcx>>;
|
||||||
|
|
||||||
impl<'tcx> PolyFnSig<'tcx> {
|
impl<'tcx> PolyFnSig<'tcx> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn inputs(&self) -> Binder<&'tcx [Ty<'tcx>]> {
|
pub fn inputs(&self) -> Binder<'tcx, &'tcx [Ty<'tcx>]> {
|
||||||
self.map_bound_ref(|fn_sig| fn_sig.inputs())
|
self.map_bound_ref(|fn_sig| fn_sig.inputs())
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn input(&self, index: usize) -> ty::Binder<Ty<'tcx>> {
|
pub fn input(&self, index: usize) -> ty::Binder<'tcx, Ty<'tcx>> {
|
||||||
self.map_bound_ref(|fn_sig| fn_sig.inputs()[index])
|
self.map_bound_ref(|fn_sig| fn_sig.inputs()[index])
|
||||||
}
|
}
|
||||||
pub fn inputs_and_output(&self) -> ty::Binder<&'tcx List<Ty<'tcx>>> {
|
pub fn inputs_and_output(&self) -> ty::Binder<'tcx, &'tcx List<Ty<'tcx>>> {
|
||||||
self.map_bound_ref(|fn_sig| fn_sig.inputs_and_output)
|
self.map_bound_ref(|fn_sig| fn_sig.inputs_and_output)
|
||||||
}
|
}
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn output(&self) -> ty::Binder<Ty<'tcx>> {
|
pub fn output(&self) -> ty::Binder<'tcx, Ty<'tcx>> {
|
||||||
self.map_bound_ref(|fn_sig| fn_sig.output())
|
self.map_bound_ref(|fn_sig| fn_sig.output())
|
||||||
}
|
}
|
||||||
pub fn c_variadic(&self) -> bool {
|
pub fn c_variadic(&self) -> bool {
|
||||||
@ -1245,7 +1245,7 @@ impl<'tcx> PolyFnSig<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type CanonicalPolyFnSig<'tcx> = Canonical<'tcx, Binder<FnSig<'tcx>>>;
|
pub type CanonicalPolyFnSig<'tcx> = Canonical<'tcx, Binder<'tcx, FnSig<'tcx>>>;
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, TyEncodable, TyDecodable)]
|
||||||
#[derive(HashStable)]
|
#[derive(HashStable)]
|
||||||
@ -1489,7 +1489,7 @@ pub struct ExistentialProjection<'tcx> {
|
|||||||
pub ty: Ty<'tcx>,
|
pub ty: Ty<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type PolyExistentialProjection<'tcx> = Binder<ExistentialProjection<'tcx>>;
|
pub type PolyExistentialProjection<'tcx> = Binder<'tcx, ExistentialProjection<'tcx>>;
|
||||||
|
|
||||||
impl<'tcx> ExistentialProjection<'tcx> {
|
impl<'tcx> ExistentialProjection<'tcx> {
|
||||||
/// Extracts the underlying existential trait reference from this projection.
|
/// Extracts the underlying existential trait reference from this projection.
|
||||||
|
@ -448,7 +448,10 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
|
|||||||
self.tcx
|
self.tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: ty::Binder<T>) -> ty::Binder<T> {
|
fn fold_binder<T: TypeFoldable<'tcx>>(
|
||||||
|
&mut self,
|
||||||
|
t: ty::Binder<'tcx, T>,
|
||||||
|
) -> ty::Binder<'tcx, T> {
|
||||||
self.binders_passed += 1;
|
self.binders_passed += 1;
|
||||||
let t = t.super_fold_with(self);
|
let t = t.super_fold_with(self);
|
||||||
self.binders_passed -= 1;
|
self.binders_passed -= 1;
|
||||||
|
@ -499,7 +499,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
self,
|
self,
|
||||||
closure_def_id: DefId,
|
closure_def_id: DefId,
|
||||||
closure_substs: SubstsRef<'tcx>,
|
closure_substs: SubstsRef<'tcx>,
|
||||||
) -> Option<ty::Binder<Ty<'tcx>>> {
|
) -> Option<ty::Binder<'tcx, Ty<'tcx>>> {
|
||||||
let closure_ty = self.mk_closure(closure_def_id, closure_substs);
|
let closure_ty = self.mk_closure(closure_def_id, closure_substs);
|
||||||
let br = ty::BoundRegion { kind: ty::BrEnv };
|
let br = ty::BoundRegion { kind: ty::BrEnv };
|
||||||
let env_region = ty::ReLateBound(ty::INNERMOST, br);
|
let env_region = ty::ReLateBound(ty::INNERMOST, br);
|
||||||
|
@ -589,7 +589,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
indices: &UniversalRegionIndices<'tcx>,
|
indices: &UniversalRegionIndices<'tcx>,
|
||||||
defining_ty: DefiningTy<'tcx>,
|
defining_ty: DefiningTy<'tcx>,
|
||||||
) -> ty::Binder<&'tcx ty::List<Ty<'tcx>>> {
|
) -> ty::Binder<'tcx, &'tcx ty::List<Ty<'tcx>>> {
|
||||||
let tcx = self.infcx.tcx;
|
let tcx = self.infcx.tcx;
|
||||||
match defining_ty {
|
match defining_ty {
|
||||||
DefiningTy::Closure(def_id, substs) => {
|
DefiningTy::Closure(def_id, substs) => {
|
||||||
@ -657,7 +657,7 @@ trait InferCtxtExt<'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
origin: NllRegionVariableOrigin,
|
origin: NllRegionVariableOrigin,
|
||||||
all_outlive_scope: LocalDefId,
|
all_outlive_scope: LocalDefId,
|
||||||
value: ty::Binder<T>,
|
value: ty::Binder<'tcx, T>,
|
||||||
indices: &mut UniversalRegionIndices<'tcx>,
|
indices: &mut UniversalRegionIndices<'tcx>,
|
||||||
) -> T
|
) -> T
|
||||||
where
|
where
|
||||||
@ -686,7 +686,7 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
origin: NllRegionVariableOrigin,
|
origin: NllRegionVariableOrigin,
|
||||||
all_outlive_scope: LocalDefId,
|
all_outlive_scope: LocalDefId,
|
||||||
value: ty::Binder<T>,
|
value: ty::Binder<'tcx, T>,
|
||||||
indices: &mut UniversalRegionIndices<'tcx>,
|
indices: &mut UniversalRegionIndices<'tcx>,
|
||||||
) -> T
|
) -> T
|
||||||
where
|
where
|
||||||
|
@ -74,7 +74,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
|
|||||||
|
|
||||||
fn print_dyn_existential(
|
fn print_dyn_existential(
|
||||||
mut self,
|
mut self,
|
||||||
predicates: &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>>,
|
predicates: &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
|
||||||
) -> Result<Self::DynExistential, Self::Error> {
|
) -> Result<Self::DynExistential, Self::Error> {
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
for p in predicates {
|
for p in predicates {
|
||||||
|
@ -230,7 +230,7 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> {
|
|||||||
|
|
||||||
fn print_dyn_existential(
|
fn print_dyn_existential(
|
||||||
mut self,
|
mut self,
|
||||||
predicates: &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>>,
|
predicates: &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
|
||||||
) -> Result<Self::DynExistential, Self::Error> {
|
) -> Result<Self::DynExistential, Self::Error> {
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
for p in predicates {
|
for p in predicates {
|
||||||
|
@ -181,7 +181,7 @@ impl SymbolMangler<'tcx> {
|
|||||||
|
|
||||||
fn in_binder<T>(
|
fn in_binder<T>(
|
||||||
mut self,
|
mut self,
|
||||||
value: &ty::Binder<T>,
|
value: &ty::Binder<'tcx, T>,
|
||||||
print_value: impl FnOnce(Self, &T) -> Result<Self, !>,
|
print_value: impl FnOnce(Self, &T) -> Result<Self, !>,
|
||||||
) -> Result<Self, !>
|
) -> Result<Self, !>
|
||||||
where
|
where
|
||||||
@ -483,7 +483,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
|
|||||||
|
|
||||||
fn print_dyn_existential(
|
fn print_dyn_existential(
|
||||||
mut self,
|
mut self,
|
||||||
predicates: &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>>,
|
predicates: &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
|
||||||
) -> Result<Self::DynExistential, Self::Error> {
|
) -> Result<Self::DynExistential, Self::Error> {
|
||||||
for predicate in predicates {
|
for predicate in predicates {
|
||||||
self = self.in_binder(&predicate, |mut cx, predicate| {
|
self = self.in_binder(&predicate, |mut cx, predicate| {
|
||||||
|
@ -697,7 +697,7 @@ where
|
|||||||
{
|
{
|
||||||
fn visit_binder<T: TypeFoldable<'tcx>>(
|
fn visit_binder<T: TypeFoldable<'tcx>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
t: &ty::Binder<T>,
|
t: &ty::Binder<'tcx, T>,
|
||||||
) -> ControlFlow<Self::BreakTy> {
|
) -> ControlFlow<Self::BreakTy> {
|
||||||
t.as_ref().skip_binder().visit_with(self);
|
t.as_ref().skip_binder().visit_with(self);
|
||||||
ControlFlow::CONTINUE
|
ControlFlow::CONTINUE
|
||||||
|
@ -65,7 +65,7 @@ pub trait InferCtxtExt<'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
err: &mut DiagnosticBuilder<'_>,
|
err: &mut DiagnosticBuilder<'_>,
|
||||||
trait_ref: ty::Binder<ty::TraitRef<'tcx>>,
|
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||||
points_at_arg: bool,
|
points_at_arg: bool,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ pub trait InferCtxtExt<'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
err: &mut DiagnosticBuilder<'_>,
|
err: &mut DiagnosticBuilder<'_>,
|
||||||
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
|
trait_ref: &ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||||
points_at_arg: bool,
|
points_at_arg: bool,
|
||||||
has_custom_message: bool,
|
has_custom_message: bool,
|
||||||
) -> bool;
|
) -> bool;
|
||||||
@ -82,14 +82,14 @@ pub trait InferCtxtExt<'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
err: &mut DiagnosticBuilder<'_>,
|
err: &mut DiagnosticBuilder<'_>,
|
||||||
trait_ref: ty::Binder<ty::TraitRef<'tcx>>,
|
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||||
);
|
);
|
||||||
|
|
||||||
fn suggest_change_mut(
|
fn suggest_change_mut(
|
||||||
&self,
|
&self,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
err: &mut DiagnosticBuilder<'_>,
|
err: &mut DiagnosticBuilder<'_>,
|
||||||
trait_ref: ty::Binder<ty::TraitRef<'tcx>>,
|
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||||
points_at_arg: bool,
|
points_at_arg: bool,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ pub trait InferCtxtExt<'tcx> {
|
|||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
err: &mut DiagnosticBuilder<'_>,
|
err: &mut DiagnosticBuilder<'_>,
|
||||||
span: Span,
|
span: Span,
|
||||||
trait_ref: ty::Binder<ty::TraitRef<'tcx>>,
|
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||||
);
|
);
|
||||||
|
|
||||||
fn return_type_span(&self, obligation: &PredicateObligation<'tcx>) -> Option<Span>;
|
fn return_type_span(&self, obligation: &PredicateObligation<'tcx>) -> Option<Span>;
|
||||||
@ -108,7 +108,7 @@ pub trait InferCtxtExt<'tcx> {
|
|||||||
err: &mut DiagnosticBuilder<'_>,
|
err: &mut DiagnosticBuilder<'_>,
|
||||||
span: Span,
|
span: Span,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
trait_ref: ty::Binder<ty::TraitRef<'tcx>>,
|
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||||
) -> bool;
|
) -> bool;
|
||||||
|
|
||||||
fn point_at_returns_when_relevant(
|
fn point_at_returns_when_relevant(
|
||||||
@ -170,7 +170,7 @@ pub trait InferCtxtExt<'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
err: &mut DiagnosticBuilder<'_>,
|
err: &mut DiagnosticBuilder<'_>,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
trait_ref: ty::Binder<ty::TraitRef<'tcx>>,
|
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||||
span: Span,
|
span: Span,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -583,7 +583,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
err: &mut DiagnosticBuilder<'_>,
|
err: &mut DiagnosticBuilder<'_>,
|
||||||
trait_ref: ty::Binder<ty::TraitRef<'tcx>>,
|
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||||
points_at_arg: bool,
|
points_at_arg: bool,
|
||||||
) {
|
) {
|
||||||
let self_ty = match trait_ref.self_ty().no_bound_vars() {
|
let self_ty = match trait_ref.self_ty().no_bound_vars() {
|
||||||
@ -676,7 +676,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
err: &mut DiagnosticBuilder<'_>,
|
err: &mut DiagnosticBuilder<'_>,
|
||||||
trait_ref: &ty::Binder<ty::TraitRef<'tcx>>,
|
trait_ref: &ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||||
points_at_arg: bool,
|
points_at_arg: bool,
|
||||||
has_custom_message: bool,
|
has_custom_message: bool,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
@ -761,7 +761,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
err: &mut DiagnosticBuilder<'_>,
|
err: &mut DiagnosticBuilder<'_>,
|
||||||
trait_ref: ty::Binder<ty::TraitRef<'tcx>>,
|
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||||
) {
|
) {
|
||||||
let span = obligation.cause.span;
|
let span = obligation.cause.span;
|
||||||
|
|
||||||
@ -824,7 +824,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
err: &mut DiagnosticBuilder<'_>,
|
err: &mut DiagnosticBuilder<'_>,
|
||||||
trait_ref: ty::Binder<ty::TraitRef<'tcx>>,
|
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||||
points_at_arg: bool,
|
points_at_arg: bool,
|
||||||
) {
|
) {
|
||||||
let span = obligation.cause.span;
|
let span = obligation.cause.span;
|
||||||
@ -896,10 +896,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
err: &mut DiagnosticBuilder<'_>,
|
err: &mut DiagnosticBuilder<'_>,
|
||||||
span: Span,
|
span: Span,
|
||||||
trait_ref: ty::Binder<ty::TraitRef<'tcx>>,
|
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||||
) {
|
) {
|
||||||
let is_empty_tuple =
|
let is_empty_tuple =
|
||||||
|ty: ty::Binder<Ty<'_>>| *ty.skip_binder().kind() == ty::Tuple(ty::List::empty());
|
|ty: ty::Binder<'tcx, Ty<'_>>| *ty.skip_binder().kind() == ty::Tuple(ty::List::empty());
|
||||||
|
|
||||||
let hir = self.tcx.hir();
|
let hir = self.tcx.hir();
|
||||||
let parent_node = hir.get_parent_node(obligation.cause.body_id);
|
let parent_node = hir.get_parent_node(obligation.cause.body_id);
|
||||||
@ -948,7 +948,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
err: &mut DiagnosticBuilder<'_>,
|
err: &mut DiagnosticBuilder<'_>,
|
||||||
span: Span,
|
span: Span,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
trait_ref: ty::Binder<ty::TraitRef<'tcx>>,
|
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
match obligation.cause.code.peel_derives() {
|
match obligation.cause.code.peel_derives() {
|
||||||
// Only suggest `impl Trait` if the return type is unsized because it is `dyn Trait`.
|
// Only suggest `impl Trait` if the return type is unsized because it is `dyn Trait`.
|
||||||
@ -2190,7 +2190,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
|||||||
&self,
|
&self,
|
||||||
err: &mut DiagnosticBuilder<'_>,
|
err: &mut DiagnosticBuilder<'_>,
|
||||||
obligation: &PredicateObligation<'tcx>,
|
obligation: &PredicateObligation<'tcx>,
|
||||||
trait_ref: ty::Binder<ty::TraitRef<'tcx>>,
|
trait_ref: ty::Binder<'tcx, ty::TraitRef<'tcx>>,
|
||||||
span: Span,
|
span: Span,
|
||||||
) {
|
) {
|
||||||
debug!(
|
debug!(
|
||||||
|
@ -272,7 +272,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
obligation: &TraitObligation<'tcx>,
|
obligation: &TraitObligation<'tcx>,
|
||||||
trait_def_id: DefId,
|
trait_def_id: DefId,
|
||||||
nested: ty::Binder<Vec<Ty<'tcx>>>,
|
nested: ty::Binder<'tcx, Vec<Ty<'tcx>>>,
|
||||||
) -> ImplSourceAutoImplData<PredicateObligation<'tcx>> {
|
) -> ImplSourceAutoImplData<PredicateObligation<'tcx>> {
|
||||||
debug!(?nested, "vtable_auto_impl");
|
debug!(?nested, "vtable_auto_impl");
|
||||||
ensure_sufficient_stack(|| {
|
ensure_sufficient_stack(|| {
|
||||||
|
@ -204,7 +204,7 @@ struct EvaluatedCandidate<'tcx> {
|
|||||||
/// When does the builtin impl for `T: Trait` apply?
|
/// When does the builtin impl for `T: Trait` apply?
|
||||||
enum BuiltinImplConditions<'tcx> {
|
enum BuiltinImplConditions<'tcx> {
|
||||||
/// The impl is conditional on `T1, T2, ...: Trait`.
|
/// The impl is conditional on `T1, T2, ...: Trait`.
|
||||||
Where(ty::Binder<Vec<Ty<'tcx>>>),
|
Where(ty::Binder<'tcx, Vec<Ty<'tcx>>>),
|
||||||
/// There is no built-in impl. There may be some other
|
/// There is no built-in impl. There may be some other
|
||||||
/// candidate (a where-clause or user-defined impl).
|
/// candidate (a where-clause or user-defined impl).
|
||||||
None,
|
None,
|
||||||
@ -1673,7 +1673,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
/// Bar<i32> where struct Bar<T> { x: T, y: u32 } -> [i32, u32]
|
/// Bar<i32> where struct Bar<T> { x: T, y: u32 } -> [i32, u32]
|
||||||
/// Zed<i32> where enum Zed { A(T), B(u32) } -> [i32, u32]
|
/// Zed<i32> where enum Zed { A(T), B(u32) } -> [i32, u32]
|
||||||
/// ```
|
/// ```
|
||||||
fn constituent_types_for_ty(&self, t: ty::Binder<Ty<'tcx>>) -> ty::Binder<Vec<Ty<'tcx>>> {
|
fn constituent_types_for_ty(
|
||||||
|
&self,
|
||||||
|
t: ty::Binder<'tcx, Ty<'tcx>>,
|
||||||
|
) -> ty::Binder<'tcx, Vec<Ty<'tcx>>> {
|
||||||
match *t.skip_binder().kind() {
|
match *t.skip_binder().kind() {
|
||||||
ty::Uint(_)
|
ty::Uint(_)
|
||||||
| ty::Int(_)
|
| ty::Int(_)
|
||||||
@ -1746,7 +1749,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
cause: ObligationCause<'tcx>,
|
cause: ObligationCause<'tcx>,
|
||||||
recursion_depth: usize,
|
recursion_depth: usize,
|
||||||
trait_def_id: DefId,
|
trait_def_id: DefId,
|
||||||
types: ty::Binder<Vec<Ty<'tcx>>>,
|
types: ty::Binder<'tcx, Vec<Ty<'tcx>>>,
|
||||||
) -> Vec<PredicateObligation<'tcx>> {
|
) -> Vec<PredicateObligation<'tcx>> {
|
||||||
// Because the types were potentially derived from
|
// Because the types were potentially derived from
|
||||||
// higher-ranked obligations they may reference late-bound
|
// higher-ranked obligations they may reference late-bound
|
||||||
@ -1767,7 +1770,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||||||
.skip_binder() // binder moved -\
|
.skip_binder() // binder moved -\
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|ty| {
|
.flat_map(|ty| {
|
||||||
let ty: ty::Binder<Ty<'tcx>> = types.rebind(ty); // <----/
|
let ty: ty::Binder<'tcx, Ty<'tcx>> = types.rebind(ty); // <----/
|
||||||
|
|
||||||
self.infcx.commit_unconditionally(|_| {
|
self.infcx.commit_unconditionally(|_| {
|
||||||
let placeholder_ty = self.infcx.replace_bound_vars_with_placeholders(ty);
|
let placeholder_ty = self.infcx.replace_bound_vars_with_placeholders(ty);
|
||||||
|
@ -328,7 +328,7 @@ pub fn closure_trait_ref_and_return_type(
|
|||||||
self_ty: Ty<'tcx>,
|
self_ty: Ty<'tcx>,
|
||||||
sig: ty::PolyFnSig<'tcx>,
|
sig: ty::PolyFnSig<'tcx>,
|
||||||
tuple_arguments: TupleArgumentsFlag,
|
tuple_arguments: TupleArgumentsFlag,
|
||||||
) -> ty::Binder<(ty::TraitRef<'tcx>, Ty<'tcx>)> {
|
) -> ty::Binder<'tcx, (ty::TraitRef<'tcx>, Ty<'tcx>)> {
|
||||||
let arguments_tuple = match tuple_arguments {
|
let arguments_tuple = match tuple_arguments {
|
||||||
TupleArgumentsFlag::No => sig.skip_binder().inputs()[0],
|
TupleArgumentsFlag::No => sig.skip_binder().inputs()[0],
|
||||||
TupleArgumentsFlag::Yes => tcx.intern_tup(sig.skip_binder().inputs()),
|
TupleArgumentsFlag::Yes => tcx.intern_tup(sig.skip_binder().inputs()),
|
||||||
@ -346,7 +346,7 @@ pub fn generator_trait_ref_and_outputs(
|
|||||||
fn_trait_def_id: DefId,
|
fn_trait_def_id: DefId,
|
||||||
self_ty: Ty<'tcx>,
|
self_ty: Ty<'tcx>,
|
||||||
sig: ty::PolyGenSig<'tcx>,
|
sig: ty::PolyGenSig<'tcx>,
|
||||||
) -> ty::Binder<(ty::TraitRef<'tcx>, Ty<'tcx>, Ty<'tcx>)> {
|
) -> ty::Binder<'tcx, (ty::TraitRef<'tcx>, Ty<'tcx>, Ty<'tcx>)> {
|
||||||
debug_assert!(!self_ty.has_escaping_bound_vars());
|
debug_assert!(!self_ty.has_escaping_bound_vars());
|
||||||
let trait_ref = ty::TraitRef {
|
let trait_ref = ty::TraitRef {
|
||||||
def_id: fn_trait_def_id,
|
def_id: fn_trait_def_id,
|
||||||
|
@ -704,7 +704,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
|||||||
fn from_object_ty(
|
fn from_object_ty(
|
||||||
&mut self,
|
&mut self,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
data: &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>>,
|
data: &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
|
||||||
region: ty::Region<'tcx>,
|
region: ty::Region<'tcx>,
|
||||||
) {
|
) {
|
||||||
// Imagine a type like this:
|
// Imagine a type like this:
|
||||||
@ -767,7 +767,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
|
|||||||
/// `infer::required_region_bounds`, see that for more information.
|
/// `infer::required_region_bounds`, see that for more information.
|
||||||
pub fn object_region_bounds<'tcx>(
|
pub fn object_region_bounds<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
existential_predicates: &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>>,
|
existential_predicates: &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
|
||||||
) -> Vec<ty::Region<'tcx>> {
|
) -> Vec<ty::Region<'tcx>> {
|
||||||
// Since we don't actually *know* the self type for an object,
|
// Since we don't actually *know* the self type for an object,
|
||||||
// this "open(err)" serves as a kind of dummy standin -- basically
|
// this "open(err)" serves as a kind of dummy standin -- basically
|
||||||
|
@ -606,7 +606,7 @@ impl<'tcx> LowerInto<'tcx, Option<chalk_ir::QuantifiedWhereClause<RustInterner<'
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> LowerInto<'tcx, chalk_ir::Binders<chalk_ir::QuantifiedWhereClauses<RustInterner<'tcx>>>>
|
impl<'tcx> LowerInto<'tcx, chalk_ir::Binders<chalk_ir::QuantifiedWhereClauses<RustInterner<'tcx>>>>
|
||||||
for &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>>
|
for &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>
|
||||||
{
|
{
|
||||||
fn lower_into(
|
fn lower_into(
|
||||||
self,
|
self,
|
||||||
@ -677,7 +677,9 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Binders<chalk_ir::QuantifiedWhereClauses<Ru
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> LowerInto<'tcx, chalk_ir::FnSig<RustInterner<'tcx>>> for ty::Binder<ty::FnSig<'tcx>> {
|
impl<'tcx> LowerInto<'tcx, chalk_ir::FnSig<RustInterner<'tcx>>>
|
||||||
|
for ty::Binder<'tcx, ty::FnSig<'tcx>>
|
||||||
|
{
|
||||||
fn lower_into(self, _interner: &RustInterner<'_>) -> FnSig<RustInterner<'tcx>> {
|
fn lower_into(self, _interner: &RustInterner<'_>) -> FnSig<RustInterner<'tcx>> {
|
||||||
chalk_ir::FnSig {
|
chalk_ir::FnSig {
|
||||||
abi: self.abi(),
|
abi: self.abi(),
|
||||||
@ -801,7 +803,7 @@ impl<'tcx> LowerInto<'tcx, chalk_solve::rust_ir::AliasEqBound<RustInterner<'tcx>
|
|||||||
crate fn collect_bound_vars<'tcx, T: TypeFoldable<'tcx>>(
|
crate fn collect_bound_vars<'tcx, T: TypeFoldable<'tcx>>(
|
||||||
interner: &RustInterner<'tcx>,
|
interner: &RustInterner<'tcx>,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
ty: Binder<T>,
|
ty: Binder<'tcx, T>,
|
||||||
) -> (T, chalk_ir::VariableKinds<RustInterner<'tcx>>, BTreeMap<DefId, u32>) {
|
) -> (T, chalk_ir::VariableKinds<RustInterner<'tcx>>, BTreeMap<DefId, u32>) {
|
||||||
let mut bound_vars_collector = BoundVarsCollector::new();
|
let mut bound_vars_collector = BoundVarsCollector::new();
|
||||||
ty.as_ref().skip_binder().visit_with(&mut bound_vars_collector);
|
ty.as_ref().skip_binder().visit_with(&mut bound_vars_collector);
|
||||||
@ -849,7 +851,10 @@ impl<'tcx> BoundVarsCollector<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> {
|
impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> {
|
||||||
fn visit_binder<T: TypeFoldable<'tcx>>(&mut self, t: &Binder<T>) -> ControlFlow<Self::BreakTy> {
|
fn visit_binder<T: TypeFoldable<'tcx>>(
|
||||||
|
&mut self,
|
||||||
|
t: &Binder<'tcx, T>,
|
||||||
|
) -> ControlFlow<Self::BreakTy> {
|
||||||
self.binder_index.shift_in(1);
|
self.binder_index.shift_in(1);
|
||||||
let result = t.super_visit_with(self);
|
let result = t.super_visit_with(self);
|
||||||
self.binder_index.shift_out(1);
|
self.binder_index.shift_out(1);
|
||||||
@ -931,7 +936,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for NamedBoundVarSubstitutor<'a, 'tcx> {
|
|||||||
self.tcx
|
self.tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: Binder<T>) -> Binder<T> {
|
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: Binder<'tcx, T>) -> Binder<'tcx, T> {
|
||||||
self.binder_index.shift_in(1);
|
self.binder_index.shift_in(1);
|
||||||
let result = t.super_fold_with(self);
|
let result = t.super_fold_with(self);
|
||||||
self.binder_index.shift_out(1);
|
self.binder_index.shift_out(1);
|
||||||
@ -987,7 +992,7 @@ impl<'tcx> TypeFolder<'tcx> for ParamsSubstitutor<'tcx> {
|
|||||||
self.tcx
|
self.tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: Binder<T>) -> Binder<T> {
|
fn fold_binder<T: TypeFoldable<'tcx>>(&mut self, t: Binder<'tcx, T>) -> Binder<'tcx, T> {
|
||||||
self.binder_index.shift_in(1);
|
self.binder_index.shift_in(1);
|
||||||
let result = t.super_fold_with(self);
|
let result = t.super_fold_with(self);
|
||||||
self.binder_index.shift_out(1);
|
self.binder_index.shift_out(1);
|
||||||
|
@ -2450,7 +2450,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
fn compute_object_lifetime_bound(
|
fn compute_object_lifetime_bound(
|
||||||
&self,
|
&self,
|
||||||
span: Span,
|
span: Span,
|
||||||
existential_predicates: &'tcx ty::List<ty::Binder<ty::ExistentialPredicate<'tcx>>>,
|
existential_predicates: &'tcx ty::List<ty::Binder<'tcx, ty::ExistentialPredicate<'tcx>>>,
|
||||||
) -> Option<ty::Region<'tcx>> // if None, use the default
|
) -> Option<ty::Region<'tcx>> // if None, use the default
|
||||||
{
|
{
|
||||||
let tcx = self.tcx();
|
let tcx = self.tcx();
|
||||||
|
@ -26,7 +26,7 @@ pub struct Bounds<'tcx> {
|
|||||||
/// A list of region bounds on the (implicit) self type. So if you
|
/// A list of region bounds on the (implicit) self type. So if you
|
||||||
/// had `T: 'a + 'b` this might would be a list `['a, 'b]` (but
|
/// had `T: 'a + 'b` this might would be a list `['a, 'b]` (but
|
||||||
/// the `T` is not explicitly included).
|
/// the `T` is not explicitly included).
|
||||||
pub region_bounds: Vec<(ty::Binder<ty::Region<'tcx>>, Span)>,
|
pub region_bounds: Vec<(ty::Binder<'tcx, ty::Region<'tcx>>, Span)>,
|
||||||
|
|
||||||
/// A list of trait bounds. So if you had `T: Debug` this would be
|
/// A list of trait bounds. So if you had `T: Debug` this would be
|
||||||
/// `T: Debug`. Note that the self-type is explicit here.
|
/// `T: Debug`. Note that the self-type is explicit here.
|
||||||
|
@ -354,9 +354,9 @@ impl TypeRelation<'tcx> for SimpleEqRelation<'tcx> {
|
|||||||
|
|
||||||
fn binders<T>(
|
fn binders<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
a: ty::Binder<T>,
|
a: ty::Binder<'tcx, T>,
|
||||||
b: ty::Binder<T>,
|
b: ty::Binder<'tcx, T>,
|
||||||
) -> RelateResult<'tcx, ty::Binder<T>>
|
) -> RelateResult<'tcx, ty::Binder<'tcx, T>>
|
||||||
where
|
where
|
||||||
T: Relate<'tcx>,
|
T: Relate<'tcx>,
|
||||||
{
|
{
|
||||||
|
@ -550,7 +550,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
|
|||||||
upcast_trait_refs.into_iter().next().unwrap()
|
upcast_trait_refs.into_iter().next().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn replace_bound_vars_with_fresh_vars<T>(&self, value: ty::Binder<T>) -> T
|
fn replace_bound_vars_with_fresh_vars<T>(&self, value: ty::Binder<'tcx, T>) -> T
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
|
@ -1753,7 +1753,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
|
|||||||
/// region got replaced with the same variable, which requires a bit more coordination
|
/// region got replaced with the same variable, which requires a bit more coordination
|
||||||
/// and/or tracking the substitution and
|
/// and/or tracking the substitution and
|
||||||
/// so forth.
|
/// so forth.
|
||||||
fn erase_late_bound_regions<T>(&self, value: ty::Binder<T>) -> T
|
fn erase_late_bound_regions<T>(&self, value: ty::Binder<'tcx, T>) -> T
|
||||||
where
|
where
|
||||||
T: TypeFoldable<'tcx>,
|
T: TypeFoldable<'tcx>,
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user