@@ -35,9 +35,8 @@ fn yeet_lint(cx: &LateContext<'_>, asm: &InlineAsm<'_>, asm_span: Span, op_spans
35
35
36
36
span_lint_and_then ( cx, POINTER_IN_NOMEM_ASM_BLOCK , op_spans, "passing pointer to nomem asm block" , |diag| {
37
37
if let Some ( probably_asm_options_span) = probably_asm_options_span {
38
- diag. span_suggestion ( probably_asm_options_span, "heeelppp" , "suggg" , Applicability :: MaybeIncorrect ) ;
38
+ diag. span_note ( probably_asm_options_span, "flags declared here" ) ;
39
39
}
40
- // note_span.inspect(|s| { diag.span_note(*s, "declared here"); });
41
40
} ) ;
42
41
}
43
42
@@ -58,21 +57,28 @@ fn check_asm(cx: &LateContext<'_>, asm: &InlineAsm<'_>, asm_span: Span) {
58
57
59
58
declare_clippy_lint ! {
60
59
/// ### What it does
60
+ /// Checks if any pointer is being passed to an asm! block with `nomem` option.
61
61
///
62
62
/// ### Why is this bad?
63
+ /// `nomem` forbids any reads or writes to memory and passing a pointer suggests
64
+ /// that either of those will happen.
63
65
///
64
66
/// ### Example
65
67
/// ```no_run
66
- /// // example code where clippy issues a warning
68
+ /// fn f(p: *mut u32) {
69
+ /// unsafe { core::arch::asm!("mov [{p}], 42", p = in(reg) p, options(nomem, nostack)); }
70
+ /// }
67
71
/// ```
68
72
/// Use instead:
69
73
/// ```no_run
70
- /// // example code which does not raise clippy warning
74
+ /// fn f(p: *mut u32) {
75
+ /// unsafe { core::arch::asm!("mov [{p}], 42", p = in(reg) p, options(nostack)); }
76
+ /// }
71
77
/// ```
72
78
#[ clippy:: version = "1.81.0" ]
73
79
pub POINTER_IN_NOMEM_ASM_BLOCK ,
74
80
suspicious,
75
- "default lint description "
81
+ "pointer in nomem asm block "
76
82
}
77
83
78
84
declare_lint_pass ! ( PointerInNomemAsmBlock => [ POINTER_IN_NOMEM_ASM_BLOCK ] ) ;
0 commit comments