Rollup merge of #121318 - kadiwa4:no_assembly_in_supposedly_safe_code, r=Nilstrieb
Trigger `unsafe_code` lint on invocations of `global_asm` `unsafe_code` already warns about things that don't involve the `unsafe` keyword, e.g. `#[no_mangle]`. This makes it warn on `core::arch::global_asm` too. Fixes #103078
This commit is contained in:
commit
d61adbffe1
7 changed files with 59 additions and 4 deletions
|
@ -773,7 +773,7 @@ pub(super) fn expand_global_asm<'cx>(
|
|||
kind: ast::VisibilityKind::Inherited,
|
||||
tokens: None,
|
||||
},
|
||||
span: ecx.with_def_site_ctxt(sp),
|
||||
span: sp,
|
||||
tokens: None,
|
||||
})])
|
||||
} else {
|
||||
|
|
|
@ -72,8 +72,11 @@ lint_builtin_explicit_outlives = outlives requirements can be inferred
|
|||
|
||||
lint_builtin_export_name_fn = declaration of a function with `export_name`
|
||||
lint_builtin_export_name_method = declaration of a method with `export_name`
|
||||
|
||||
lint_builtin_export_name_static = declaration of a static with `export_name`
|
||||
|
||||
lint_builtin_global_asm = usage of `core::arch::global_asm`
|
||||
lint_builtin_global_macro_unsafety = using this macro is unsafe even though it does not need an `unsafe` block
|
||||
|
||||
lint_builtin_impl_unsafe_method = implementation of an `unsafe` method
|
||||
|
||||
lint_builtin_incomplete_features = the feature `{$name}` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
|
|
|
@ -393,6 +393,10 @@ impl EarlyLintPass for UnsafeCode {
|
|||
}
|
||||
}
|
||||
|
||||
ast::ItemKind::GlobalAsm(..) => {
|
||||
self.report_unsafe(cx, it.span, BuiltinUnsafe::GlobalAsm);
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,6 +114,9 @@ pub enum BuiltinUnsafe {
|
|||
DeclUnsafeMethod,
|
||||
#[diag(lint_builtin_impl_unsafe_method)]
|
||||
ImplUnsafeMethod,
|
||||
#[diag(lint_builtin_global_asm)]
|
||||
#[note(lint_builtin_global_macro_unsafety)]
|
||||
GlobalAsm,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue