Introduce missing ABI lint on extern blocks
This commit is contained in:
parent
9f3998b4aa
commit
c4a8d7f86a
7 changed files with 68 additions and 7 deletions
|
@ -2917,6 +2917,7 @@ declare_lint_pass! {
|
|||
FUNCTION_ITEM_REFERENCES,
|
||||
USELESS_DEPRECATED,
|
||||
UNSUPPORTED_NAKED_FUNCTIONS,
|
||||
MISSING_ABI,
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -2944,3 +2945,28 @@ declare_lint! {
|
|||
}
|
||||
|
||||
declare_lint_pass!(UnusedDocComment => [UNUSED_DOC_COMMENTS]);
|
||||
|
||||
declare_lint! {
|
||||
/// The `missing_abi` lint detects cases where the ABI is omitted from
|
||||
/// extern declarations.
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
/// ```rust,compile_fail
|
||||
/// #![deny(missing_abi)]
|
||||
///
|
||||
/// extern fn foo() {}
|
||||
/// ```
|
||||
///
|
||||
/// {{produces}}
|
||||
///
|
||||
/// ### Explanation
|
||||
///
|
||||
/// Historically, Rust implicitly selected C as the ABI for extern
|
||||
/// declarations. We expect to add new ABIs, like `C-unwind`, in the future,
|
||||
/// though this has not yet happened, and especially with their addition
|
||||
/// seeing the ABI easily will make code review easier.
|
||||
pub MISSING_ABI,
|
||||
Allow,
|
||||
"No declared ABI for extern declaration"
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ use rustc_ast::node_id::{NodeId, NodeMap};
|
|||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::{sym, symbol::Ident, MultiSpan, Span, Symbol};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
pub mod builtin;
|
||||
|
||||
|
@ -252,6 +253,7 @@ pub enum BuiltinLintDiagnostics {
|
|||
UnusedImports(String, Vec<(Span, String)>),
|
||||
RedundantImport(Vec<(Span, bool)>, Ident),
|
||||
DeprecatedMacro(Option<Symbol>, Span),
|
||||
MissingAbi(Span, Abi),
|
||||
UnusedDocComment(Span),
|
||||
PatternsInFnsWithoutBody(Span, Ident),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue