Skip to content

Commit 0a97eee

Browse files
committed
Reduce size of statements
1 parent 2fb1fb7 commit 0a97eee

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
@@ -1452,7 +1452,7 @@ pub struct Statement<'tcx> {
14521452

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

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

14871487
/// Write the discriminant for a variant to the enum Place.
14881488
SetDiscriminant { place: Box<Place<'tcx>>, variant_index: VariantIdx },
@@ -1628,7 +1628,9 @@ impl Debug for Statement<'_> {
16281628
use self::StatementKind::*;
16291629
match self.kind {
16301630
Assign(box (ref place, ref rv)) => write!(fmt, "{:?} = {:?}", place, rv),
1631-
FakeRead(ref cause, ref place) => write!(fmt, "FakeRead({:?}, {:?})", cause, place),
1631+
FakeRead(box (ref cause, ref place)) => {
1632+
write!(fmt, "FakeRead({:?}, {:?})", cause, place)
1633+
}
16321634
Retag(ref kind, ref place) => write!(
16331635
fmt,
16341636
"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
@@ -797,7 +797,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
797797

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

compiler/rustc_mir/src/borrow_check/invalidation.rs

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

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

compiler/rustc_mir/src/borrow_check/mod.rs

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

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

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

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