Skip to content

Commit b60bcba

Browse files
committed
Make ast::ExprKind smaller.
1 parent 6e9bf12 commit b60bcba

File tree

4 files changed

+43
-63
lines changed

4 files changed

+43
-63
lines changed

src/librustc/hir/lowering.rs

+24-30
Original file line numberDiff line numberDiff line change
@@ -1208,36 +1208,30 @@ impl<'a> LoweringContext<'a> {
12081208
ExprKind::Break(opt_ident) => hir::ExprBreak(self.lower_opt_sp_ident(opt_ident)),
12091209
ExprKind::Continue(opt_ident) => hir::ExprAgain(self.lower_opt_sp_ident(opt_ident)),
12101210
ExprKind::Ret(ref e) => hir::ExprRet(e.as_ref().map(|x| self.lower_expr(x))),
1211-
ExprKind::InlineAsm(InlineAsm {
1212-
ref inputs,
1213-
ref outputs,
1214-
ref asm,
1215-
asm_str_style,
1216-
ref clobbers,
1217-
volatile,
1218-
alignstack,
1219-
dialect,
1220-
expn_id,
1221-
}) => hir::ExprInlineAsm(P(hir::InlineAsm {
1222-
inputs: inputs.iter().map(|&(ref c, _)| c.clone()).collect(),
1223-
outputs: outputs.iter()
1224-
.map(|out| {
1225-
hir::InlineAsmOutput {
1226-
constraint: out.constraint.clone(),
1227-
is_rw: out.is_rw,
1228-
is_indirect: out.is_indirect,
1229-
}
1230-
})
1231-
.collect(),
1232-
asm: asm.clone(),
1233-
asm_str_style: asm_str_style,
1234-
clobbers: clobbers.clone().into(),
1235-
volatile: volatile,
1236-
alignstack: alignstack,
1237-
dialect: dialect,
1238-
expn_id: expn_id,
1239-
}), outputs.iter().map(|out| self.lower_expr(&out.expr)).collect(),
1240-
inputs.iter().map(|&(_, ref input)| self.lower_expr(input)).collect()),
1211+
ExprKind::InlineAsm(ref asm) => {
1212+
let hir_asm = hir::InlineAsm {
1213+
inputs: asm.inputs.iter().map(|&(ref c, _)| c.clone()).collect(),
1214+
outputs: asm.outputs.iter().map(|out| {
1215+
hir::InlineAsmOutput {
1216+
constraint: out.constraint.clone(),
1217+
is_rw: out.is_rw,
1218+
is_indirect: out.is_indirect,
1219+
}
1220+
}).collect(),
1221+
asm: asm.asm.clone(),
1222+
asm_str_style: asm.asm_str_style,
1223+
clobbers: asm.clobbers.clone().into(),
1224+
volatile: asm.volatile,
1225+
alignstack: asm.alignstack,
1226+
dialect: asm.dialect,
1227+
expn_id: asm.expn_id,
1228+
};
1229+
let outputs =
1230+
asm.outputs.iter().map(|out| self.lower_expr(&out.expr)).collect();
1231+
let inputs =
1232+
asm.inputs.iter().map(|&(_, ref input)| self.lower_expr(input)).collect();
1233+
hir::ExprInlineAsm(P(hir_asm), outputs, inputs)
1234+
}
12411235
ExprKind::Struct(ref path, ref fields, ref maybe_expr) => {
12421236
hir::ExprStruct(self.lower_path(path),
12431237
fields.iter().map(|x| self.lower_field(x)).collect(),

src/libsyntax/ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ pub enum ExprKind {
10501050
Ret(Option<P<Expr>>),
10511051

10521052
/// Output of the `asm!()` macro
1053-
InlineAsm(InlineAsm),
1053+
InlineAsm(P<InlineAsm>),
10541054

10551055
/// A macro invocation; pre-expansion
10561056
Mac(Mac),

src/libsyntax/fold.rs

+16-30
Original file line numberDiff line numberDiff line change
@@ -1249,36 +1249,22 @@ pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mu
12491249
folder.fold_ident(label.node)))
12501250
),
12511251
ExprKind::Ret(e) => ExprKind::Ret(e.map(|x| folder.fold_expr(x))),
1252-
ExprKind::InlineAsm(InlineAsm {
1253-
inputs,
1254-
outputs,
1255-
asm,
1256-
asm_str_style,
1257-
clobbers,
1258-
volatile,
1259-
alignstack,
1260-
dialect,
1261-
expn_id,
1262-
}) => ExprKind::InlineAsm(InlineAsm {
1263-
inputs: inputs.move_map(|(c, input)| {
1264-
(c, folder.fold_expr(input))
1265-
}),
1266-
outputs: outputs.move_map(|out| {
1267-
InlineAsmOutput {
1268-
constraint: out.constraint,
1269-
expr: folder.fold_expr(out.expr),
1270-
is_rw: out.is_rw,
1271-
is_indirect: out.is_indirect,
1272-
}
1273-
}),
1274-
asm: asm,
1275-
asm_str_style: asm_str_style,
1276-
clobbers: clobbers,
1277-
volatile: volatile,
1278-
alignstack: alignstack,
1279-
dialect: dialect,
1280-
expn_id: expn_id,
1281-
}),
1252+
ExprKind::InlineAsm(asm) => ExprKind::InlineAsm(asm.map(|asm| {
1253+
InlineAsm {
1254+
inputs: asm.inputs.move_map(|(c, input)| {
1255+
(c, folder.fold_expr(input))
1256+
}),
1257+
outputs: asm.outputs.move_map(|out| {
1258+
InlineAsmOutput {
1259+
constraint: out.constraint,
1260+
expr: folder.fold_expr(out.expr),
1261+
is_rw: out.is_rw,
1262+
is_indirect: out.is_indirect,
1263+
}
1264+
}),
1265+
..asm
1266+
}
1267+
})),
12821268
ExprKind::Mac(mac) => ExprKind::Mac(folder.fold_mac(mac)),
12831269
ExprKind::Struct(path, fields, maybe_expr) => {
12841270
ExprKind::Struct(folder.fold_path(path),

src/libsyntax_ext/asm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
250250

251251
MacEager::expr(P(ast::Expr {
252252
id: ast::DUMMY_NODE_ID,
253-
node: ast::ExprKind::InlineAsm(ast::InlineAsm {
253+
node: ast::ExprKind::InlineAsm(P(ast::InlineAsm {
254254
asm: token::intern_and_get_ident(&asm),
255255
asm_str_style: asm_str_style.unwrap(),
256256
outputs: outputs,
@@ -260,7 +260,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
260260
alignstack: alignstack,
261261
dialect: dialect,
262262
expn_id: expn_id,
263-
}),
263+
})),
264264
span: sp,
265265
attrs: ast::ThinVec::new(),
266266
}))

0 commit comments

Comments
 (0)