Skip to content

Commit e57ac76

Browse files
committed
Box thir::ExprKind::InlineAsm.
This shrinks `thir::Expr`.
1 parent b3245a8 commit e57ac76

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

compiler/rustc_middle/src/thir.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ pub struct ClosureExpr<'tcx> {
133133
pub fake_reads: Vec<(ExprId, FakeReadCause, hir::HirId)>,
134134
}
135135

136+
#[derive(Clone, Debug, HashStable)]
137+
pub struct InlineAsmExpr<'tcx> {
138+
pub template: &'tcx [InlineAsmTemplatePiece],
139+
pub operands: Box<[InlineAsmOperand<'tcx>]>,
140+
pub options: InlineAsmOptions,
141+
pub line_spans: &'tcx [Span],
142+
}
143+
136144
#[derive(Copy, Clone, Debug, HashStable)]
137145
pub enum BlockSafety {
138146
Safe,
@@ -432,12 +440,7 @@ pub enum ExprKind<'tcx> {
432440
def_id: DefId,
433441
},
434442
/// Inline assembly, i.e. `asm!()`.
435-
InlineAsm {
436-
template: &'tcx [InlineAsmTemplatePiece],
437-
operands: Box<[InlineAsmOperand<'tcx>]>,
438-
options: InlineAsmOptions,
439-
line_spans: &'tcx [Span],
440-
},
443+
InlineAsm(Box<InlineAsmExpr<'tcx>>),
441444
/// An expression taking a reference to a thread local.
442445
ThreadLocalRef(DefId),
443446
/// A `yield` expression.
@@ -804,7 +807,7 @@ mod size_asserts {
804807
use super::*;
805808
// These are in alphabetical order, which is easy to maintain.
806809
static_assert_size!(Block, 56);
807-
static_assert_size!(Expr<'_>, 80);
810+
static_assert_size!(Expr<'_>, 64);
808811
static_assert_size!(Pat<'_>, 24);
809812
static_assert_size!(Stmt<'_>, 72);
810813
}

compiler/rustc_middle/src/thir/visit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::{
2-
Arm, Block, ClosureExpr, Expr, ExprKind, Guard, InlineAsmOperand, Pat, PatKind, Stmt, StmtKind,
2+
Arm, Block, ClosureExpr, Expr, ExprKind, Guard, InlineAsmExpr, InlineAsmOperand, Pat, PatKind, Stmt, StmtKind,
33
Thir,
44
};
55

@@ -140,7 +140,7 @@ pub fn walk_expr<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, expr: &Exp
140140
NamedConst { def_id: _, substs: _, user_ty: _ } => {}
141141
ConstParam { param: _, def_id: _ } => {}
142142
StaticRef { alloc_id: _, ty: _, def_id: _ } => {}
143-
InlineAsm { ref operands, template: _, options: _, line_spans: _ } => {
143+
InlineAsm(box InlineAsmExpr { ref operands, template: _, options: _, line_spans: _ }) => {
144144
for op in &**operands {
145145
use InlineAsmOperand::*;
146146
match op {

compiler/rustc_mir_build/src/build/expr/into.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
400400
);
401401
block.unit()
402402
}
403-
ExprKind::InlineAsm { template, ref operands, options, line_spans } => {
403+
ExprKind::InlineAsm(box InlineAsmExpr { template, ref operands, options, line_spans }) => {
404404
use rustc_middle::{mir, thir};
405405
let operands = operands
406406
.into_iter()

compiler/rustc_mir_build/src/thir/cx/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ impl<'tcx> Cx<'tcx> {
562562
self.convert_path_expr(expr, res)
563563
}
564564

565-
hir::ExprKind::InlineAsm(ref asm) => ExprKind::InlineAsm {
565+
hir::ExprKind::InlineAsm(ref asm) => ExprKind::InlineAsm(Box::new(InlineAsmExpr {
566566
template: asm.template,
567567
operands: asm
568568
.operands
@@ -621,7 +621,7 @@ impl<'tcx> Cx<'tcx> {
621621
.collect(),
622622
options: asm.options,
623623
line_spans: asm.line_spans,
624-
},
624+
})),
625625

626626
hir::ExprKind::ConstBlock(ref anon_const) => {
627627
let ty = self.typeck_results().node_type(anon_const.hir_id);

0 commit comments

Comments
 (0)