Skip to content

Commit 9f77688

Browse files
committed
Completely remove captures flag
1 parent 20c88a2 commit 9f77688

File tree

8 files changed

+99
-193
lines changed

8 files changed

+99
-193
lines changed

compiler/rustc_ast_lowering/src/asm.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
234234
&sym.path,
235235
ParamMode::Optional,
236236
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
237-
true,
238237
);
239238
hir::InlineAsmOperand::SymStatic { path, def_id }
240239
} else {

compiler/rustc_ast_lowering/src/block.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
8484
}
8585

8686
fn lower_local(&mut self, l: &Local) -> &'hir hir::Local<'hir> {
87-
let ty = l.ty.as_ref().map(|t| {
88-
self.lower_ty(t, ImplTraitContext::Disallowed(ImplTraitPosition::Variable), true)
89-
});
87+
let ty = l
88+
.ty
89+
.as_ref()
90+
.map(|t| self.lower_ty(t, ImplTraitContext::Disallowed(ImplTraitPosition::Variable)));
9091
let init = l.kind.init().map(|init| self.lower_expr(init));
9192
let hir_id = self.lower_node_id(l.id);
9293
let pat = self.lower_pat(&l.pat);

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
6969
ParamMode::Optional,
7070
ParenthesizedGenericArgs::Err,
7171
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
72-
true,
7372
));
7473
let args = self.lower_exprs(args);
7574
hir::ExprKind::MethodCall(hir_seg, args, self.lower_span(span))
@@ -90,20 +89,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
9089
}
9190
ExprKind::Cast(ref expr, ref ty) => {
9291
let expr = self.lower_expr(expr);
93-
let ty = self.lower_ty(
94-
ty,
95-
ImplTraitContext::Disallowed(ImplTraitPosition::Type),
96-
true,
97-
);
92+
let ty =
93+
self.lower_ty(ty, ImplTraitContext::Disallowed(ImplTraitPosition::Type));
9894
hir::ExprKind::Cast(expr, ty)
9995
}
10096
ExprKind::Type(ref expr, ref ty) => {
10197
let expr = self.lower_expr(expr);
102-
let ty = self.lower_ty(
103-
ty,
104-
ImplTraitContext::Disallowed(ImplTraitPosition::Type),
105-
true,
106-
);
98+
let ty =
99+
self.lower_ty(ty, ImplTraitContext::Disallowed(ImplTraitPosition::Type));
107100
hir::ExprKind::Type(expr, ty)
108101
}
109102
ExprKind::AddrOf(k, m, ref ohs) => {
@@ -233,7 +226,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
233226
path,
234227
ParamMode::Optional,
235228
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
236-
true,
237229
);
238230
hir::ExprKind::Path(qpath)
239231
}
@@ -272,7 +264,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
272264
&se.path,
273265
ParamMode::Optional,
274266
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
275-
true,
276267
)),
277268
self.arena
278269
.alloc_from_iter(se.fields.iter().map(|x| self.lower_expr_field(x))),
@@ -570,11 +561,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
570561
body: impl FnOnce(&mut Self) -> hir::Expr<'hir>,
571562
) -> hir::ExprKind<'hir> {
572563
let output = match ret_ty {
573-
Some(ty) => hir::FnRetTy::Return(self.lower_ty(
574-
&ty,
575-
ImplTraitContext::Disallowed(ImplTraitPosition::AsyncBlock),
576-
true,
577-
)),
564+
Some(ty) => hir::FnRetTy::Return(
565+
self.lower_ty(&ty, ImplTraitContext::Disallowed(ImplTraitPosition::AsyncBlock)),
566+
),
578567
None => hir::FnRetTy::DefaultReturn(self.lower_span(span)),
579568
};
580569

@@ -1178,7 +1167,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
11781167
path,
11791168
ParamMode::Optional,
11801169
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
1181-
true,
11821170
);
11831171
// Destructure like a tuple struct.
11841172
let tuple_struct_pat =
@@ -1195,7 +1183,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
11951183
path,
11961184
ParamMode::Optional,
11971185
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
1198-
true,
11991186
);
12001187
// Destructure like a unit struct.
12011188
let unit_struct_pat = hir::PatKind::Path(qpath);
@@ -1220,7 +1207,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
12201207
&se.path,
12211208
ParamMode::Optional,
12221209
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
1223-
true,
12241210
);
12251211
let fields_omitted = match &se.rest {
12261212
StructRest::Base(e) => {

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
308308
&generics,
309309
id,
310310
ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
311-
|this| this.lower_ty(ty, ImplTraitContext::TypeAliasesOpaqueTy, true),
311+
|this| this.lower_ty(ty, ImplTraitContext::TypeAliasesOpaqueTy),
312312
);
313313
hir::ItemKind::TyAlias(ty, generics)
314314
}
@@ -386,15 +386,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
386386
this.lower_trait_ref(
387387
trait_ref,
388388
ImplTraitContext::Disallowed(ImplTraitPosition::Trait),
389-
true,
390389
)
391390
});
392391

393-
let lowered_ty = this.lower_ty(
394-
ty,
395-
ImplTraitContext::Disallowed(ImplTraitPosition::Type),
396-
true,
397-
);
392+
let lowered_ty = this
393+
.lower_ty(ty, ImplTraitContext::Disallowed(ImplTraitPosition::Type));
398394

399395
(trait_ref, lowered_ty)
400396
});
@@ -438,7 +434,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
438434
let bounds = this.lower_param_bounds(
439435
bounds,
440436
ImplTraitContext::Disallowed(ImplTraitPosition::Bound),
441-
true,
442437
);
443438
let items = this.arena.alloc_from_iter(
444439
items.iter().map(|item| this.lower_trait_item_ref(item)),
@@ -458,7 +453,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
458453
this.lower_param_bounds(
459454
bounds,
460455
ImplTraitContext::Disallowed(ImplTraitPosition::Bound),
461-
true,
462456
)
463457
},
464458
);
@@ -481,7 +475,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
481475
span: Span,
482476
body: Option<&Expr>,
483477
) -> (&'hir hir::Ty<'hir>, hir::BodyId) {
484-
let ty = self.lower_ty(ty, ImplTraitContext::Disallowed(ImplTraitPosition::Type), true);
478+
let ty = self.lower_ty(ty, ImplTraitContext::Disallowed(ImplTraitPosition::Type));
485479
(ty, self.lower_const_body(span, body))
486480
}
487481

@@ -667,11 +661,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
667661
hir::ForeignItemKind::Fn(fn_dec, fn_args, generics)
668662
}
669663
ForeignItemKind::Static(ref t, m, _) => {
670-
let ty = self.lower_ty(
671-
t,
672-
ImplTraitContext::Disallowed(ImplTraitPosition::Type),
673-
true,
674-
);
664+
let ty =
665+
self.lower_ty(t, ImplTraitContext::Disallowed(ImplTraitPosition::Type));
675666
hir::ForeignItemKind::Static(ty, m)
676667
}
677668
ForeignItemKind::TyAlias(..) => hir::ForeignItemKind::Type,
@@ -740,11 +731,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
740731
path,
741732
ParamMode::ExplicitNamed, // no `'_` in declarations (Issue #61124)
742733
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
743-
true,
744734
);
745735
self.arena.alloc(t)
746736
} else {
747-
self.lower_ty(&f.ty, ImplTraitContext::Disallowed(ImplTraitPosition::Type), true)
737+
self.lower_ty(&f.ty, ImplTraitContext::Disallowed(ImplTraitPosition::Type))
748738
};
749739
let hir_id = self.lower_node_id(f.id);
750740
self.lower_attrs(hir_id, &f.attrs);
@@ -767,8 +757,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
767757

768758
let (generics, kind, has_default) = match i.kind {
769759
AssocItemKind::Const(_, ref ty, ref default) => {
770-
let ty =
771-
self.lower_ty(ty, ImplTraitContext::Disallowed(ImplTraitPosition::Type), true);
760+
let ty = self.lower_ty(ty, ImplTraitContext::Disallowed(ImplTraitPosition::Type));
772761
let body = default.as_ref().map(|x| self.lower_const_body(i.span, Some(x)));
773762
(hir::Generics::empty(), hir::TraitItemKind::Const(ty, body), body.is_some())
774763
}
@@ -806,17 +795,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
806795
ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
807796
|this| {
808797
let ty = ty.as_ref().map(|x| {
809-
this.lower_ty(
810-
x,
811-
ImplTraitContext::Disallowed(ImplTraitPosition::Type),
812-
true,
813-
)
798+
this.lower_ty(x, ImplTraitContext::Disallowed(ImplTraitPosition::Type))
814799
});
815800
hir::TraitItemKind::Type(
816801
this.lower_param_bounds(
817802
bounds,
818803
ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
819-
true,
820804
),
821805
ty,
822806
)
@@ -869,8 +853,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
869853

870854
let (generics, kind) = match &i.kind {
871855
AssocItemKind::Const(_, ty, expr) => {
872-
let ty =
873-
self.lower_ty(ty, ImplTraitContext::Disallowed(ImplTraitPosition::Type), true);
856+
let ty = self.lower_ty(ty, ImplTraitContext::Disallowed(ImplTraitPosition::Type));
874857
(
875858
hir::Generics::empty(),
876859
hir::ImplItemKind::Const(ty, self.lower_const_body(i.span, expr.as_deref())),
@@ -904,7 +887,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
904887
hir::ImplItemKind::TyAlias(ty)
905888
}
906889
Some(ty) => {
907-
let ty = this.lower_ty(ty, ImplTraitContext::TypeAliasesOpaqueTy, true);
890+
let ty = this.lower_ty(ty, ImplTraitContext::TypeAliasesOpaqueTy);
908891
hir::ImplItemKind::TyAlias(ty)
909892
}
910893
},
@@ -1429,7 +1412,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14291412
return None;
14301413
}
14311414

1432-
let bounds = self.lower_param_bounds(bounds, itctx, true);
1415+
let bounds = self.lower_param_bounds(bounds, itctx);
14331416

14341417
let ident = self.lower_ident(ident);
14351418
let param_span = ident.span;
@@ -1475,8 +1458,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14751458
panic!("Missing resolution for lifetime {:?} at {:?}", id, ident.span)
14761459
});
14771460
let lt_id = self.next_node_id();
1478-
let lifetime =
1479-
self.new_named_lifetime_with_res(lt_id, ident_span, ident, res, true);
1461+
let lifetime = self.new_named_lifetime_with_res(lt_id, ident_span, ident, res);
14801462
Some(hir::WherePredicate::RegionPredicate(hir::WhereRegionPredicate {
14811463
lifetime,
14821464
span,
@@ -1496,16 +1478,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
14961478
span,
14971479
}) => hir::WherePredicate::BoundPredicate(hir::WhereBoundPredicate {
14981480
bound_generic_params: self.lower_generic_params(bound_generic_params),
1499-
bounded_ty: self.lower_ty(
1500-
bounded_ty,
1501-
ImplTraitContext::Disallowed(ImplTraitPosition::Type),
1502-
true,
1503-
),
1481+
bounded_ty: self
1482+
.lower_ty(bounded_ty, ImplTraitContext::Disallowed(ImplTraitPosition::Type)),
15041483
bounds: self.arena.alloc_from_iter(bounds.iter().map(|bound| {
15051484
self.lower_param_bound(
15061485
bound,
15071486
ImplTraitContext::Disallowed(ImplTraitPosition::Bound),
1508-
true,
15091487
)
15101488
})),
15111489
span: self.lower_span(span),
@@ -1517,27 +1495,20 @@ impl<'hir> LoweringContext<'_, 'hir> {
15171495
span,
15181496
}) => hir::WherePredicate::RegionPredicate(hir::WhereRegionPredicate {
15191497
span: self.lower_span(span),
1520-
lifetime: self.lower_lifetime(lifetime, true),
1498+
lifetime: self.lower_lifetime(lifetime),
15211499
bounds: self.lower_param_bounds(
15221500
bounds,
15231501
ImplTraitContext::Disallowed(ImplTraitPosition::Bound),
1524-
true,
15251502
),
15261503
in_where_clause: true,
15271504
}),
15281505
WherePredicate::EqPredicate(WhereEqPredicate { id, ref lhs_ty, ref rhs_ty, span }) => {
15291506
hir::WherePredicate::EqPredicate(hir::WhereEqPredicate {
15301507
hir_id: self.lower_node_id(id),
1531-
lhs_ty: self.lower_ty(
1532-
lhs_ty,
1533-
ImplTraitContext::Disallowed(ImplTraitPosition::Type),
1534-
true,
1535-
),
1536-
rhs_ty: self.lower_ty(
1537-
rhs_ty,
1538-
ImplTraitContext::Disallowed(ImplTraitPosition::Type),
1539-
true,
1540-
),
1508+
lhs_ty: self
1509+
.lower_ty(lhs_ty, ImplTraitContext::Disallowed(ImplTraitPosition::Type)),
1510+
rhs_ty: self
1511+
.lower_ty(rhs_ty, ImplTraitContext::Disallowed(ImplTraitPosition::Type)),
15411512
span: self.lower_span(span),
15421513
})
15431514
}

0 commit comments

Comments
 (0)