mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
extern fns often need to adhere to a specific api -> don't suggest api-changes
This commit is contained in:
parent
ac5abcf593
commit
331afc3246
@ -4,6 +4,7 @@ use rustc::ty;
|
|||||||
use rustc::lint::*;
|
use rustc::lint::*;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
|
use syntax::abi::Abi;
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
use utils::{span_lint, type_is_unsafe_function};
|
use utils::{span_lint, type_is_unsafe_function};
|
||||||
|
|
||||||
@ -85,7 +86,12 @@ impl LateLintPass for Functions {
|
|||||||
|
|
||||||
// don't warn for implementations, it's not their fault
|
// don't warn for implementations, it's not their fault
|
||||||
if !is_impl {
|
if !is_impl {
|
||||||
self.check_arg_number(cx, decl, span);
|
// don't lint extern functions decls, it's not their fault either
|
||||||
|
match kind {
|
||||||
|
hir::intravisit::FnKind::Method(_, &hir::MethodSig { abi: Abi::Rust, .. }, _, _) |
|
||||||
|
hir::intravisit::FnKind::ItemFn(_, _, _, _, Abi::Rust, _, _) => self.check_arg_number(cx, decl, span),
|
||||||
|
_ => {},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.check_raw_ptr(cx, unsafety, decl, block, nodeid);
|
self.check_raw_ptr(cx, unsafety, decl, block, nodeid);
|
||||||
@ -93,7 +99,10 @@ impl LateLintPass for Functions {
|
|||||||
|
|
||||||
fn check_trait_item(&mut self, cx: &LateContext, item: &hir::TraitItem) {
|
fn check_trait_item(&mut self, cx: &LateContext, item: &hir::TraitItem) {
|
||||||
if let hir::MethodTraitItem(ref sig, ref block) = item.node {
|
if let hir::MethodTraitItem(ref sig, ref block) = item.node {
|
||||||
self.check_arg_number(cx, &sig.decl, item.span);
|
// don't lint extern functions decls, it's not their fault
|
||||||
|
if sig.abi == Abi::Rust {
|
||||||
|
self.check_arg_number(cx, &sig.decl, item.span);
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(ref block) = *block {
|
if let Some(ref block) = *block {
|
||||||
self.check_raw_ptr(cx, sig.unsafety, &sig.decl, block, item.id);
|
self.check_raw_ptr(cx, sig.unsafety, &sig.decl, block, item.id);
|
||||||
|
@ -12,6 +12,9 @@ fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _
|
|||||||
//~^ ERROR: this function has too many arguments (8/7)
|
//~^ ERROR: this function has too many arguments (8/7)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// don't lint extern fns
|
||||||
|
extern fn extern_fn(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ()) {}
|
||||||
|
|
||||||
pub trait Foo {
|
pub trait Foo {
|
||||||
fn good(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool);
|
fn good(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool);
|
||||||
fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ());
|
fn bad(_one: u32, _two: u32, _three: &str, _four: bool, _five: f32, _six: f32, _seven: bool, _eight: ());
|
||||||
|
Loading…
Reference in New Issue
Block a user