Remove ImplTraitContext::reborrow
This commit is contained in:
parent
208ffbbe86
commit
d327db9319
3 changed files with 21 additions and 42 deletions
|
@ -293,18 +293,6 @@ enum ImplTraitPosition {
|
|||
ImplReturn,
|
||||
}
|
||||
|
||||
impl ImplTraitContext {
|
||||
fn reborrow<'this>(&'this mut self) -> ImplTraitContext {
|
||||
use self::ImplTraitContext::*;
|
||||
match self {
|
||||
Universal(parent) => Universal(*parent),
|
||||
ReturnPositionOpaqueTy { origin } => ReturnPositionOpaqueTy { origin: *origin },
|
||||
TypeAliasesOpaqueTy => TypeAliasesOpaqueTy,
|
||||
Disallowed(pos) => Disallowed(*pos),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for ImplTraitPosition {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let name = match self {
|
||||
|
@ -867,7 +855,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
fn lower_assoc_ty_constraint(
|
||||
&mut self,
|
||||
constraint: &AssocConstraint,
|
||||
mut itctx: ImplTraitContext,
|
||||
itctx: ImplTraitContext,
|
||||
) -> hir::TypeBinding<'hir> {
|
||||
debug!("lower_assoc_ty_constraint(constraint={:?}, itctx={:?})", constraint, itctx);
|
||||
|
||||
|
@ -875,12 +863,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
let gen_args = if let Some(ref gen_args) = constraint.gen_args {
|
||||
let gen_args_ctor = match gen_args {
|
||||
GenericArgs::AngleBracketed(ref data) => {
|
||||
self.lower_angle_bracketed_parameter_data(
|
||||
data,
|
||||
ParamMode::Explicit,
|
||||
itctx.reborrow(),
|
||||
)
|
||||
.0
|
||||
self.lower_angle_bracketed_parameter_data(data, ParamMode::Explicit, itctx).0
|
||||
}
|
||||
GenericArgs::Parenthesized(ref data) => {
|
||||
let mut err = self.sess.struct_span_err(
|
||||
|
@ -892,7 +875,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
self.lower_angle_bracketed_parameter_data(
|
||||
&data.as_angle_bracketed_args(),
|
||||
ParamMode::Explicit,
|
||||
itctx.reborrow(),
|
||||
itctx,
|
||||
)
|
||||
.0
|
||||
}
|
||||
|
@ -1097,7 +1080,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
self.ty(span, hir::TyKind::Tup(tys))
|
||||
}
|
||||
|
||||
fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext) -> hir::Ty<'hir> {
|
||||
fn lower_ty_direct(&mut self, t: &Ty, itctx: ImplTraitContext) -> hir::Ty<'hir> {
|
||||
let kind = match t.kind {
|
||||
TyKind::Infer => hir::TyKind::Infer,
|
||||
TyKind::Err => hir::TyKind::Err,
|
||||
|
@ -1129,11 +1112,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
}))
|
||||
}),
|
||||
TyKind::Never => hir::TyKind::Never,
|
||||
TyKind::Tup(ref tys) => {
|
||||
hir::TyKind::Tup(self.arena.alloc_from_iter(
|
||||
tys.iter().map(|ty| self.lower_ty_direct(ty, itctx.reborrow())),
|
||||
))
|
||||
}
|
||||
TyKind::Tup(ref tys) => hir::TyKind::Tup(
|
||||
self.arena.alloc_from_iter(tys.iter().map(|ty| self.lower_ty_direct(ty, itctx))),
|
||||
),
|
||||
TyKind::Paren(ref ty) => {
|
||||
return self.lower_ty_direct(ty, itctx);
|
||||
}
|
||||
|
@ -1167,7 +1148,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
GenericBound::Trait(
|
||||
ref ty,
|
||||
TraitBoundModifier::None | TraitBoundModifier::MaybeConst,
|
||||
) => Some(this.lower_poly_trait_ref(ty, itctx.reborrow())),
|
||||
) => Some(this.lower_poly_trait_ref(ty, itctx)),
|
||||
// `~const ?Bound` will cause an error during AST validation
|
||||
// anyways, so treat it like `?Bound` as compilation proceeds.
|
||||
GenericBound::Trait(
|
||||
|
@ -1935,12 +1916,12 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
fn lower_poly_trait_ref(
|
||||
&mut self,
|
||||
p: &PolyTraitRef,
|
||||
mut itctx: ImplTraitContext,
|
||||
itctx: ImplTraitContext,
|
||||
) -> hir::PolyTraitRef<'hir> {
|
||||
let bound_generic_params = self.lower_generic_params(&p.bound_generic_params);
|
||||
|
||||
let trait_ref = self.with_lifetime_binder(p.trait_ref.ref_id, |this| {
|
||||
this.lower_trait_ref(&p.trait_ref, itctx.reborrow())
|
||||
this.lower_trait_ref(&p.trait_ref, itctx)
|
||||
});
|
||||
|
||||
hir::PolyTraitRef { bound_generic_params, trait_ref, span: self.lower_span(p.span) }
|
||||
|
@ -1961,9 +1942,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
|||
fn lower_param_bounds_mut<'s>(
|
||||
&'s mut self,
|
||||
bounds: &'s [GenericBound],
|
||||
mut itctx: ImplTraitContext,
|
||||
itctx: ImplTraitContext,
|
||||
) -> impl Iterator<Item = hir::GenericBound<'hir>> + Captures<'s> + Captures<'a> {
|
||||
bounds.iter().map(move |bound| self.lower_param_bound(bound, itctx.reborrow()))
|
||||
bounds.iter().map(move |bound| self.lower_param_bound(bound, itctx))
|
||||
}
|
||||
|
||||
/// Lowers a block directly to an expression, presuming that it
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue