Skip to content

Commit a4943be

Browse files
committed
Unify walk_inline_asm
1 parent 5b2351a commit a4943be

File tree

1 file changed

+41
-63
lines changed

1 file changed

+41
-63
lines changed

compiler/rustc_ast/src/visitors.rs

Lines changed: 41 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,47 @@ macro_rules! make_ast_visitor {
532532
return_result!(V)
533533
}
534534

535+
pub fn walk_inline_asm<$($lt,)? V: $trait$(<$lt>)?>(
536+
vis: &mut V,
537+
asm: ref_t!(InlineAsm)
538+
) -> result!(V) {
539+
// FIXME: Visit spans inside all this currently ignored stuff.
540+
let InlineAsm {
541+
asm_macro: _,
542+
template: _,
543+
template_strs: _,
544+
operands,
545+
clobber_abis: _,
546+
options: _,
547+
line_spans: _,
548+
} = asm;
549+
for (op, span) in operands {
550+
match op {
551+
InlineAsmOperand::In { expr, reg: _ }
552+
| InlineAsmOperand::Out { expr: Some(expr), reg: _, late: _ }
553+
| InlineAsmOperand::InOut { expr, reg: _, late: _ } => {
554+
try_v!(vis.visit_expr(expr));
555+
}
556+
InlineAsmOperand::Out { expr: None, reg: _, late: _ } => {}
557+
InlineAsmOperand::SplitInOut { in_expr, out_expr, reg: _, late: _ } => {
558+
try_v!(vis.visit_expr(in_expr));
559+
visit_o!(out_expr, |out_expr| vis.visit_expr(out_expr));
560+
}
561+
InlineAsmOperand::Const { anon_const } => {
562+
try_v!(vis.visit_anon_const(anon_const));
563+
}
564+
InlineAsmOperand::Sym { sym } => {
565+
try_v!(vis.visit_inline_asm_sym(sym));
566+
}
567+
InlineAsmOperand::Label { block } => {
568+
try_v!(vis.visit_block(block));
569+
}
570+
}
571+
try_v!(visit_span!(vis, span));
572+
}
573+
return_result!(V)
574+
}
575+
535576
pub fn walk_label<$($lt,)? V: $trait$(<$lt>)?>(
536577
vis: &mut V,
537578
label: ref_t!(Label)
@@ -1333,38 +1374,6 @@ pub mod visit {
13331374
visitor.visit_path(path, DUMMY_NODE_ID)
13341375
}
13351376

1336-
pub fn walk_inline_asm<'a, V: Visitor<'a>>(visitor: &mut V, asm: &'a InlineAsm) -> V::Result {
1337-
let InlineAsm {
1338-
asm_macro: _,
1339-
template: _,
1340-
template_strs: _,
1341-
operands,
1342-
clobber_abis: _,
1343-
options: _,
1344-
line_spans: _,
1345-
} = asm;
1346-
for (op, _span) in operands {
1347-
match op {
1348-
InlineAsmOperand::In { expr, reg: _ }
1349-
| InlineAsmOperand::Out { expr: Some(expr), reg: _, late: _ }
1350-
| InlineAsmOperand::InOut { expr, reg: _, late: _ } => {
1351-
try_visit!(visitor.visit_expr(expr))
1352-
}
1353-
InlineAsmOperand::Out { expr: None, reg: _, late: _ } => {}
1354-
InlineAsmOperand::SplitInOut { in_expr, out_expr, reg: _, late: _ } => {
1355-
try_visit!(visitor.visit_expr(in_expr));
1356-
visit_opt!(visitor, visit_expr, out_expr);
1357-
}
1358-
InlineAsmOperand::Const { anon_const } => {
1359-
try_visit!(visitor.visit_anon_const(anon_const))
1360-
}
1361-
InlineAsmOperand::Sym { sym } => try_visit!(visitor.visit_inline_asm_sym(sym)),
1362-
InlineAsmOperand::Label { block } => try_visit!(visitor.visit_block(block)),
1363-
}
1364-
}
1365-
V::Result::output()
1366-
}
1367-
13681377
pub fn walk_inline_asm_sym<'a, V: Visitor<'a>>(
13691378
visitor: &mut V,
13701379
InlineAsmSym { id, qself, path }: &'a InlineAsmSym,
@@ -2516,37 +2525,6 @@ pub mod mut_visit {
25162525
vis.visit_span(span);
25172526
}
25182527

2519-
fn walk_inline_asm<T: MutVisitor>(vis: &mut T, asm: &mut InlineAsm) {
2520-
// FIXME: Visit spans inside all this currently ignored stuff.
2521-
let InlineAsm {
2522-
asm_macro: _,
2523-
template: _,
2524-
template_strs: _,
2525-
operands,
2526-
clobber_abis: _,
2527-
options: _,
2528-
line_spans: _,
2529-
} = asm;
2530-
for (op, span) in operands {
2531-
match op {
2532-
InlineAsmOperand::In { expr, reg: _ }
2533-
| InlineAsmOperand::Out { expr: Some(expr), reg: _, late: _ }
2534-
| InlineAsmOperand::InOut { expr, reg: _, late: _ } => vis.visit_expr(expr),
2535-
InlineAsmOperand::Out { expr: None, reg: _, late: _ } => {}
2536-
InlineAsmOperand::SplitInOut { in_expr, out_expr, reg: _, late: _ } => {
2537-
vis.visit_expr(in_expr);
2538-
if let Some(out_expr) = out_expr {
2539-
vis.visit_expr(out_expr);
2540-
}
2541-
}
2542-
InlineAsmOperand::Const { anon_const } => vis.visit_anon_const(anon_const),
2543-
InlineAsmOperand::Sym { sym } => vis.visit_inline_asm_sym(sym),
2544-
InlineAsmOperand::Label { block } => vis.visit_block(block),
2545-
}
2546-
vis.visit_span(span);
2547-
}
2548-
}
2549-
25502528
fn walk_inline_asm_sym<T: MutVisitor>(
25512529
vis: &mut T,
25522530
InlineAsmSym { id, qself, path }: &mut InlineAsmSym,

0 commit comments

Comments
 (0)