|
1 | 1 | use std::fmt;
|
2 | 2 |
|
3 |
| -use clippy_utils::diagnostics::span_lint_and_help; |
| 3 | +use clippy_utils::diagnostics::span_lint_and_then; |
4 | 4 | use rustc_ast::ast::{Expr, ExprKind, InlineAsmOptions};
|
5 | 5 | use rustc_ast::{InlineAsm, Item, ItemKind};
|
6 | 6 | use rustc_lint::{EarlyContext, EarlyLintPass, Lint, LintContext};
|
@@ -49,14 +49,10 @@ fn check_asm_syntax(
|
49 | 49 | };
|
50 | 50 |
|
51 | 51 | if style == check_for {
|
52 |
| - span_lint_and_help( |
53 |
| - cx, |
54 |
| - lint, |
55 |
| - span, |
56 |
| - format!("{style} x86 assembly syntax used"), |
57 |
| - None, |
58 |
| - format!("use {} x86 assembly syntax", !style), |
59 |
| - ); |
| 52 | + #[expect(clippy::collapsible_span_lint_calls, reason = "rust-clippy#7797")] |
| 53 | + span_lint_and_then(cx, lint, span, format!("{style} x86 assembly syntax used"), |diag| { |
| 54 | + diag.help(format!("use {} x86 assembly syntax", !style)); |
| 55 | + }); |
60 | 56 | }
|
61 | 57 | }
|
62 | 58 | }
|
@@ -98,13 +94,13 @@ declare_lint_pass!(InlineAsmX86IntelSyntax => [INLINE_ASM_X86_INTEL_SYNTAX]);
|
98 | 94 | impl EarlyLintPass for InlineAsmX86IntelSyntax {
|
99 | 95 | fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
|
100 | 96 | if let ExprKind::InlineAsm(inline_asm) = &expr.kind {
|
101 |
| - check_asm_syntax(Self::get_lints()[0], cx, inline_asm, expr.span, AsmStyle::Intel); |
| 97 | + check_asm_syntax(INLINE_ASM_X86_INTEL_SYNTAX, cx, inline_asm, expr.span, AsmStyle::Intel); |
102 | 98 | }
|
103 | 99 | }
|
104 | 100 |
|
105 | 101 | fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
|
106 | 102 | if let ItemKind::GlobalAsm(inline_asm) = &item.kind {
|
107 |
| - check_asm_syntax(Self::get_lints()[0], cx, inline_asm, item.span, AsmStyle::Intel); |
| 103 | + check_asm_syntax(INLINE_ASM_X86_INTEL_SYNTAX, cx, inline_asm, item.span, AsmStyle::Intel); |
108 | 104 | }
|
109 | 105 | }
|
110 | 106 | }
|
@@ -146,13 +142,13 @@ declare_lint_pass!(InlineAsmX86AttSyntax => [INLINE_ASM_X86_ATT_SYNTAX]);
|
146 | 142 | impl EarlyLintPass for InlineAsmX86AttSyntax {
|
147 | 143 | fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
|
148 | 144 | if let ExprKind::InlineAsm(inline_asm) = &expr.kind {
|
149 |
| - check_asm_syntax(Self::get_lints()[0], cx, inline_asm, expr.span, AsmStyle::Att); |
| 145 | + check_asm_syntax(INLINE_ASM_X86_ATT_SYNTAX, cx, inline_asm, expr.span, AsmStyle::Att); |
150 | 146 | }
|
151 | 147 | }
|
152 | 148 |
|
153 | 149 | fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
|
154 | 150 | if let ItemKind::GlobalAsm(inline_asm) = &item.kind {
|
155 |
| - check_asm_syntax(Self::get_lints()[0], cx, inline_asm, item.span, AsmStyle::Att); |
| 151 | + check_asm_syntax(INLINE_ASM_X86_ATT_SYNTAX, cx, inline_asm, item.span, AsmStyle::Att); |
156 | 152 | }
|
157 | 153 | }
|
158 | 154 | }
|
0 commit comments