Validate naked functions definitions
This commit is contained in:
parent
91fe548825
commit
8065dabd17
10 changed files with 757 additions and 121 deletions
|
@ -2742,6 +2742,50 @@ declare_lint! {
|
|||
"detects deprecation attributes with no effect",
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `unsupported_naked_functions` lint detects naked function
|
||||
/// definitions that are unsupported but were previously accepted.
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
/// ```rust
|
||||
/// #![feature(naked_functions)]
|
||||
///
|
||||
/// #[naked]
|
||||
/// pub fn f() -> u32 {
|
||||
/// 42
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// {{produces}}
|
||||
///
|
||||
/// ### Explanation
|
||||
///
|
||||
/// The naked functions must be defined using a single inline assembly
|
||||
/// block.
|
||||
///
|
||||
/// The execution must never fall through past the end of the assembly
|
||||
/// code so the block must use `noreturn` option. The asm block can also
|
||||
/// use `att_syntax` option, but other options are not allowed.
|
||||
///
|
||||
/// The asm block must not contain any operands other than `const` and
|
||||
/// `sym`. Additionally, naked function should specify a non-Rust ABI.
|
||||
///
|
||||
/// While other definitions of naked functions were previously accepted,
|
||||
/// they are unsupported and might not work reliably. This is a
|
||||
/// [future-incompatible] lint that will transition into hard error in
|
||||
/// the future.
|
||||
///
|
||||
/// [future-incompatible]: ../index.md#future-incompatible-lints
|
||||
pub UNSUPPORTED_NAKED_FUNCTIONS,
|
||||
Warn,
|
||||
"unsupported naked function definitions",
|
||||
@future_incompatible = FutureIncompatibleInfo {
|
||||
reference: "issue #32408 <https://github.com/rust-lang/rust/issues/32408>",
|
||||
edition: None,
|
||||
};
|
||||
}
|
||||
|
||||
declare_tool_lint! {
|
||||
pub rustc::INEFFECTIVE_UNSTABLE_TRAIT_IMPL,
|
||||
Deny,
|
||||
|
@ -2832,6 +2876,7 @@ declare_lint_pass! {
|
|||
UNINHABITED_STATIC,
|
||||
FUNCTION_ITEM_REFERENCES,
|
||||
USELESS_DEPRECATED,
|
||||
UNSUPPORTED_NAKED_FUNCTIONS,
|
||||
]
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue