Skip to content

Commit 1ef70d8

Browse files
committed
Reduce size of statements
1 parent c3cf93a commit 1ef70d8

File tree

10 files changed

+16
-14
lines changed

10 files changed

+16
-14
lines changed

compiler/rustc_middle/src/mir/mod.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,7 @@ pub struct Statement<'tcx> {
14701470

14711471
// `Statement` is used a lot. Make sure it doesn't unintentionally get bigger.
14721472
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
1473-
static_assert_size!(Statement<'_>, 40);
1473+
static_assert_size!(Statement<'_>, 32);
14741474

14751475
impl Statement<'_> {
14761476
/// Changes a statement to a nop. This is both faster than deleting instructions and avoids
@@ -1500,7 +1500,7 @@ pub enum StatementKind<'tcx> {
15001500
///
15011501
/// Note that this also is emitted for regular `let` bindings to ensure that locals that are
15021502
/// never accessed still get some sanity checks for, e.g., `let x: ! = ..;`
1503-
FakeRead(FakeReadCause, Box<Place<'tcx>>),
1503+
FakeRead(Box<(FakeReadCause, Place<'tcx>)>),
15041504

15051505
/// Write the discriminant for a variant to the enum Place.
15061506
SetDiscriminant { place: Box<Place<'tcx>>, variant_index: VariantIdx },
@@ -1646,7 +1646,9 @@ impl Debug for Statement<'_> {
16461646
use self::StatementKind::*;
16471647
match self.kind {
16481648
Assign(box (ref place, ref rv)) => write!(fmt, "{:?} = {:?}", place, rv),
1649-
FakeRead(ref cause, ref place) => write!(fmt, "FakeRead({:?}, {:?})", cause, place),
1649+
FakeRead(box (ref cause, ref place)) => {
1650+
write!(fmt, "FakeRead({:?}, {:?})", cause, place)
1651+
}
16501652
Retag(ref kind, ref place) => write!(
16511653
fmt,
16521654
"Retag({}{:?})",

compiler/rustc_middle/src/mir/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ macro_rules! make_mir_visitor {
380380
) => {
381381
self.visit_assign(place, rvalue, location);
382382
}
383-
StatementKind::FakeRead(_, place) => {
383+
StatementKind::FakeRead(box (_, place)) => {
384384
self.visit_place(
385385
place,
386386
PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect),

compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1728,7 +1728,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
17281728
impl<'tcx> Visitor<'tcx> for FakeReadCauseFinder<'tcx> {
17291729
fn visit_statement(&mut self, statement: &Statement<'tcx>, _: Location) {
17301730
match statement {
1731-
Statement { kind: StatementKind::FakeRead(cause, box place), .. }
1731+
Statement { kind: StatementKind::FakeRead(box (cause, place)), .. }
17321732
if *place == self.place =>
17331733
{
17341734
self.cause = Some(*cause);

compiler/rustc_mir/src/borrow_check/diagnostics/explain_borrow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
515515
let block = &self.body.basic_blocks()[location.block];
516516

517517
let kind = if let Some(&Statement {
518-
kind: StatementKind::FakeRead(FakeReadCause::ForLet(_), _),
518+
kind: StatementKind::FakeRead(box (FakeReadCause::ForLet(_), _)),
519519
..
520520
}) = block.statements.get(location.statement_index)
521521
{

compiler/rustc_mir/src/borrow_check/diagnostics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
796796

797797
// StatementKind::FakeRead only contains a def_id if they are introduced as a result
798798
// of pattern matching within a closure.
799-
if let StatementKind::FakeRead(cause, box ref place) = stmt.kind {
799+
if let StatementKind::FakeRead(box (cause, ref place)) = stmt.kind {
800800
match cause {
801801
FakeReadCause::ForMatchedPlace(Some(closure_def_id))
802802
| FakeReadCause::ForLet(Some(closure_def_id)) => {

compiler/rustc_mir/src/borrow_check/invalidation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
6262

6363
self.mutate_place(location, *lhs, Shallow(None), JustWrite);
6464
}
65-
StatementKind::FakeRead(_, _) => {
65+
StatementKind::FakeRead(box (_, _)) => {
6666
// Only relevant for initialized/liveness/safety checks.
6767
}
6868
StatementKind::SetDiscriminant { place, variant_index: _ } => {

compiler/rustc_mir/src/borrow_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ impl<'cx, 'tcx> dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tc
573573

574574
self.mutate_place(location, (*lhs, span), Shallow(None), JustWrite, flow_state);
575575
}
576-
StatementKind::FakeRead(_, box ref place) => {
576+
StatementKind::FakeRead(box (_, ref place)) => {
577577
// Read for match doesn't access any memory and is used to
578578
// assert that a place is safe and live. So we don't have to
579579
// do any checks here.

compiler/rustc_mir/src/dataflow/move_paths/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
292292
}
293293
self.gather_rvalue(rval);
294294
}
295-
StatementKind::FakeRead(_, place) => {
296-
self.create_move_path(**place);
295+
StatementKind::FakeRead(box (_, place)) => {
296+
self.create_move_path(*place);
297297
}
298298
StatementKind::LlvmInlineAsm(ref asm) => {
299299
for (output, kind) in asm.outputs.iter().zip(&asm.asm.outputs) {

compiler/rustc_mir/src/transform/coverage/spans.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -683,10 +683,10 @@ pub(super) fn filtered_statement_span(
683683
// and `_1` is the `Place` for `somenum`.
684684
//
685685
// If and when the Issue is resolved, remove this special case match pattern:
686-
StatementKind::FakeRead(cause, _) if cause == FakeReadCause::ForGuardBinding => None,
686+
StatementKind::FakeRead(box (cause, _)) if cause == FakeReadCause::ForGuardBinding => None,
687687

688688
// Retain spans from all other statements
689-
StatementKind::FakeRead(_, _) // Not including `ForGuardBinding`
689+
StatementKind::FakeRead(box (_, _)) // Not including `ForGuardBinding`
690690
| StatementKind::CopyNonOverlapping(..)
691691
| StatementKind::Assign(_)
692692
| StatementKind::SetDiscriminant { .. }

compiler/rustc_mir_build/src/build/cfg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl<'tcx> CFG<'tcx> {
8080
cause: FakeReadCause,
8181
place: Place<'tcx>,
8282
) {
83-
let kind = StatementKind::FakeRead(cause, box place);
83+
let kind = StatementKind::FakeRead(box (cause, place));
8484
let stmt = Statement { source_info, kind };
8585
self.push(block, stmt);
8686
}

0 commit comments

Comments
 (0)