Pass ImplTraitContext as &, there's no need for that to be &mut
This commit is contained in:
@@ -984,7 +984,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
fn lower_assoc_ty_constraint(
|
||||
&mut self,
|
||||
constraint: &AssocConstraint,
|
||||
itctx: &mut ImplTraitContext,
|
||||
itctx: &ImplTraitContext,
|
||||
) -> hir::TypeBinding<'hir> {
|
||||
debug!("lower_assoc_ty_constraint(constraint={:?}, itctx={:?})", constraint, itctx);
|
||||
// lower generic arguments of identifier in constraint
|
||||
@@ -1003,7 +1003,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
} else {
|
||||
self.arena.alloc(hir::GenericArgs::none())
|
||||
};
|
||||
let mut itctx_tait = ImplTraitContext::TypeAliasesOpaqueTy;
|
||||
let itctx_tait = &ImplTraitContext::TypeAliasesOpaqueTy;
|
||||
|
||||
let kind = match constraint.kind {
|
||||
AssocConstraintKind::Equality { ref term } => {
|
||||
@@ -1041,9 +1041,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
// then to an opaque type).
|
||||
//
|
||||
// FIXME: this is only needed until `impl Trait` is allowed in type aliases.
|
||||
ImplTraitContext::Disallowed(_) if self.is_in_dyn_type => {
|
||||
(true, &mut itctx_tait)
|
||||
}
|
||||
ImplTraitContext::Disallowed(_) if self.is_in_dyn_type => (true, itctx_tait),
|
||||
|
||||
// We are in the parameter position, but not within a dyn type:
|
||||
//
|
||||
@@ -1122,7 +1120,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
fn lower_generic_arg(
|
||||
&mut self,
|
||||
arg: &ast::GenericArg,
|
||||
itctx: &mut ImplTraitContext,
|
||||
itctx: &ImplTraitContext,
|
||||
) -> hir::GenericArg<'hir> {
|
||||
match arg {
|
||||
ast::GenericArg::Lifetime(lt) => GenericArg::Lifetime(self.lower_lifetime(<)),
|
||||
@@ -1184,7 +1182,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
fn lower_ty(&mut self, t: &Ty, itctx: &mut ImplTraitContext) -> &'hir hir::Ty<'hir> {
|
||||
fn lower_ty(&mut self, t: &Ty, itctx: &ImplTraitContext) -> &'hir hir::Ty<'hir> {
|
||||
self.arena.alloc(self.lower_ty_direct(t, itctx))
|
||||
}
|
||||
|
||||
@@ -1194,7 +1192,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
qself: &Option<QSelf>,
|
||||
path: &Path,
|
||||
param_mode: ParamMode,
|
||||
itctx: &mut ImplTraitContext,
|
||||
itctx: &ImplTraitContext,
|
||||
) -> hir::Ty<'hir> {
|
||||
// Check whether we should interpret this as a bare trait object.
|
||||
// This check mirrors the one in late resolution. We only introduce this special case in
|
||||
@@ -1237,7 +1235,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
self.ty(span, hir::TyKind::Tup(tys))
|
||||
}
|
||||
|
||||
fn lower_ty_direct(&mut self, t: &Ty, itctx: &mut 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,
|
||||
@@ -1348,7 +1346,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
def_node_id,
|
||||
bounds,
|
||||
false,
|
||||
&mut ImplTraitContext::TypeAliasesOpaqueTy,
|
||||
&ImplTraitContext::TypeAliasesOpaqueTy,
|
||||
),
|
||||
ImplTraitContext::Universal => {
|
||||
let span = t.span;
|
||||
@@ -1435,7 +1433,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
opaque_ty_node_id: NodeId,
|
||||
bounds: &GenericBounds,
|
||||
in_trait: bool,
|
||||
itctx: &mut ImplTraitContext,
|
||||
itctx: &ImplTraitContext,
|
||||
) -> hir::TyKind<'hir> {
|
||||
// Make sure we know that some funky desugaring has been going on here.
|
||||
// This is a first: there is code in other places like for loop
|
||||
@@ -1681,11 +1679,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
}
|
||||
let inputs = self.arena.alloc_from_iter(inputs.iter().map(|param| {
|
||||
if fn_node_id.is_some() {
|
||||
self.lower_ty_direct(¶m.ty, &mut ImplTraitContext::Universal)
|
||||
self.lower_ty_direct(¶m.ty, &ImplTraitContext::Universal)
|
||||
} else {
|
||||
self.lower_ty_direct(
|
||||
¶m.ty,
|
||||
&mut ImplTraitContext::Disallowed(match kind {
|
||||
&ImplTraitContext::Disallowed(match kind {
|
||||
FnDeclKind::Fn | FnDeclKind::Inherent => {
|
||||
unreachable!("fn should allow in-band lifetimes")
|
||||
}
|
||||
@@ -2084,7 +2082,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
fn lower_param_bound(
|
||||
&mut self,
|
||||
tpb: &GenericBound,
|
||||
itctx: &mut ImplTraitContext,
|
||||
itctx: &ImplTraitContext,
|
||||
) -> hir::GenericBound<'hir> {
|
||||
match tpb {
|
||||
GenericBound::Trait(p, modifier) => hir::GenericBound::Trait(
|
||||
@@ -2200,7 +2198,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
GenericParamKind::Type { ref default, .. } => {
|
||||
let kind = hir::GenericParamKind::Type {
|
||||
default: default.as_ref().map(|x| {
|
||||
self.lower_ty(x, &mut ImplTraitContext::Disallowed(ImplTraitPosition::Type))
|
||||
self.lower_ty(x, &ImplTraitContext::Disallowed(ImplTraitPosition::Type))
|
||||
}),
|
||||
synthetic: false,
|
||||
};
|
||||
@@ -2208,8 +2206,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
(hir::ParamName::Plain(self.lower_ident(param.ident)), kind)
|
||||
}
|
||||
GenericParamKind::Const { ref ty, kw_span: _, ref default } => {
|
||||
let ty =
|
||||
self.lower_ty(&ty, &mut ImplTraitContext::Disallowed(ImplTraitPosition::Type));
|
||||
let ty = self.lower_ty(&ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Type));
|
||||
let default = default.as_ref().map(|def| self.lower_anon_const(def));
|
||||
(
|
||||
hir::ParamName::Plain(self.lower_ident(param.ident)),
|
||||
@@ -2219,11 +2216,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
}
|
||||
}
|
||||
|
||||
fn lower_trait_ref(
|
||||
&mut self,
|
||||
p: &TraitRef,
|
||||
itctx: &mut ImplTraitContext,
|
||||
) -> hir::TraitRef<'hir> {
|
||||
fn lower_trait_ref(&mut self, p: &TraitRef, itctx: &ImplTraitContext) -> hir::TraitRef<'hir> {
|
||||
let path = match self.lower_qpath(p.ref_id, &None, &p.path, ParamMode::Explicit, itctx) {
|
||||
hir::QPath::Resolved(None, path) => path,
|
||||
qpath => panic!("lower_trait_ref: unexpected QPath `{:?}`", qpath),
|
||||
@@ -2235,7 +2228,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
fn lower_poly_trait_ref(
|
||||
&mut self,
|
||||
p: &PolyTraitRef,
|
||||
itctx: &mut ImplTraitContext,
|
||||
itctx: &ImplTraitContext,
|
||||
) -> hir::PolyTraitRef<'hir> {
|
||||
let bound_generic_params =
|
||||
self.lower_lifetime_binder(p.trait_ref.ref_id, &p.bound_generic_params);
|
||||
@@ -2243,7 +2236,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
hir::PolyTraitRef { bound_generic_params, trait_ref, span: self.lower_span(p.span) }
|
||||
}
|
||||
|
||||
fn lower_mt(&mut self, mt: &MutTy, itctx: &mut ImplTraitContext) -> hir::MutTy<'hir> {
|
||||
fn lower_mt(&mut self, mt: &MutTy, itctx: &ImplTraitContext) -> hir::MutTy<'hir> {
|
||||
hir::MutTy { ty: self.lower_ty(&mt.ty, itctx), mutbl: mt.mutbl }
|
||||
}
|
||||
|
||||
@@ -2251,7 +2244,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
fn lower_param_bounds(
|
||||
&mut self,
|
||||
bounds: &[GenericBound],
|
||||
itctx: &mut ImplTraitContext,
|
||||
itctx: &ImplTraitContext,
|
||||
) -> hir::GenericBounds<'hir> {
|
||||
self.arena.alloc_from_iter(self.lower_param_bounds_mut(bounds, itctx))
|
||||
}
|
||||
@@ -2259,7 +2252,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
fn lower_param_bounds_mut<'s, 'b>(
|
||||
&'s mut self,
|
||||
bounds: &'s [GenericBound],
|
||||
itctx: &'b mut ImplTraitContext,
|
||||
itctx: &'b ImplTraitContext,
|
||||
) -> impl Iterator<Item = hir::GenericBound<'hir>> + Captures<'s> + Captures<'a> + Captures<'b>
|
||||
{
|
||||
bounds.iter().map(move |bound| self.lower_param_bound(bound, itctx))
|
||||
@@ -2291,7 +2284,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
node_id,
|
||||
&GenericParamKind::Type { default: None },
|
||||
bounds,
|
||||
&mut ImplTraitContext::Universal,
|
||||
&ImplTraitContext::Universal,
|
||||
hir::PredicateOrigin::ImplTrait,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user