Skip to content

Commit 1194992

Browse files
committed
lowering: extract lower_expr_asm
1 parent 45d507d commit 1194992

File tree

1 file changed

+35
-30
lines changed

1 file changed

+35
-30
lines changed

src/librustc/hir/lowering/expr.rs

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -451,36 +451,7 @@ impl LoweringContext<'_> {
451451
})
452452
}
453453
ExprKind::Ret(ref e) => hir::ExprKind::Ret(e.as_ref().map(|x| P(self.lower_expr(x)))),
454-
ExprKind::InlineAsm(ref asm) => {
455-
let hir_asm = hir::InlineAsm {
456-
inputs: asm.inputs.iter().map(|&(ref c, _)| c.clone()).collect(),
457-
outputs: asm.outputs
458-
.iter()
459-
.map(|out| hir::InlineAsmOutput {
460-
constraint: out.constraint.clone(),
461-
is_rw: out.is_rw,
462-
is_indirect: out.is_indirect,
463-
span: out.expr.span,
464-
})
465-
.collect(),
466-
asm: asm.asm.clone(),
467-
asm_str_style: asm.asm_str_style,
468-
clobbers: asm.clobbers.clone().into(),
469-
volatile: asm.volatile,
470-
alignstack: asm.alignstack,
471-
dialect: asm.dialect,
472-
ctxt: asm.ctxt,
473-
};
474-
let outputs = asm.outputs
475-
.iter()
476-
.map(|out| self.lower_expr(&out.expr))
477-
.collect();
478-
let inputs = asm.inputs
479-
.iter()
480-
.map(|&(_, ref input)| self.lower_expr(input))
481-
.collect();
482-
hir::ExprKind::InlineAsm(P(hir_asm), outputs, inputs)
483-
}
454+
ExprKind::InlineAsm(ref asm) => self.lower_expr_asm(asm),
484455
ExprKind::Struct(ref path, ref fields, ref maybe_expr) => hir::ExprKind::Struct(
485456
P(self.lower_qpath(
486457
e.id,
@@ -526,6 +497,40 @@ impl LoweringContext<'_> {
526497
}
527498
}
528499

500+
fn lower_expr_asm(&mut self, asm: &InlineAsm) -> hir::ExprKind {
501+
let hir_asm = hir::InlineAsm {
502+
inputs: asm.inputs.iter().map(|&(ref c, _)| c.clone()).collect(),
503+
outputs: asm.outputs
504+
.iter()
505+
.map(|out| hir::InlineAsmOutput {
506+
constraint: out.constraint.clone(),
507+
is_rw: out.is_rw,
508+
is_indirect: out.is_indirect,
509+
span: out.expr.span,
510+
})
511+
.collect(),
512+
asm: asm.asm.clone(),
513+
asm_str_style: asm.asm_str_style,
514+
clobbers: asm.clobbers.clone().into(),
515+
volatile: asm.volatile,
516+
alignstack: asm.alignstack,
517+
dialect: asm.dialect,
518+
ctxt: asm.ctxt,
519+
};
520+
521+
let outputs = asm.outputs
522+
.iter()
523+
.map(|out| self.lower_expr(&out.expr))
524+
.collect();
525+
526+
let inputs = asm.inputs
527+
.iter()
528+
.map(|&(_, ref input)| self.lower_expr(input))
529+
.collect();
530+
531+
hir::ExprKind::InlineAsm(P(hir_asm), outputs, inputs)
532+
}
533+
529534
fn lower_expr_yield(&mut self, span: Span, opt_expr: Option<&Expr>) -> hir::ExprKind {
530535
match self.generator_kind {
531536
Some(hir::GeneratorKind::Gen) => {},

0 commit comments

Comments
 (0)