Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d2cb145
move type casting related tests into its dedicated folder
danieljofficial May 4, 2026
f10f286
std::net::tcp: let the OS pick the port numbers
RalfJung May 10, 2026
1d6a77f
use `deref_patterns` in `rustc_borrowck`
cyrgani May 7, 2026
b8ff0d5
use `deref_patterns` in `rustc_builtin_macros`
cyrgani May 7, 2026
1a3617d
use `deref_patterns` in `rustc_const_eval`
cyrgani May 7, 2026
754c496
use `deref_patterns` in `rustc_hir_typeck`
cyrgani May 7, 2026
3e557c8
use `deref_patterns` in `rustc_lint`
cyrgani May 7, 2026
74c4e77
use `deref_patterns` in `rustc_parse`
cyrgani May 7, 2026
985fe34
use `deref_patterns` in `rustc_resolve`
cyrgani May 7, 2026
52db3c4
use `deref_patterns` in `rustc_ty_utils`
cyrgani May 7, 2026
82ebc72
use `deref_patterns` in `rustc_trait_selection`
cyrgani May 7, 2026
e722c36
use `deref_patterns` in `rustc_middle`
cyrgani May 7, 2026
a060379
use `deref_patterns` in `rustc_codegen_ssa`
cyrgani May 7, 2026
32a3612
add issue links and bless
danieljofficial May 4, 2026
7a876ac
add helpful comments to tests
danieljofficial May 12, 2026
c37d020
give an example of a Ctor in the doc-comments
jyn514 May 12, 2026
dfe68e9
Rollup merge of #156287 - cyrgani:unbox-2, r=petrochenkov
JonathanBrouwer May 12, 2026
bb4b755
Rollup merge of #156385 - RalfJung:tcp-ports, r=nia-e
JonathanBrouwer May 12, 2026
e7ddc8a
Rollup merge of #156145 - danieljofficial:move-tests-cast, r=jieyouxu
JonathanBrouwer May 12, 2026
613f3fa
Rollup merge of #156502 - ferrocene:jyn/ctor-docs, r=Kivooeo
JonathanBrouwer May 12, 2026
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_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) | mir::Rvalue::Reborrow(_, _, 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 @@ -803,12 +803,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 @@ -826,7 +826,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 @@ -1602,7 +1602,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 @@ -1725,7 +1725,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 @@ -324,7 +324,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 @@ -600,7 +600,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 @@ -691,7 +691,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 @@ -712,7 +712,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 @@ -721,7 +721,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 @@ -1610,7 +1610,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