Skip to content
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
location: Location,
) {
match &stmt.kind {
mir::StatementKind::Assign(box (lhs, rhs)) => {
mir::StatementKind::Assign((lhs, rhs)) => {
if let mir::Rvalue::Ref(_, _, place) = rhs {
if place.ignore_borrow(
self.tcx,
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4009,12 +4009,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
Some(LocalDecl {
local_info:
ClearCrossCrate::Set(
box LocalInfo::User(BindingForm::Var(VarBindingForm {
LocalInfo::User(BindingForm::Var(VarBindingForm {
opt_match_place: None,
..
}))
| box LocalInfo::StaticRef { .. }
| box LocalInfo::Boring,
| LocalInfo::StaticRef { .. }
| LocalInfo::Boring,
),
..
})
Expand Down Expand Up @@ -4185,7 +4185,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
impl<'tcx> Visitor<'tcx> for FakeReadCauseFinder<'tcx> {
fn visit_statement(&mut self, statement: &Statement<'tcx>, _: Location) {
match statement {
Statement { kind: StatementKind::FakeRead(box (cause, place)), .. }
Statement { kind: StatementKind::FakeRead((cause, place)), .. }
if *place == self.place =>
{
self.cause = Some(*cause);
Expand Down Expand Up @@ -4243,7 +4243,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
// and it'll make sense.
let location = borrow.reserve_location;
debug!("annotate_argument_and_return_for_borrow: location={:?}", location);
if let Some(Statement { kind: StatementKind::Assign(box (reservation, _)), .. }) =
if let Some(Statement { kind: StatementKind::Assign((reservation, _)), .. }) =
&self.body[location.block].statements.get(location.statement_index)
{
debug!("annotate_argument_and_return_for_borrow: reservation={:?}", reservation);
Expand All @@ -4261,7 +4261,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
"annotate_argument_and_return_for_borrow: target={:?} stmt={:?}",
target, stmt
);
if let StatementKind::Assign(box (place, rvalue)) = &stmt.kind
if let StatementKind::Assign((place, rvalue)) = &stmt.kind
&& let Some(assigned_to) = place.as_local()
{
debug!(
Expand All @@ -4270,7 +4270,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
assigned_to, rvalue
);
// Check if our `target` was captured by a closure.
if let Rvalue::Aggregate(box AggregateKind::Closure(def_id, args), operands) =
if let Rvalue::Aggregate(AggregateKind::Closure(def_id, args), operands) =
rvalue
{
let def_id = def_id.expect_local();
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
let block = &self.body.basic_blocks[location.block];

let kind = if let Some(&Statement {
kind: StatementKind::FakeRead(box (FakeReadCause::ForLet(_), place)),
kind: StatementKind::FakeRead((FakeReadCause::ForLet(_), place)),
..
}) = block.statements.get(location.statement_index)
{
Expand Down Expand Up @@ -849,7 +849,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
// will only ever have one item at any given time, but by using a vector, we can pop from
// it which simplifies the termination logic.
let mut queue = vec![location];
let Some(Statement { kind: StatementKind::Assign(box (place, _)), .. }) = stmt else {
let Some(Statement { kind: StatementKind::Assign((place, _)), .. }) = stmt else {
return false;
};
let Some(mut target) = place.as_local() else { return false };
Expand All @@ -865,7 +865,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
debug!("was_captured_by_trait_object: stmt={:?}", stmt);

// The only kind of statement that we care about is assignments...
if let StatementKind::Assign(box (place, rvalue)) = &stmt.kind {
if let StatementKind::Assign((place, rvalue)) = &stmt.kind {
let Some(into) = place.local_or_deref_local() else {
// Continue at the next location.
queue.push(current_location.successor_within_block());
Expand Down
18 changes: 9 additions & 9 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let mut target = place.local_or_deref_local();
for stmt in &self.body[location.block].statements[location.statement_index..] {
debug!("add_moved_or_invoked_closure_note: stmt={:?} target={:?}", stmt, target);
if let StatementKind::Assign(box (into, Rvalue::Use(from, _))) = &stmt.kind {
if let StatementKind::Assign((into, Rvalue::Use(from, _))) = &stmt.kind {
debug!("add_fnonce_closure_note: into={:?} from={:?}", into, from);
match from {
Operand::Copy(place) | Operand::Move(place)
Expand All @@ -260,7 +260,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
let terminator = self.body[location.block].terminator();
debug!("add_moved_or_invoked_closure_note: terminator={:?}", terminator);
if let TerminatorKind::Call {
func: Operand::Constant(box ConstOperand { const_, .. }),
func: Operand::Constant(ConstOperand { const_, .. }),
args,
..
} = &terminator.kind
Expand Down Expand Up @@ -1030,7 +1030,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
};

debug!("move_spans: moved_place={:?} location={:?} stmt={:?}", moved_place, location, stmt);
if let StatementKind::Assign(box (_, Rvalue::Aggregate(kind, places))) = &stmt.kind
if let StatementKind::Assign((_, Rvalue::Aggregate(kind, places))) = &stmt.kind
&& let AggregateKind::Closure(def_id, _) | AggregateKind::Coroutine(def_id, _) = **kind
{
debug!("move_spans: def_id={:?} places={:?}", def_id, places);
Expand All @@ -1044,7 +1044,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {

// StatementKind::FakeRead only contains a def_id if they are introduced as a result
// of pattern matching within a closure.
if let StatementKind::FakeRead(box (cause, place)) = stmt.kind {
if let StatementKind::FakeRead((cause, place)) = stmt.kind {
match cause {
FakeReadCause::ForMatchedPlace(Some(closure_def_id))
| FakeReadCause::ForLet(Some(closure_def_id)) => {
Expand Down Expand Up @@ -1084,7 +1084,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
// that has a `self` parameter.

let target_temp = match stmt.kind {
StatementKind::Assign(box (temp, _)) if temp.as_local().is_some() => {
StatementKind::Assign((temp, _)) if temp.as_local().is_some() => {
temp.as_local().unwrap()
}
_ => return normal_ret,
Expand Down Expand Up @@ -1131,7 +1131,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
use self::UseSpans::*;
debug!("borrow_spans: use_span={:?} location={:?}", use_span, location);

let Some(Statement { kind: StatementKind::Assign(box (place, _)), .. }) =
let Some(Statement { kind: StatementKind::Assign((place, _)), .. }) =
self.body[location.block].statements.get(location.statement_index)
else {
return OtherUse(use_span);
Expand All @@ -1157,10 +1157,10 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
self.body[location.block].statements[location.statement_index + 1..].iter();

for stmt in statements.chain(maybe_additional_statement) {
if let StatementKind::Assign(box (_, Rvalue::Aggregate(kind, places))) = &stmt.kind {
if let StatementKind::Assign((_, Rvalue::Aggregate(kind, places))) = &stmt.kind {
let (&def_id, is_coroutine) = match kind {
box AggregateKind::Closure(def_id, _) => (def_id, false),
box AggregateKind::Coroutine(def_id, _) => (def_id, true),
AggregateKind::Closure(def_id, _) => (def_id, false),
AggregateKind::Coroutine(def_id, _) => (def_id, true),
_ => continue,
};
let def_id = def_id.expect_local();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/move_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
// to a user variable is when initializing it.
// If that ever stops being the case, then the ever initialized
// flow could be used.
if let Some(StatementKind::Assign(box (place, Rvalue::Use(Operand::Move(move_from), _)))) =
if let Some(StatementKind::Assign((place, Rvalue::Use(Operand::Move(move_from), _)))) =
self.body.basic_blocks[location.block]
.statements
.get(location.statement_index)
Expand Down
16 changes: 6 additions & 10 deletions compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
if let Some(mir::Statement {
source_info,
kind:
mir::StatementKind::Assign(box (
mir::StatementKind::Assign((
_,
mir::Rvalue::Ref(
_,
Expand Down Expand Up @@ -1418,10 +1418,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
if let Some(mir::Statement {
source_info: _,
kind:
mir::StatementKind::Assign(box (
_,
mir::Rvalue::Use(mir::Operand::Copy(place), _),
)),
mir::StatementKind::Assign((_, mir::Rvalue::Use(mir::Operand::Copy(place), _))),
..
}) = first_assignment_stmt
{
Expand Down Expand Up @@ -1879,7 +1876,7 @@ fn suggest_ampmut<'tcx>(
// ^^ lifetime annotation not allowed
//
if let Some(rhs_stmt) = opt_assignment_rhs_stmt
&& let StatementKind::Assign(box (lhs, rvalue)) = &rhs_stmt.kind
&& let StatementKind::Assign((lhs, rvalue)) = &rhs_stmt.kind
&& let mut rhs_span = rhs_stmt.source_info.span
&& let Ok(mut rhs_str) = tcx.sess.source_map().span_to_snippet(rhs_span)
{
Expand All @@ -1900,17 +1897,16 @@ fn suggest_ampmut<'tcx>(
&& let [user_ty_proj] = user_ty_projs.contents.as_slice()
&& user_ty_proj.projs.is_empty()
&& let Either::Left(rhs_stmt_new) = body.stmt_at(*assign)
&& let StatementKind::Assign(box (_, rvalue_new)) = &rhs_stmt_new.kind
&& let StatementKind::Assign((_, rvalue_new)) = &rhs_stmt_new.kind
&& let rhs_span_new = rhs_stmt_new.source_info.span
&& let Ok(rhs_str_new) = tcx.sess.source_map().span_to_snippet(rhs_span_new)
{
(rvalue, rhs_span, rhs_str) = (rvalue_new, rhs_span_new, rhs_str_new);
}

if let Either::Right(call) = body.stmt_at(*assign)
&& let TerminatorKind::Call {
func: Operand::Constant(box const_operand), args, ..
} = &call.kind
&& let TerminatorKind::Call { func: Operand::Constant(const_operand), args, .. } =
&call.kind
&& let ty::FnDef(method_def_id, method_args) = *const_operand.ty().kind()
&& let Some(trait_) = tcx.trait_of_assoc(method_def_id)
&& tcx.is_lang_item(trait_, hir::LangItem::Index)
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

// tidy-alphabetical-start
#![allow(internal_features)]
#![feature(box_patterns)]
#![feature(default_field_values)]
#![feature(deref_patterns)]
#![feature(file_buffered)]
#![feature(negative_impls)]
#![feature(never_type)]
Expand Down Expand Up @@ -798,12 +798,12 @@ impl<'a, 'tcx> ResultsVisitor<'tcx, Borrowck<'a, 'tcx>> for MirBorrowckCtxt<'a,
self.check_activations(location, span, state);

match &stmt.kind {
StatementKind::Assign(box (lhs, rhs)) => {
StatementKind::Assign((lhs, rhs)) => {
self.consume_rvalue(location, (rhs, span), state);

self.mutate_place(location, (*lhs, span), Shallow(None), state);
}
StatementKind::FakeRead(box (_, place)) => {
StatementKind::FakeRead((_, place)) => {
// Read for match doesn't access any memory and is used to
// assert that a place is safe and live. So we don't have to
// do any checks here.
Expand All @@ -821,7 +821,7 @@ impl<'a, 'tcx> ResultsVisitor<'tcx, Borrowck<'a, 'tcx>> for MirBorrowckCtxt<'a,
state,
);
}
StatementKind::Intrinsic(box kind) => match kind {
StatementKind::Intrinsic(kind) => match kind {
NonDivergingIntrinsic::Assume(op) => {
self.consume_operand(location, (op, span), state);
}
Expand Down Expand Up @@ -1566,7 +1566,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
);
}

Rvalue::BinaryOp(_bin_op, box (operand1, operand2)) => {
Rvalue::BinaryOp(_bin_op, (operand1, operand2)) => {
self.consume_operand(location, (operand1, span), state);
self.consume_operand(location, (operand2, span), state);
}
Expand Down Expand Up @@ -1689,7 +1689,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
debug!("temporary assigned in: stmt={:?}", stmt);

match stmt.kind {
StatementKind::Assign(box (
StatementKind::Assign((
_,
Rvalue::Ref(_, _, source)
| Rvalue::Use(Operand::Copy(source) | Operand::Move(source), _),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ impl<'a, 'tcx> Visitor<'tcx> for LoanInvalidationsGenerator<'a, 'tcx> {
self.check_activations(location);

match &statement.kind {
StatementKind::Assign(box (lhs, rhs)) => {
StatementKind::Assign((lhs, rhs)) => {
self.consume_rvalue(location, rhs);

self.mutate_place(location, *lhs, Shallow(None));
}
StatementKind::FakeRead(box (_, _)) => {
StatementKind::FakeRead((_, _)) => {
// Only relevant for initialized/liveness/safety checks.
}
StatementKind::Intrinsic(box NonDivergingIntrinsic::Assume(op)) => {
StatementKind::Intrinsic(NonDivergingIntrinsic::Assume(op)) => {
self.consume_operand(location, op);
}
StatementKind::Intrinsic(box NonDivergingIntrinsic::CopyNonOverlapping(CopyNonOverlapping {
StatementKind::Intrinsic(NonDivergingIntrinsic::CopyNonOverlapping(CopyNonOverlapping {
src,
dst,
count,
Expand Down Expand Up @@ -309,7 +309,7 @@ impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> {
);
}

Rvalue::BinaryOp(_bin_op, box (operand1, operand2)) => {
Rvalue::BinaryOp(_bin_op, (operand1, operand2)) => {
self.consume_operand(location, operand1);
self.consume_operand(location, operand2);
}
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
self.super_statement(stmt, location);
let tcx = self.tcx();
match &stmt.kind {
StatementKind::Assign(box (place, rv)) => {
StatementKind::Assign((place, rv)) => {
// Assignments to temporaries are not "interesting";
// they are not caused by the user, but rather artifacts
// of lowering. Assignments to other sorts of places *are* interesting
Expand Down Expand Up @@ -672,7 +672,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
);
}
}
StatementKind::AscribeUserType(box (place, projection), variance) => {
StatementKind::AscribeUserType((place, projection), variance) => {
let place_ty = place.ty(self.body, tcx).ty;
if let Err(terr) = self.relate_type_and_user_type(
place_ty,
Expand All @@ -693,7 +693,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
);
}
}
StatementKind::Intrinsic(box NonDivergingIntrinsic::Assume(..))
StatementKind::Intrinsic(NonDivergingIntrinsic::Assume(..))
| StatementKind::FakeRead(..)
| StatementKind::StorageLive(..)
| StatementKind::StorageDead(..)
Expand All @@ -702,7 +702,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
| StatementKind::PlaceMention(..)
| StatementKind::BackwardIncompatibleDropHint { .. }
| StatementKind::Nop => {}
StatementKind::Intrinsic(box NonDivergingIntrinsic::CopyNonOverlapping(..))
StatementKind::Intrinsic(NonDivergingIntrinsic::CopyNonOverlapping(..))
| StatementKind::SetDiscriminant { .. } => {
bug!("Statement not allowed in this MIR phase")
}
Expand Down Expand Up @@ -1582,7 +1582,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {

Rvalue::BinaryOp(
BinOp::Eq | BinOp::Ne | BinOp::Lt | BinOp::Le | BinOp::Gt | BinOp::Ge,
box (left, right),
(left, right),
) => {
let ty_left = left.ty(self.body, tcx);
match ty_left.kind() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/used_muts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'_, '_, '_, 'tcx> {
}

fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
if let StatementKind::Assign(box (into, _)) = &statement.kind {
if let StatementKind::Assign((into, _)) = &statement.kind {
debug!(
"visit_statement: statement={:?} local={:?} \
never_initialized_mut_locals={:?}",
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_builtin_macros/src/autodiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ mod llvm_enzyme {
// Get information about the function the macro is applied to
fn extract_item_info(iitem: &Box<ast::Item>) -> Option<(Visibility, FnSig, Ident, Generics)> {
match &iitem.kind {
ItemKind::Fn(box ast::Fn { sig, ident, generics, .. }) => {
ItemKind::Fn(ast::Fn { sig, ident, generics, .. }) => {
Some((iitem.vis.clone(), sig.clone(), ident.clone(), generics.clone()))
}
_ => None,
Expand Down Expand Up @@ -226,7 +226,7 @@ mod llvm_enzyme {
},
Annotatable::AssocItem(assoc_item, _ctxt @ (Impl { of_trait: _ } | Trait)) => {
match &assoc_item.kind {
ast::AssocItemKind::Fn(box ast::Fn { sig, ident, generics, .. }) => Some((
ast::AssocItemKind::Fn(ast::Fn { sig, ident, generics, .. }) => Some((
assoc_item.vis.clone(),
sig.clone(),
ident.clone(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ impl<'a> MethodDef<'a> {

match ty {
// Selflike (`&Self`) arguments only occur in non-static methods.
Ref(box Self_, _) if !self.is_static() => selflike_args.push(arg_expr),
Ref(Self_, _) if !self.is_static() => selflike_args.push(arg_expr),
Self_ => cx.dcx().span_bug(span, "`Self` in non-return position"),
_ => nonselflike_args.push(arg_expr),
}
Expand Down
Loading
Loading