Skip to content

Commit 480d852

Browse files
committed
Auto merge of #156542 - cyrgani:unbox-3, r=Nadrieril
remove `box_patterns` from remaining compiler crates Part of #156110.
2 parents 1a70f8d + d5f8ddf commit 480d852

46 files changed

Lines changed: 148 additions & 151 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

compiler/rustc_mir_build/src/builder/custom/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ macro_rules! parse_by_kind {
5353
} => $call_expr,
5454
)*
5555
$(
56-
ExprKind::Adt(box AdtExpr { adt_def, variant_index, .. }) if {
56+
ExprKind::Adt(AdtExpr { adt_def, variant_index, .. }) if {
5757
$self.tcx.is_diagnostic_item(rustc_span::sym::$adt, adt_def.did()) &&
5858
adt_def.variants()[*variant_index].name == rustc_span::sym::$variant
5959
} => $variant_expr,

compiler/rustc_mir_build/src/builder/custom/parse/instruction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl<'a, 'tcx> ParseCtxt<'a, 'tcx> {
275275
fields.iter().map(|e| self.parse_operand(*e)).collect::<Result<_, _>>()?
276276
))
277277
},
278-
ExprKind::Adt(box AdtExpr { adt_def, variant_index, args, fields, .. }) => {
278+
ExprKind::Adt(AdtExpr { adt_def, variant_index, args, fields, .. }) => {
279279
let is_union = adt_def.is_union();
280280
let active_field_index = is_union.then(|| fields[0].name);
281281

compiler/rustc_mir_build/src/builder/expr/as_rvalue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
242242

243243
block.and(Rvalue::Aggregate(Box::new(AggregateKind::Tuple), fields))
244244
}
245-
ExprKind::Closure(box ClosureExpr {
245+
ExprKind::Closure(ClosureExpr {
246246
closure_id,
247247
args,
248248
ref upvars,

compiler/rustc_mir_build/src/builder/expr/into.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
247247
ExprKind::LoopMatch {
248248
state,
249249
region_scope,
250-
match_data: box LoopMatchMatchData { box ref arms, span: match_span, scrutinee },
250+
match_data: LoopMatchMatchData { ref arms, span: match_span, scrutinee },
251251
} => {
252252
// Intuitively, this is a combination of a loop containing a labeled block
253253
// containing a match.
@@ -347,7 +347,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
347347
LintLevel::Inherited,
348348
move |this| {
349349
this.in_const_continuable_scope(
350-
Box::from(arms),
350+
arms.clone(),
351351
built_tree.clone(),
352352
state_place,
353353
expr_span,
@@ -587,7 +587,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
587587
this.cfg.push_assign(block, source_info, destination, address_of);
588588
block.unit()
589589
}
590-
ExprKind::Adt(box AdtExpr {
590+
ExprKind::Adt(AdtExpr {
591591
adt_def,
592592
variant_index,
593593
args,
@@ -698,7 +698,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
698698
);
699699
block.unit()
700700
}
701-
ExprKind::InlineAsm(box InlineAsmExpr {
701+
ExprKind::InlineAsm(InlineAsmExpr {
702702
asm_macro,
703703
template,
704704
ref operands,

compiler/rustc_mir_build/src/builder/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
885885
for stmt in &bb.statements {
886886
match &stmt.kind {
887887
// Ignore the implicit `()` return place assignment for unit functions/blocks
888-
StatementKind::Assign(box (_, Rvalue::Use(Operand::Constant(const_), _)))
888+
StatementKind::Assign((_, Rvalue::Use(Operand::Constant(const_), _)))
889889
if const_.ty().is_unit() =>
890890
{
891891
continue;

compiler/rustc_mir_build/src/builder/scope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
892892

893893
let expr = &self.thir[value];
894894
let constant = match &expr.kind {
895-
ExprKind::Adt(box AdtExpr { variant_index, fields, base, .. }) => {
895+
ExprKind::Adt(AdtExpr { variant_index, fields, base, .. }) => {
896896
assert!(matches!(base, AdtExprBase::None));
897897
assert!(fields.is_empty());
898898
ConstOperand {

compiler/rustc_mir_build/src/check_unsafety.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
510510
self.requires_unsafe(expr.span, DerefOfRawPointer);
511511
}
512512
}
513-
ExprKind::InlineAsm(box InlineAsmExpr {
513+
ExprKind::InlineAsm(InlineAsmExpr {
514514
asm_macro: asm_macro @ (AsmMacro::Asm | AsmMacro::NakedAsm),
515515
ref operands,
516516
template: _,
@@ -554,7 +554,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
554554
}
555555
return;
556556
}
557-
ExprKind::Adt(box AdtExpr {
557+
ExprKind::Adt(AdtExpr {
558558
adt_def,
559559
variant_index,
560560
args: _,
@@ -566,7 +566,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
566566
self.requires_unsafe(expr.span, InitializingTypeWithUnsafeField)
567567
}
568568
}
569-
ExprKind::Closure(box ClosureExpr {
569+
ExprKind::Closure(ClosureExpr {
570570
closure_id,
571571
args: _,
572572
upvars: _,

compiler/rustc_mir_build/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Construction of MIR from HIR.
22
33
// tidy-alphabetical-start
4-
#![feature(box_patterns)]
4+
#![feature(deref_patterns)]
55
#![feature(try_blocks)]
66
// tidy-alphabetical-end
77

compiler/rustc_mir_build/src/thir/pattern/check_match.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub(crate) fn check_match(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), Err
6060
};
6161

6262
for param in thir.params.iter() {
63-
if let Some(box ref pattern) = param.pat {
63+
if let Some(ref pattern) = param.pat {
6464
visitor.check_binding_is_irrefutable(pattern, origin, None, None);
6565
}
6666
}
@@ -149,16 +149,16 @@ impl<'p, 'tcx> Visitor<'p, 'tcx> for MatchVisitor<'p, 'tcx> {
149149
}
150150
return;
151151
}
152-
ExprKind::Match { scrutinee, box ref arms, match_source } => {
152+
ExprKind::Match { scrutinee, ref arms, match_source } => {
153153
self.check_match(scrutinee, arms, match_source, ex.span);
154154
}
155155
ExprKind::LoopMatch {
156-
match_data: box LoopMatchMatchData { scrutinee, box ref arms, span },
156+
match_data: LoopMatchMatchData { scrutinee, ref arms, span },
157157
..
158158
} => {
159159
self.check_match(scrutinee, arms, MatchSource::Normal, span);
160160
}
161-
ExprKind::Let { box ref pat, expr } => {
161+
ExprKind::Let { ref pat, expr } => {
162162
self.check_let(pat, Some(expr), ex.span, None);
163163
}
164164
ExprKind::LogicalOp { op: LogicalOp::And, .. }
@@ -179,7 +179,7 @@ impl<'p, 'tcx> Visitor<'p, 'tcx> for MatchVisitor<'p, 'tcx> {
179179

180180
fn visit_stmt(&mut self, stmt: &'p Stmt<'tcx>) {
181181
match stmt.kind {
182-
StmtKind::Let { box ref pattern, initializer, else_block, hir_id, span, .. } => {
182+
StmtKind::Let { ref pattern, initializer, else_block, hir_id, span, .. } => {
183183
self.with_hir_source(hir_id, |this| {
184184
let let_source =
185185
if else_block.is_some() { LetSource::LetElse } else { LetSource::PlainLet };
@@ -251,7 +251,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
251251
ExprKind::Scope { value, hir_id, .. } => {
252252
self.with_hir_source(hir_id, |this| this.visit_land_rhs(&this.thir[value]))
253253
}
254-
ExprKind::Let { box ref pat, expr } => {
254+
ExprKind::Let { ref pat, expr } => {
255255
let expr = &self.thir()[expr];
256256
self.with_let_source(LetSource::None, |this| {
257257
this.visit_expr(expr);
@@ -466,7 +466,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
466466
&& self.tcx.is_diagnostic_item(rustc_span::sym::Option, s_ty.did())
467467
&& let ExprKind::Scope { value, .. } = initializer.kind
468468
&& let initializer_expr = &self.thir[value]
469-
&& let ExprKind::Adt(box AdtExpr { fields, .. }) = &initializer_expr.kind
469+
&& let ExprKind::Adt(AdtExpr { fields, .. }) = &initializer_expr.kind
470470
&& let Some(field) = fields.first()
471471
&& let inner = &self.thir[field.expr]
472472
&& let Some(inner_ty) = inner.ty.ty_adt_def()
@@ -754,7 +754,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
754754
/// This analysis is *not* subsumed by NLL.
755755
fn check_borrow_conflicts_in_at_patterns<'tcx>(cx: &MatchVisitor<'_, 'tcx>, pat: &Pat<'tcx>) {
756756
// Extract `sub` in `binding @ sub`.
757-
let PatKind::Binding { name, mode, ty, subpattern: Some(box ref sub), .. } = pat.kind else {
757+
let PatKind::Binding { name, mode, ty, subpattern: Some(ref sub), .. } = pat.kind else {
758758
return;
759759
};
760760

compiler/rustc_mir_build/src/thir/pattern/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl<'tcx, 'ptcx> PatCtxt<'tcx, 'ptcx> {
177177
// Lower the endpoint into a temporary `thir::Pat` that will then be
178178
// deconstructed to obtain the constant value and other data.
179179
let endpoint_pat: Box<Pat<'tcx>> = self.lower_pat_expr(pat, expr);
180-
let box Pat { ref kind, extra, .. } = endpoint_pat;
180+
let Pat { ref kind, extra, .. } = endpoint_pat;
181181

182182
// Preserve any ascriptions from endpoint constants.
183183
if let Some(extra) = extra {

0 commit comments

Comments
 (0)