1
Fork 0

Pass ImplTraitContext as &, there's no need for that to be &mut

This commit is contained in:
Santiago Pastorino 2022-09-14 17:39:52 -03:00
parent 669f2d4550
commit 861055094c
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF
6 changed files with 84 additions and 107 deletions

View file

@ -66,7 +66,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
seg,
ParamMode::Optional,
ParenthesizedGenericArgs::Err,
&mut ImplTraitContext::Disallowed(ImplTraitPosition::Path),
&ImplTraitContext::Disallowed(ImplTraitPosition::Path),
));
let receiver = self.lower_expr(receiver);
let args =
@ -89,14 +89,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
ExprKind::Cast(ref expr, ref ty) => {
let expr = self.lower_expr(expr);
let ty = self
.lower_ty(ty, &mut ImplTraitContext::Disallowed(ImplTraitPosition::Type));
let ty =
self.lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Type));
hir::ExprKind::Cast(expr, ty)
}
ExprKind::Type(ref expr, ref ty) => {
let expr = self.lower_expr(expr);
let ty = self
.lower_ty(ty, &mut ImplTraitContext::Disallowed(ImplTraitPosition::Type));
let ty =
self.lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Type));
hir::ExprKind::Type(expr, ty)
}
ExprKind::AddrOf(k, m, ref ohs) => {
@ -225,7 +225,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
qself,
path,
ParamMode::Optional,
&mut ImplTraitContext::Disallowed(ImplTraitPosition::Path),
&ImplTraitContext::Disallowed(ImplTraitPosition::Path),
);
hir::ExprKind::Path(qpath)
}
@ -259,7 +259,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
&se.qself,
&se.path,
ParamMode::Optional,
&mut ImplTraitContext::Disallowed(ImplTraitPosition::Path),
&ImplTraitContext::Disallowed(ImplTraitPosition::Path),
)),
self.arena
.alloc_from_iter(se.fields.iter().map(|x| self.lower_expr_field(x))),
@ -556,14 +556,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
async_gen_kind: hir::AsyncGeneratorKind,
body: impl FnOnce(&mut Self) -> hir::Expr<'hir>,
) -> hir::ExprKind<'hir> {
let output =
match ret_ty {
Some(ty) => hir::FnRetTy::Return(self.lower_ty(
&ty,
&mut ImplTraitContext::Disallowed(ImplTraitPosition::AsyncBlock),
)),
None => hir::FnRetTy::DefaultReturn(self.lower_span(span)),
};
let output = match ret_ty {
Some(ty) => hir::FnRetTy::Return(
self.lower_ty(&ty, &ImplTraitContext::Disallowed(ImplTraitPosition::AsyncBlock)),
),
None => hir::FnRetTy::DefaultReturn(self.lower_span(span)),
};
// Resume argument type. We let the compiler infer this to simplify the lowering. It is
// fully constrained by `future::from_generator`.
@ -1131,7 +1129,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
qself,
path,
ParamMode::Optional,
&mut ImplTraitContext::Disallowed(ImplTraitPosition::Path),
&ImplTraitContext::Disallowed(ImplTraitPosition::Path),
);
// Destructure like a tuple struct.
let tuple_struct_pat = hir::PatKind::TupleStruct(
@ -1150,7 +1148,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
qself,
path,
ParamMode::Optional,
&mut ImplTraitContext::Disallowed(ImplTraitPosition::Path),
&ImplTraitContext::Disallowed(ImplTraitPosition::Path),
);
// Destructure like a unit struct.
let unit_struct_pat = hir::PatKind::Path(qpath);
@ -1174,7 +1172,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
&se.qself,
&se.path,
ParamMode::Optional,
&mut ImplTraitContext::Disallowed(ImplTraitPosition::Path),
&ImplTraitContext::Disallowed(ImplTraitPosition::Path),
);
let fields_omitted = match &se.rest {
StructRest::Base(e) => {