Move naked function ABI check to its own lint
This check was previously categorized under the lint named `UNSUPPORTED_NAKED_FUNCTIONS`. That lint is future incompatible and will be turned into an error in a future release. However, as defined in the Constrained Naked Functions RFC, this check should only be a warning. This is because it is possible for a naked function to be implemented in such a way that it does not break even the undefined ABI. For example, a `jmp` to a `const`. Therefore, this patch defines a new lint named `UNDEFINED_NAKED_FUNCTION_ABI` which contains just this single check. Unlike `UNSUPPORTED_NAKED_FUNCTIONS`, `UNDEFINED_NAKED_FUNCTION_ABI` will not be converted to an error in the future. rust-lang/rfcs#2774 rust-lang/rfcs#2972
This commit is contained in:
parent
6fe0886723
commit
ba9afb58b3
4 changed files with 43 additions and 16 deletions
|
@ -2691,6 +2691,38 @@ declare_lint! {
|
|||
"detects deprecation attributes with no effect",
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `undefined_naked_function_abi` lint detects naked function definitions that
|
||||
/// either do not specify an ABI or specify the Rust ABI.
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
/// ```rust
|
||||
/// #![feature(naked_functions)]
|
||||
/// #![feature(asm)]
|
||||
///
|
||||
/// #[naked]
|
||||
/// pub fn default_abi() -> u32 {
|
||||
/// unsafe { asm!("", options(noreturn)); }
|
||||
/// }
|
||||
///
|
||||
/// #[naked]
|
||||
/// pub extern "Rust" fn rust_abi() -> u32 {
|
||||
/// unsafe { asm!("", options(noreturn)); }
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// {{produces}}
|
||||
///
|
||||
/// ### Explanation
|
||||
///
|
||||
/// The Rust ABI is currently undefined. Therefore, naked functions should
|
||||
/// specify a non-Rust ABI.
|
||||
pub UNDEFINED_NAKED_FUNCTION_ABI,
|
||||
Warn,
|
||||
"undefined naked function ABI"
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `unsupported_naked_functions` lint detects naked function
|
||||
/// definitions that are unsupported but were previously accepted.
|
||||
|
@ -2701,7 +2733,7 @@ declare_lint! {
|
|||
/// #![feature(naked_functions)]
|
||||
///
|
||||
/// #[naked]
|
||||
/// pub fn f() -> u32 {
|
||||
/// pub extern "sysv64" fn f() -> u32 {
|
||||
/// 42
|
||||
/// }
|
||||
/// ```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue