Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/builder/custom/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ macro_rules! parse_by_kind {
} => $call_expr,
)*
$(
ExprKind::Adt(box AdtExpr { adt_def, variant_index, .. }) if {
ExprKind::Adt(AdtExpr { adt_def, variant_index, .. }) if {
$self.tcx.is_diagnostic_item(rustc_span::sym::$adt, adt_def.did()) &&
adt_def.variants()[*variant_index].name == rustc_span::sym::$variant
} => $variant_expr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ impl<'a, 'tcx> ParseCtxt<'a, 'tcx> {
fields.iter().map(|e| self.parse_operand(*e)).collect::<Result<_, _>>()?
))
},
ExprKind::Adt(box AdtExpr { adt_def, variant_index, args, fields, .. }) => {
ExprKind::Adt(AdtExpr { adt_def, variant_index, args, fields, .. }) => {
let is_union = adt_def.is_union();
let active_field_index = is_union.then(|| fields[0].name);

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/builder/expr/as_rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {

block.and(Rvalue::Aggregate(Box::new(AggregateKind::Tuple), fields))
}
ExprKind::Closure(box ClosureExpr {
ExprKind::Closure(ClosureExpr {
closure_id,
args,
ref upvars,
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_mir_build/src/builder/expr/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
ExprKind::LoopMatch {
state,
region_scope,
match_data: box LoopMatchMatchData { box ref arms, span: match_span, scrutinee },
match_data: LoopMatchMatchData { ref arms, span: match_span, scrutinee },
} => {
// Intuitively, this is a combination of a loop containing a labeled block
// containing a match.
Expand Down Expand Up @@ -347,7 +347,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
LintLevel::Inherited,
move |this| {
this.in_const_continuable_scope(
Box::from(arms),
arms.clone(),
built_tree.clone(),
state_place,
expr_span,
Expand Down Expand Up @@ -587,7 +587,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
this.cfg.push_assign(block, source_info, destination, address_of);
block.unit()
}
ExprKind::Adt(box AdtExpr {
ExprKind::Adt(AdtExpr {
adt_def,
variant_index,
args,
Expand Down Expand Up @@ -698,7 +698,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
);
block.unit()
}
ExprKind::InlineAsm(box InlineAsmExpr {
ExprKind::InlineAsm(InlineAsmExpr {
asm_macro,
template,
ref operands,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
for stmt in &bb.statements {
match &stmt.kind {
// Ignore the implicit `()` return place assignment for unit functions/blocks
StatementKind::Assign(box (_, Rvalue::Use(Operand::Constant(const_), _)))
StatementKind::Assign((_, Rvalue::Use(Operand::Constant(const_), _)))
if const_.ty().is_unit() =>
{
continue;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/builder/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {

let expr = &self.thir[value];
let constant = match &expr.kind {
ExprKind::Adt(box AdtExpr { variant_index, fields, base, .. }) => {
ExprKind::Adt(AdtExpr { variant_index, fields, base, .. }) => {
assert!(matches!(base, AdtExprBase::None));
assert!(fields.is_empty());
ConstOperand {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_mir_build/src/check_unsafety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
self.requires_unsafe(expr.span, DerefOfRawPointer);
}
}
ExprKind::InlineAsm(box InlineAsmExpr {
ExprKind::InlineAsm(InlineAsmExpr {
asm_macro: asm_macro @ (AsmMacro::Asm | AsmMacro::NakedAsm),
ref operands,
template: _,
Expand Down Expand Up @@ -554,7 +554,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
}
return;
}
ExprKind::Adt(box AdtExpr {
ExprKind::Adt(AdtExpr {
adt_def,
variant_index,
args: _,
Expand All @@ -566,7 +566,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
self.requires_unsafe(expr.span, InitializingTypeWithUnsafeField)
}
}
ExprKind::Closure(box ClosureExpr {
ExprKind::Closure(ClosureExpr {
closure_id,
args: _,
upvars: _,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Construction of MIR from HIR.

// tidy-alphabetical-start
#![feature(box_patterns)]
#![feature(deref_patterns)]
#![feature(try_blocks)]
// tidy-alphabetical-end

Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_mir_build/src/thir/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub(crate) fn check_match(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), Err
};

for param in thir.params.iter() {
if let Some(box ref pattern) = param.pat {
if let Some(ref pattern) = param.pat {
visitor.check_binding_is_irrefutable(pattern, origin, None, None);
}
}
Expand Down Expand Up @@ -149,16 +149,16 @@ impl<'p, 'tcx> Visitor<'p, 'tcx> for MatchVisitor<'p, 'tcx> {
}
return;
}
ExprKind::Match { scrutinee, box ref arms, match_source } => {
ExprKind::Match { scrutinee, ref arms, match_source } => {
self.check_match(scrutinee, arms, match_source, ex.span);
}
ExprKind::LoopMatch {
match_data: box LoopMatchMatchData { scrutinee, box ref arms, span },
match_data: LoopMatchMatchData { scrutinee, ref arms, span },
..
} => {
self.check_match(scrutinee, arms, MatchSource::Normal, span);
}
ExprKind::Let { box ref pat, expr } => {
ExprKind::Let { ref pat, expr } => {
self.check_let(pat, Some(expr), ex.span, None);
}
ExprKind::LogicalOp { op: LogicalOp::And, .. }
Expand All @@ -179,7 +179,7 @@ impl<'p, 'tcx> Visitor<'p, 'tcx> for MatchVisitor<'p, 'tcx> {

fn visit_stmt(&mut self, stmt: &'p Stmt<'tcx>) {
match stmt.kind {
StmtKind::Let { box ref pattern, initializer, else_block, hir_id, span, .. } => {
StmtKind::Let { ref pattern, initializer, else_block, hir_id, span, .. } => {
self.with_hir_source(hir_id, |this| {
let let_source =
if else_block.is_some() { LetSource::LetElse } else { LetSource::PlainLet };
Expand Down Expand Up @@ -251,7 +251,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
ExprKind::Scope { value, hir_id, .. } => {
self.with_hir_source(hir_id, |this| this.visit_land_rhs(&this.thir[value]))
}
ExprKind::Let { box ref pat, expr } => {
ExprKind::Let { ref pat, expr } => {
let expr = &self.thir()[expr];
self.with_let_source(LetSource::None, |this| {
this.visit_expr(expr);
Expand Down Expand Up @@ -466,7 +466,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
&& self.tcx.is_diagnostic_item(rustc_span::sym::Option, s_ty.did())
&& let ExprKind::Scope { value, .. } = initializer.kind
&& let initializer_expr = &self.thir[value]
&& let ExprKind::Adt(box AdtExpr { fields, .. }) = &initializer_expr.kind
&& let ExprKind::Adt(AdtExpr { fields, .. }) = &initializer_expr.kind
&& let Some(field) = fields.first()
&& let inner = &self.thir[field.expr]
&& let Some(inner_ty) = inner.ty.ty_adt_def()
Expand Down Expand Up @@ -754,7 +754,7 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
/// This analysis is *not* subsumed by NLL.
fn check_borrow_conflicts_in_at_patterns<'tcx>(cx: &MatchVisitor<'_, 'tcx>, pat: &Pat<'tcx>) {
// Extract `sub` in `binding @ sub`.
let PatKind::Binding { name, mode, ty, subpattern: Some(box ref sub), .. } = pat.kind else {
let PatKind::Binding { name, mode, ty, subpattern: Some(ref sub), .. } = pat.kind else {
return;
};

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/thir/pattern/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl<'tcx, 'ptcx> PatCtxt<'tcx, 'ptcx> {
// Lower the endpoint into a temporary `thir::Pat` that will then be
// deconstructed to obtain the constant value and other data.
let endpoint_pat: Box<Pat<'tcx>> = self.lower_pat_expr(pat, expr);
let box Pat { ref kind, extra, .. } = endpoint_pat;
let Pat { ref kind, extra, .. } = endpoint_pat;

// Preserve any ascriptions from endpoint constants.
if let Some(extra) = extra {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_dataflow/src/impls/initialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<'tcx> MaybePlacesSwitchIntData<'tcx> {
let block_data = &body[block];
for statement in block_data.statements.iter().rev() {
match statement.kind {
mir::StatementKind::Assign(box (lhs, mir::Rvalue::Discriminant(enum_place)))
mir::StatementKind::Assign((lhs, mir::Rvalue::Discriminant(enum_place)))
if lhs == discr =>
{
match enum_place.ty(body, tcx).ty.kind() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_dataflow/src/impls/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl<'a> MaybeTransitiveLiveLocals<'a> {
) -> Option<Place<'tcx>> {
// Compute the place that we are storing to, if any
let destination = match stmt_kind {
StatementKind::Assign(box (place, rvalue)) => (rvalue.is_safe_to_remove()
StatementKind::Assign((place, rvalue)) => (rvalue.is_safe_to_remove()
// FIXME: We are not sure how we should represent this debugging information for some statements,
// keep it for now.
&& (!debuginfo_locals.contains(place.local)
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ impl<'tcx> Analysis<'tcx> for MaybeRequiresStorage<'_, 'tcx> {
StatementKind::StorageDead(l) => state.kill(*l),

// If a place is assigned to in a statement, it needs storage for that statement.
StatementKind::Assign(box (place, _))
| StatementKind::SetDiscriminant { box place, .. } => {
StatementKind::Assign((place, _)) => {
state.gen_(place.local);
}
StatementKind::SetDiscriminant { place, .. } => {
state.gen_(place.local);
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_dataflow/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// tidy-alphabetical-start
#![feature(associated_type_defaults)]
#![feature(box_patterns)]
#![feature(deref_patterns)]
#![feature(exact_size_is_empty)]
#![feature(file_buffered)]
#![feature(never_type)]
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_mir_dataflow/src/move_paths/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ impl<'a, 'tcx, F: Fn(Ty<'tcx>) -> bool> MoveDataBuilder<'a, 'tcx, F> {
fn gather_statement(&mut self, stmt: &Statement<'tcx>) {
debug!("gather_statement({:?}, {:?})", self.loc, stmt);
match &stmt.kind {
StatementKind::Assign(box (place, Rvalue::CopyForDeref(reffed))) => {
StatementKind::Assign((place, Rvalue::CopyForDeref(reffed))) => {
let local = place.as_local().unwrap();
assert!(self.body.local_decls[local].is_deref_temp());

Expand All @@ -389,12 +389,12 @@ impl<'a, 'tcx, F: Fn(Ty<'tcx>) -> bool> MoveDataBuilder<'a, 'tcx, F> {
let base_local = rev_lookup.un_derefer.deref_chain(local).first().unwrap().local;
rev_lookup.locals[local] = rev_lookup.locals[base_local];
}
StatementKind::Assign(box (place, rval)) => {
StatementKind::Assign((place, rval)) => {
self.create_move_path(*place);
self.gather_init(place.as_ref(), InitKind::Deep);
self.gather_rvalue(rval);
}
StatementKind::FakeRead(box (_, place)) => {
StatementKind::FakeRead((_, place)) => {
self.create_move_path(*place);
}
StatementKind::StorageLive(_) => {}
Expand Down Expand Up @@ -428,7 +428,7 @@ impl<'a, 'tcx, F: Fn(Ty<'tcx>) -> bool> MoveDataBuilder<'a, 'tcx, F> {
| Rvalue::Cast(_, ref operand, _)
| Rvalue::UnaryOp(_, ref operand)
| Rvalue::WrapUnsafeBinder(ref operand, _) => self.gather_operand(operand),
Rvalue::BinaryOp(ref _binop, box (ref lhs, ref rhs)) => {
Rvalue::BinaryOp(ref _binop, (ref lhs, ref rhs)) => {
self.gather_operand(lhs);
self.gather_operand(rhs);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_dataflow/src/rustc_peek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fn value_assigned_to_local<'a, 'tcx>(
stmt: &'a mir::Statement<'tcx>,
local: Local,
) -> Option<&'a mir::Rvalue<'tcx>> {
if let mir::StatementKind::Assign(box (place, rvalue)) = &stmt.kind
if let mir::StatementKind::Assign((place, rvalue)) = &stmt.kind
&& let Some(l) = place.as_local()
&& local == l
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl<'tcx> ConstMutationChecker<'_, 'tcx> {

impl<'tcx> Visitor<'tcx> for ConstMutationChecker<'_, 'tcx> {
fn visit_statement(&mut self, stmt: &Statement<'tcx>, loc: Location) {
if let StatementKind::Assign(box (lhs, _)) = &stmt.kind {
if let StatementKind::Assign((lhs, _)) = &stmt.kind {
// Check for assignment to fields of a constant
// Assigning directly to a constant (e.g. `FOO = true;`) is a hard error,
// so emitting a lint would be redundant.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_mir_transform/src/cleanup_post_borrowck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl<'tcx> crate::MirPass<'tcx> for CleanupPostBorrowck {
for statement in basic_block.statements.iter_mut() {
match statement.kind {
StatementKind::AscribeUserType(..)
| StatementKind::Assign(box (_, Rvalue::Ref(_, BorrowKind::Fake(_), _)))
| StatementKind::Assign((_, Rvalue::Ref(_, BorrowKind::Fake(_), _)))
| StatementKind::Coverage(
// These kinds of coverage statements are markers inserted during
// MIR building, and are not needed after InstrumentCoverage.
Expand All @@ -41,7 +41,7 @@ impl<'tcx> crate::MirPass<'tcx> for CleanupPostBorrowck {
| StatementKind::BackwardIncompatibleDropHint { .. } => {
statement.make_nop(true)
}
StatementKind::Assign(box (
StatementKind::Assign((
_,
Rvalue::Cast(
ref mut cast_kind @ CastKind::PointerCoercion(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/copy_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
self.super_statement(stmt, loc);

// Do not leave tautological assignments around.
if let StatementKind::Assign(box (lhs, ref rhs)) = stmt.kind
if let StatementKind::Assign((lhs, ref rhs)) = stmt.kind
&& let Rvalue::Use(Operand::Copy(rhs) | Operand::Move(rhs), _) = *rhs
&& lhs == rhs
{
Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc_mir_transform/src/coroutine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -997,12 +997,10 @@ fn compute_layout<'tcx>(
let ignore_for_traits = match decl.local_info {
// Do not include raw pointers created from accessing `static` items, as those could
// well be re-created by another access to the same static.
ClearCrossCrate::Set(box LocalInfo::StaticRef { is_thread_local, .. }) => {
!is_thread_local
}
ClearCrossCrate::Set(LocalInfo::StaticRef { is_thread_local, .. }) => !is_thread_local,
// Fake borrows are only read by fake reads, so do not have any reality in
// post-analysis MIR.
ClearCrossCrate::Set(box LocalInfo::FakeBorrow) => true,
ClearCrossCrate::Set(LocalInfo::FakeBorrow) => true,
_ => false,
};
let decl =
Expand Down Expand Up @@ -1747,7 +1745,7 @@ impl<'tcx> Visitor<'tcx> for EnsureCoroutineFieldAssignmentsNeverAlias<'_> {

fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
match &statement.kind {
StatementKind::Assign(box (lhs, rhs)) => {
StatementKind::Assign((lhs, rhs)) => {
self.check_assigned_place(*lhs, |this| this.visit_rvalue(rhs, location));
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/coroutine/by_move_body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ impl<'tcx> MutVisitor<'tcx> for MakeByMoveBody<'tcx> {
// here at all since they're fully a MIR borrowck artifact, and we
// don't need to borrowck by-move MIR bodies. But it's best to preserve
// as much as we can between these two bodies :)
if let mir::StatementKind::Assign(box (_, rvalue)) = &statement.kind
if let mir::StatementKind::Assign((_, rvalue)) = &statement.kind
&& let mir::Rvalue::Ref(_, mir::BorrowKind::Fake(mir::FakeBorrowKind::Shallow), place) =
rvalue
&& let mir::PlaceRef {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_transform/src/coverage/from_mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn filtered_statement_span(statement: &Statement<'_>) -> Option<Span> {
// and `_1` is the `Place` for `somenum`.
//
// If and when the Issue is resolved, remove this special case match pattern:
StatementKind::FakeRead(box (FakeReadCause::ForGuardBinding, _)) => None,
StatementKind::FakeRead((FakeReadCause::ForGuardBinding, _)) => None,

// Retain spans from most other statements.
StatementKind::FakeRead(_)
Expand Down
Loading
Loading