mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-25 11:57:25 +00:00
Reimplement lowering of sym operands for asm! so that it also works with global_asm!
This commit is contained in:
parent
a377ebc82e
commit
0de314b3b3
3 changed files with 26 additions and 7 deletions
|
@ -169,13 +169,14 @@ fn never_loop_expr(expr: &Expr<'_>, main_loop_id: HirId) -> NeverLoopResult {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(o, _)| match o {
|
.map(|(o, _)| match o {
|
||||||
InlineAsmOperand::In { expr, .. }
|
InlineAsmOperand::In { expr, .. }
|
||||||
| InlineAsmOperand::InOut { expr, .. }
|
| InlineAsmOperand::InOut { expr, .. } => never_loop_expr(expr, main_loop_id),
|
||||||
| InlineAsmOperand::Sym { expr } => never_loop_expr(expr, main_loop_id),
|
|
||||||
InlineAsmOperand::Out { expr, .. } => never_loop_expr_all(&mut expr.iter(), main_loop_id),
|
InlineAsmOperand::Out { expr, .. } => never_loop_expr_all(&mut expr.iter(), main_loop_id),
|
||||||
InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
|
InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
|
||||||
never_loop_expr_all(&mut once(in_expr).chain(out_expr.iter()), main_loop_id)
|
never_loop_expr_all(&mut once(in_expr).chain(out_expr.iter()), main_loop_id)
|
||||||
},
|
},
|
||||||
InlineAsmOperand::Const { .. } => NeverLoopResult::Otherwise,
|
InlineAsmOperand::Const { .. }
|
||||||
|
| InlineAsmOperand::SymFn { .. }
|
||||||
|
| InlineAsmOperand::SymStatic { .. } => NeverLoopResult::Otherwise,
|
||||||
})
|
})
|
||||||
.fold(NeverLoopResult::Otherwise, combine_both),
|
.fold(NeverLoopResult::Otherwise, combine_both),
|
||||||
ExprKind::Struct(_, _, None)
|
ExprKind::Struct(_, _, None)
|
||||||
|
|
|
@ -281,8 +281,9 @@ fn print_expr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, indent: usize) {
|
||||||
for (op, _op_sp) in asm.operands {
|
for (op, _op_sp) in asm.operands {
|
||||||
match op {
|
match op {
|
||||||
hir::InlineAsmOperand::In { expr, .. }
|
hir::InlineAsmOperand::In { expr, .. }
|
||||||
| hir::InlineAsmOperand::InOut { expr, .. }
|
| hir::InlineAsmOperand::InOut { expr, .. } => {
|
||||||
| hir::InlineAsmOperand::Sym { expr } => print_expr(cx, expr, indent + 1),
|
print_expr(cx, expr, indent + 1);
|
||||||
|
}
|
||||||
hir::InlineAsmOperand::Out { expr, .. } => {
|
hir::InlineAsmOperand::Out { expr, .. } => {
|
||||||
if let Some(expr) = expr {
|
if let Some(expr) = expr {
|
||||||
print_expr(cx, expr, indent + 1);
|
print_expr(cx, expr, indent + 1);
|
||||||
|
@ -294,10 +295,26 @@ fn print_expr(cx: &LateContext<'_>, expr: &hir::Expr<'_>, indent: usize) {
|
||||||
print_expr(cx, out_expr, indent + 1);
|
print_expr(cx, out_expr, indent + 1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hir::InlineAsmOperand::Const { anon_const } => {
|
hir::InlineAsmOperand::Const { anon_const }
|
||||||
|
| hir::InlineAsmOperand::SymFn { anon_const } => {
|
||||||
println!("{}anon_const:", ind);
|
println!("{}anon_const:", ind);
|
||||||
print_expr(cx, &cx.tcx.hir().body(anon_const.body).value, indent + 1);
|
print_expr(cx, &cx.tcx.hir().body(anon_const.body).value, indent + 1);
|
||||||
},
|
},
|
||||||
|
hir::InlineAsmOperand::SymStatic { path, .. } => {
|
||||||
|
match path {
|
||||||
|
hir::QPath::Resolved(ref ty, path) => {
|
||||||
|
println!("{}Resolved Path, {:?}", ind, ty);
|
||||||
|
println!("{}path: {:?}", ind, path);
|
||||||
|
},
|
||||||
|
hir::QPath::TypeRelative(ty, seg) => {
|
||||||
|
println!("{}Relative Path, {:?}", ind, ty);
|
||||||
|
println!("{}seg: {:?}", ind, seg);
|
||||||
|
},
|
||||||
|
hir::QPath::LangItem(lang_item, ..) => {
|
||||||
|
println!("{}Lang Item Path, {:?}", ind, lang_item.name());
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -675,7 +675,8 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
InlineAsmOperand::Const { anon_const } => self.hash_body(anon_const.body),
|
InlineAsmOperand::Const { anon_const } => self.hash_body(anon_const.body),
|
||||||
InlineAsmOperand::Sym { expr } => self.hash_expr(expr),
|
InlineAsmOperand::SymFn { anon_const } => self.hash_body(anon_const.body),
|
||||||
|
InlineAsmOperand::SymStatic { path, def_id: _ } => self.hash_qpath(path),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue