Rollup merge of #112060 - lcnr:early-binder, r=jackh726
`EarlyBinder::new` -> `EarlyBinder::bind` for consistency with `Binder::bind`. it may make sense to also add `EarlyBinder::dummy` in places where we know that no parameters exist, but I left that out of this PR. r? `@jackh726` `@kylematsuda`
This commit is contained in:
commit
e7fdba84e2
46 changed files with 60 additions and 60 deletions
|
@ -476,7 +476,7 @@ impl<'tcx> Body<'tcx> {
|
|||
/// Returns the return type; it always return first element from `local_decls` array.
|
||||
#[inline]
|
||||
pub fn bound_return_ty(&self) -> ty::EarlyBinder<Ty<'tcx>> {
|
||||
ty::EarlyBinder::new(self.local_decls[RETURN_PLACE].ty)
|
||||
ty::EarlyBinder::bind(self.local_decls[RETURN_PLACE].ty)
|
||||
}
|
||||
|
||||
/// Gets the location of the terminator for the given block.
|
||||
|
|
|
@ -573,7 +573,7 @@ impl<'tcx> AdtDef<'tcx> {
|
|||
/// Due to normalization being eager, this applies even if
|
||||
/// the associated type is behind a pointer (e.g., issue #31299).
|
||||
pub fn sized_constraint(self, tcx: TyCtxt<'tcx>) -> ty::EarlyBinder<&'tcx [Ty<'tcx>]> {
|
||||
ty::EarlyBinder::new(tcx.adt_sized_constraint(self.did()))
|
||||
ty::EarlyBinder::bind(tcx.adt_sized_constraint(self.did()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -254,5 +254,5 @@ pub fn const_param_default(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBind
|
|||
"`const_param_default` expected a generic parameter with a constant"
|
||||
),
|
||||
};
|
||||
ty::EarlyBinder::new(Const::from_anon_const(tcx, default_def_id))
|
||||
ty::EarlyBinder::bind(Const::from_anon_const(tcx, default_def_id))
|
||||
}
|
||||
|
|
|
@ -343,7 +343,7 @@ impl<'tcx> GenericPredicates<'tcx> {
|
|||
substs: SubstsRef<'tcx>,
|
||||
) -> impl Iterator<Item = (Predicate<'tcx>, Span)> + DoubleEndedIterator + ExactSizeIterator
|
||||
{
|
||||
EarlyBinder::new(self.predicates).subst_iter_copied(tcx, substs)
|
||||
EarlyBinder::bind(self.predicates).subst_iter_copied(tcx, substs)
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(self, tcx))]
|
||||
|
@ -358,7 +358,7 @@ impl<'tcx> GenericPredicates<'tcx> {
|
|||
}
|
||||
instantiated
|
||||
.predicates
|
||||
.extend(self.predicates.iter().map(|(p, _)| EarlyBinder::new(*p).subst(tcx, substs)));
|
||||
.extend(self.predicates.iter().map(|(p, _)| EarlyBinder::bind(*p).subst(tcx, substs)));
|
||||
instantiated.spans.extend(self.predicates.iter().map(|(_, sp)| *sp));
|
||||
}
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ impl<'tcx> InhabitedPredicate<'tcx> {
|
|||
fn subst_opt(self, tcx: TyCtxt<'tcx>, substs: ty::SubstsRef<'tcx>) -> Option<Self> {
|
||||
match self {
|
||||
Self::ConstIsZero(c) => {
|
||||
let c = ty::EarlyBinder::new(c).subst(tcx, substs);
|
||||
let c = ty::EarlyBinder::bind(c).subst(tcx, substs);
|
||||
let pred = match c.kind().try_to_target_usize(tcx) {
|
||||
Some(0) => Self::True,
|
||||
Some(1..) => Self::False,
|
||||
|
@ -167,7 +167,7 @@ impl<'tcx> InhabitedPredicate<'tcx> {
|
|||
Some(pred)
|
||||
}
|
||||
Self::GenericType(t) => {
|
||||
Some(ty::EarlyBinder::new(t).subst(tcx, substs).inhabited_predicate(tcx))
|
||||
Some(ty::EarlyBinder::bind(t).subst(tcx, substs).inhabited_predicate(tcx))
|
||||
}
|
||||
Self::And(&[a, b]) => match a.subst_opt(tcx, substs) {
|
||||
None => b.subst_opt(tcx, substs).map(|b| a.and(tcx, b)),
|
||||
|
|
|
@ -764,7 +764,7 @@ impl<'tcx> Predicate<'tcx> {
|
|||
let shifted_pred =
|
||||
tcx.shift_bound_var_indices(trait_bound_vars.len(), bound_pred.skip_binder());
|
||||
// 2) Self: Bar1<'a, '^0.1> -> T: Bar1<'^0.0, '^0.1>
|
||||
let new = EarlyBinder::new(shifted_pred).subst(tcx, trait_ref.skip_binder().substs);
|
||||
let new = EarlyBinder::bind(shifted_pred).subst(tcx, trait_ref.skip_binder().substs);
|
||||
// 3) ['x] + ['b] -> ['x, 'b]
|
||||
let bound_vars =
|
||||
tcx.mk_bound_variable_kinds_from_iter(trait_bound_vars.iter().chain(pred_bound_vars));
|
||||
|
|
|
@ -568,7 +568,7 @@ impl<'tcx> GeneratorSubsts<'tcx> {
|
|||
let layout = tcx.generator_layout(def_id).unwrap();
|
||||
layout.variant_fields.iter().map(move |variant| {
|
||||
variant.iter().map(move |field| {
|
||||
ty::EarlyBinder::new(layout.field_tys[*field].ty).subst(tcx, self.substs)
|
||||
ty::EarlyBinder::bind(layout.field_tys[*field].ty).subst(tcx, self.substs)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -545,7 +545,7 @@ impl<'tcx, T> !TypeFoldable<TyCtxt<'tcx>> for ty::EarlyBinder<T> {}
|
|||
impl<'tcx, T> !TypeVisitable<TyCtxt<'tcx>> for ty::EarlyBinder<T> {}
|
||||
|
||||
impl<T> EarlyBinder<T> {
|
||||
pub fn new(inner: T) -> EarlyBinder<T> {
|
||||
pub fn bind(inner: T) -> EarlyBinder<T> {
|
||||
EarlyBinder(inner)
|
||||
}
|
||||
|
||||
|
|
|
@ -709,7 +709,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
.as_ref()
|
||||
.map_or_else(|| [].iter(), |l| l.field_tys.iter())
|
||||
.filter(|decl| !decl.ignore_for_traits)
|
||||
.map(|decl| ty::EarlyBinder::new(decl.ty))
|
||||
.map(|decl| ty::EarlyBinder::bind(decl.ty))
|
||||
}
|
||||
|
||||
/// Normalizes all opaque types in the given value, replacing them
|
||||
|
|
|
@ -96,13 +96,13 @@ impl<'tcx> Value<TyCtxt<'tcx>, DepKind> for Representability {
|
|||
|
||||
impl<'tcx> Value<TyCtxt<'tcx>, DepKind> for ty::EarlyBinder<Ty<'_>> {
|
||||
fn from_cycle_error(tcx: TyCtxt<'tcx>, cycle: &[QueryInfo<DepKind>]) -> Self {
|
||||
ty::EarlyBinder::new(Ty::from_cycle_error(tcx, cycle))
|
||||
ty::EarlyBinder::bind(Ty::from_cycle_error(tcx, cycle))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> Value<TyCtxt<'tcx>, DepKind> for ty::EarlyBinder<ty::Binder<'_, ty::FnSig<'_>>> {
|
||||
fn from_cycle_error(tcx: TyCtxt<'tcx>, cycle: &[QueryInfo<DepKind>]) -> Self {
|
||||
ty::EarlyBinder::new(ty::Binder::from_cycle_error(tcx, cycle))
|
||||
ty::EarlyBinder::bind(ty::Binder::from_cycle_error(tcx, cycle))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue