Skip to content

Commit 8b03437

Browse files
committed
Auto merge of #156506 - JonathanBrouwer:rollup-sOIgP3l, r=JonathanBrouwer
Rollup of 6 pull requests Successful merges: - #156287 (move more compiler crates away from `box_patterns` ) - #156428 (Move `std::io::Cursor` to `core::io`) - #156431 (Move `std::io::util` to `core::io`) - #156145 (Move tests cast) - #156284 (resolve: Fix a false positive "cannot reexport" error for ambiguous glob sets) - #156502 (Give an example of a Ctor in the doc-comments)
2 parents 2aabf3c + 03bb9d1 commit 8b03437

78 files changed

Lines changed: 1036 additions & 917 deletions

File tree

Some content is hidden

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

compiler/rustc_borrowck/src/dataflow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
548548
location: Location,
549549
) {
550550
match &stmt.kind {
551-
mir::StatementKind::Assign(box (lhs, rhs)) => {
551+
mir::StatementKind::Assign((lhs, rhs)) => {
552552
if let mir::Rvalue::Ref(_, _, place) | mir::Rvalue::Reborrow(_, _, place) = rhs {
553553
if place.ignore_borrow(
554554
self.tcx,

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4009,12 +4009,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
40094009
Some(LocalDecl {
40104010
local_info:
40114011
ClearCrossCrate::Set(
4012-
box LocalInfo::User(BindingForm::Var(VarBindingForm {
4012+
LocalInfo::User(BindingForm::Var(VarBindingForm {
40134013
opt_match_place: None,
40144014
..
40154015
}))
4016-
| box LocalInfo::StaticRef { .. }
4017-
| box LocalInfo::Boring,
4016+
| LocalInfo::StaticRef { .. }
4017+
| LocalInfo::Boring,
40184018
),
40194019
..
40204020
})
@@ -4185,7 +4185,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
41854185
impl<'tcx> Visitor<'tcx> for FakeReadCauseFinder<'tcx> {
41864186
fn visit_statement(&mut self, statement: &Statement<'tcx>, _: Location) {
41874187
match statement {
4188-
Statement { kind: StatementKind::FakeRead(box (cause, place)), .. }
4188+
Statement { kind: StatementKind::FakeRead((cause, place)), .. }
41894189
if *place == self.place =>
41904190
{
41914191
self.cause = Some(*cause);
@@ -4243,7 +4243,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
42434243
// and it'll make sense.
42444244
let location = borrow.reserve_location;
42454245
debug!("annotate_argument_and_return_for_borrow: location={:?}", location);
4246-
if let Some(Statement { kind: StatementKind::Assign(box (reservation, _)), .. }) =
4246+
if let Some(Statement { kind: StatementKind::Assign((reservation, _)), .. }) =
42474247
&self.body[location.block].statements.get(location.statement_index)
42484248
{
42494249
debug!("annotate_argument_and_return_for_borrow: reservation={:?}", reservation);
@@ -4261,7 +4261,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
42614261
"annotate_argument_and_return_for_borrow: target={:?} stmt={:?}",
42624262
target, stmt
42634263
);
4264-
if let StatementKind::Assign(box (place, rvalue)) = &stmt.kind
4264+
if let StatementKind::Assign((place, rvalue)) = &stmt.kind
42654265
&& let Some(assigned_to) = place.as_local()
42664266
{
42674267
debug!(
@@ -4270,7 +4270,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
42704270
assigned_to, rvalue
42714271
);
42724272
// Check if our `target` was captured by a closure.
4273-
if let Rvalue::Aggregate(box AggregateKind::Closure(def_id, args), operands) =
4273+
if let Rvalue::Aggregate(AggregateKind::Closure(def_id, args), operands) =
42744274
rvalue
42754275
{
42764276
let def_id = def_id.expect_local();

compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
787787
let block = &self.body.basic_blocks[location.block];
788788

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

867867
// The only kind of statement that we care about is assignments...
868-
if let StatementKind::Assign(box (place, rvalue)) = &stmt.kind {
868+
if let StatementKind::Assign((place, rvalue)) = &stmt.kind {
869869
let Some(into) = place.local_or_deref_local() else {
870870
// Continue at the next location.
871871
queue.push(current_location.successor_within_block());

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
243243
let mut target = place.local_or_deref_local();
244244
for stmt in &self.body[location.block].statements[location.statement_index..] {
245245
debug!("add_moved_or_invoked_closure_note: stmt={:?} target={:?}", stmt, target);
246-
if let StatementKind::Assign(box (into, Rvalue::Use(from, _))) = &stmt.kind {
246+
if let StatementKind::Assign((into, Rvalue::Use(from, _))) = &stmt.kind {
247247
debug!("add_fnonce_closure_note: into={:?} from={:?}", into, from);
248248
match from {
249249
Operand::Copy(place) | Operand::Move(place)
@@ -260,7 +260,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
260260
let terminator = self.body[location.block].terminator();
261261
debug!("add_moved_or_invoked_closure_note: terminator={:?}", terminator);
262262
if let TerminatorKind::Call {
263-
func: Operand::Constant(box ConstOperand { const_, .. }),
263+
func: Operand::Constant(ConstOperand { const_, .. }),
264264
args,
265265
..
266266
} = &terminator.kind
@@ -1030,7 +1030,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
10301030
};
10311031

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

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

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

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

11591159
for stmt in statements.chain(maybe_additional_statement) {
1160-
if let StatementKind::Assign(box (_, Rvalue::Aggregate(kind, places))) = &stmt.kind {
1160+
if let StatementKind::Assign((_, Rvalue::Aggregate(kind, places))) = &stmt.kind {
11611161
let (&def_id, is_coroutine) = match kind {
1162-
box AggregateKind::Closure(def_id, _) => (def_id, false),
1163-
box AggregateKind::Coroutine(def_id, _) => (def_id, true),
1162+
AggregateKind::Closure(def_id, _) => (def_id, false),
1163+
AggregateKind::Coroutine(def_id, _) => (def_id, true),
11641164
_ => continue,
11651165
};
11661166
let def_id = def_id.expect_local();

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
122122
// to a user variable is when initializing it.
123123
// If that ever stops being the case, then the ever initialized
124124
// flow could be used.
125-
if let Some(StatementKind::Assign(box (place, Rvalue::Use(Operand::Move(move_from), _)))) =
125+
if let Some(StatementKind::Assign((place, Rvalue::Use(Operand::Move(move_from), _)))) =
126126
self.body.basic_blocks[location.block]
127127
.statements
128128
.get(location.statement_index)

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
315315
if let Some(mir::Statement {
316316
source_info,
317317
kind:
318-
mir::StatementKind::Assign(box (
318+
mir::StatementKind::Assign((
319319
_,
320320
mir::Rvalue::Ref(
321321
_,
@@ -1418,10 +1418,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
14181418
if let Some(mir::Statement {
14191419
source_info: _,
14201420
kind:
1421-
mir::StatementKind::Assign(box (
1422-
_,
1423-
mir::Rvalue::Use(mir::Operand::Copy(place), _),
1424-
)),
1421+
mir::StatementKind::Assign((_, mir::Rvalue::Use(mir::Operand::Copy(place), _))),
14251422
..
14261423
}) = first_assignment_stmt
14271424
{
@@ -1879,7 +1876,7 @@ fn suggest_ampmut<'tcx>(
18791876
// ^^ lifetime annotation not allowed
18801877
//
18811878
if let Some(rhs_stmt) = opt_assignment_rhs_stmt
1882-
&& let StatementKind::Assign(box (lhs, rvalue)) = &rhs_stmt.kind
1879+
&& let StatementKind::Assign((lhs, rvalue)) = &rhs_stmt.kind
18831880
&& let mut rhs_span = rhs_stmt.source_info.span
18841881
&& let Ok(mut rhs_str) = tcx.sess.source_map().span_to_snippet(rhs_span)
18851882
{
@@ -1900,17 +1897,16 @@ fn suggest_ampmut<'tcx>(
19001897
&& let [user_ty_proj] = user_ty_projs.contents.as_slice()
19011898
&& user_ty_proj.projs.is_empty()
19021899
&& let Either::Left(rhs_stmt_new) = body.stmt_at(*assign)
1903-
&& let StatementKind::Assign(box (_, rvalue_new)) = &rhs_stmt_new.kind
1900+
&& let StatementKind::Assign((_, rvalue_new)) = &rhs_stmt_new.kind
19041901
&& let rhs_span_new = rhs_stmt_new.source_info.span
19051902
&& let Ok(rhs_str_new) = tcx.sess.source_map().span_to_snippet(rhs_span_new)
19061903
{
19071904
(rvalue, rhs_span, rhs_str) = (rvalue_new, rhs_span_new, rhs_str_new);
19081905
}
19091906

19101907
if let Either::Right(call) = body.stmt_at(*assign)
1911-
&& let TerminatorKind::Call {
1912-
func: Operand::Constant(box const_operand), args, ..
1913-
} = &call.kind
1908+
&& let TerminatorKind::Call { func: Operand::Constant(const_operand), args, .. } =
1909+
&call.kind
19141910
&& let ty::FnDef(method_def_id, method_args) = *const_operand.ty().kind()
19151911
&& let Some(trait_) = tcx.trait_of_assoc(method_def_id)
19161912
&& tcx.is_lang_item(trait_, hir::LangItem::Index)

compiler/rustc_borrowck/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
// tidy-alphabetical-start
44
#![allow(internal_features)]
5-
#![feature(box_patterns)]
65
#![feature(default_field_values)]
6+
#![feature(deref_patterns)]
77
#![feature(file_buffered)]
88
#![feature(negative_impls)]
99
#![feature(never_type)]
@@ -803,12 +803,12 @@ impl<'a, 'tcx> ResultsVisitor<'tcx, Borrowck<'a, 'tcx>> for MirBorrowckCtxt<'a,
803803
self.check_activations(location, span, state);
804804

805805
match &stmt.kind {
806-
StatementKind::Assign(box (lhs, rhs)) => {
806+
StatementKind::Assign((lhs, rhs)) => {
807807
self.consume_rvalue(location, (rhs, span), state);
808808

809809
self.mutate_place(location, (*lhs, span), Shallow(None), state);
810810
}
811-
StatementKind::FakeRead(box (_, place)) => {
811+
StatementKind::FakeRead((_, place)) => {
812812
// Read for match doesn't access any memory and is used to
813813
// assert that a place is safe and live. So we don't have to
814814
// do any checks here.
@@ -826,7 +826,7 @@ impl<'a, 'tcx> ResultsVisitor<'tcx, Borrowck<'a, 'tcx>> for MirBorrowckCtxt<'a,
826826
state,
827827
);
828828
}
829-
StatementKind::Intrinsic(box kind) => match kind {
829+
StatementKind::Intrinsic(kind) => match kind {
830830
NonDivergingIntrinsic::Assume(op) => {
831831
self.consume_operand(location, (op, span), state);
832832
}
@@ -1602,7 +1602,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
16021602
);
16031603
}
16041604

1605-
Rvalue::BinaryOp(_bin_op, box (operand1, operand2)) => {
1605+
Rvalue::BinaryOp(_bin_op, (operand1, operand2)) => {
16061606
self.consume_operand(location, (operand1, span), state);
16071607
self.consume_operand(location, (operand2, span), state);
16081608
}
@@ -1725,7 +1725,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
17251725
debug!("temporary assigned in: stmt={:?}", stmt);
17261726

17271727
match stmt.kind {
1728-
StatementKind::Assign(box (
1728+
StatementKind::Assign((
17291729
_,
17301730
Rvalue::Ref(_, _, source)
17311731
| Rvalue::Use(Operand::Copy(source) | Operand::Move(source), _),

compiler/rustc_borrowck/src/polonius/legacy/loan_invalidations.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ impl<'a, 'tcx> Visitor<'tcx> for LoanInvalidationsGenerator<'a, 'tcx> {
4545
self.check_activations(location);
4646

4747
match &statement.kind {
48-
StatementKind::Assign(box (lhs, rhs)) => {
48+
StatementKind::Assign((lhs, rhs)) => {
4949
self.consume_rvalue(location, rhs);
5050

5151
self.mutate_place(location, *lhs, Shallow(None));
5252
}
53-
StatementKind::FakeRead(box (_, _)) => {
53+
StatementKind::FakeRead((_, _)) => {
5454
// Only relevant for initialized/liveness/safety checks.
5555
}
56-
StatementKind::Intrinsic(box NonDivergingIntrinsic::Assume(op)) => {
56+
StatementKind::Intrinsic(NonDivergingIntrinsic::Assume(op)) => {
5757
self.consume_operand(location, op);
5858
}
59-
StatementKind::Intrinsic(box NonDivergingIntrinsic::CopyNonOverlapping(CopyNonOverlapping {
59+
StatementKind::Intrinsic(NonDivergingIntrinsic::CopyNonOverlapping(CopyNonOverlapping {
6060
src,
6161
dst,
6262
count,
@@ -324,7 +324,7 @@ impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> {
324324
);
325325
}
326326

327-
Rvalue::BinaryOp(_bin_op, box (operand1, operand2)) => {
327+
Rvalue::BinaryOp(_bin_op, (operand1, operand2)) => {
328328
self.consume_operand(location, operand1);
329329
self.consume_operand(location, operand2);
330330
}

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
600600
self.super_statement(stmt, location);
601601
let tcx = self.tcx();
602602
match &stmt.kind {
603-
StatementKind::Assign(box (place, rv)) => {
603+
StatementKind::Assign((place, rv)) => {
604604
// Assignments to temporaries are not "interesting";
605605
// they are not caused by the user, but rather artifacts
606606
// of lowering. Assignments to other sorts of places *are* interesting
@@ -691,7 +691,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
691691
);
692692
}
693693
}
694-
StatementKind::AscribeUserType(box (place, projection), variance) => {
694+
StatementKind::AscribeUserType((place, projection), variance) => {
695695
let place_ty = place.ty(self.body, tcx).ty;
696696
if let Err(terr) = self.relate_type_and_user_type(
697697
place_ty,
@@ -712,7 +712,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
712712
);
713713
}
714714
}
715-
StatementKind::Intrinsic(box NonDivergingIntrinsic::Assume(..))
715+
StatementKind::Intrinsic(NonDivergingIntrinsic::Assume(..))
716716
| StatementKind::FakeRead(..)
717717
| StatementKind::StorageLive(..)
718718
| StatementKind::StorageDead(..)
@@ -721,7 +721,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
721721
| StatementKind::PlaceMention(..)
722722
| StatementKind::BackwardIncompatibleDropHint { .. }
723723
| StatementKind::Nop => {}
724-
StatementKind::Intrinsic(box NonDivergingIntrinsic::CopyNonOverlapping(..))
724+
StatementKind::Intrinsic(NonDivergingIntrinsic::CopyNonOverlapping(..))
725725
| StatementKind::SetDiscriminant { .. } => {
726726
bug!("Statement not allowed in this MIR phase")
727727
}
@@ -1610,7 +1610,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
16101610

16111611
Rvalue::BinaryOp(
16121612
BinOp::Eq | BinOp::Ne | BinOp::Lt | BinOp::Le | BinOp::Gt | BinOp::Ge,
1613-
box (left, right),
1613+
(left, right),
16141614
) => {
16151615
let ty_left = left.ty(self.body, tcx);
16161616
match ty_left.kind() {

compiler/rustc_borrowck/src/used_muts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl<'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'_, '_, '_, 'tcx> {
7878
}
7979

8080
fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
81-
if let StatementKind::Assign(box (into, _)) = &statement.kind {
81+
if let StatementKind::Assign((into, _)) = &statement.kind {
8282
debug!(
8383
"visit_statement: statement={:?} local={:?} \
8484
never_initialized_mut_locals={:?}",

0 commit comments

Comments
 (0)