diff options
| author | Joel Gallant <joel@joelgallant.me> | 2018-10-04 17:30:45 -0600 |
|---|---|---|
| committer | Joel Gallant <joel@joelgallant.me> | 2018-10-04 18:49:03 -0600 |
| commit | 163780ee0b41de143ec06181026ef575a736de2f (patch) | |
| tree | 455edf36f2cca2ad205ca883ac579b4efadfdc6d | |
| parent | eb2cfe62b523c34dc2ec5990b0113001c936db7e (diff) | |
| download | rust-163780ee0b41de143ec06181026ef575a736de2f.tar.gz rust-163780ee0b41de143ec06181026ef575a736de2f.zip | |
Solves #3222 by checking the BareFnTy Abi type
| -rw-r--r-- | clippy_lints/src/types.rs | 3 | ||||
| -rw-r--r-- | tests/ui/complex_types.rs | 17 |
2 files changed, 19 insertions, 1 deletions
diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 857238e9002..6f024e59610 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -16,6 +16,7 @@ use std::borrow::Cow; use crate::syntax::ast::{FloatTy, IntTy, UintTy}; use crate::syntax::source_map::Span; use crate::syntax::errors::DiagnosticBuilder; +use crate::rustc_target::spec::abi::Abi; use crate::utils::{comparisons, differing_macro_contexts, higher, in_constant, in_macro, last_path_segment, match_def_path, match_path, match_type, multispan_sugg, opt_def_id, same_tys, snippet, snippet_opt, span_help_and_lint, span_lint, span_lint_and_sugg, span_lint_and_then, clip, unsext, sext, int_bits}; @@ -1224,7 +1225,7 @@ impl<'tcx> Visitor<'tcx> for TypeComplexityVisitor { TyKind::Path(..) | TyKind::Slice(..) | TyKind::Tup(..) | TyKind::Array(..) => (10 * self.nest, 1), // function types bring a lot of overhead - TyKind::BareFn(..) => (50 * self.nest, 1), + TyKind::BareFn(ref bare) if bare.abi == Abi::Rust => (50 * self.nest, 1), TyKind::TraitObject(ref param_bounds, _) => { let has_lifetime_parameters = param_bounds diff --git a/tests/ui/complex_types.rs b/tests/ui/complex_types.rs index a6875793c83..eac2c07c12e 100644 --- a/tests/ui/complex_types.rs +++ b/tests/ui/complex_types.rs @@ -40,5 +40,22 @@ fn test3() { let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![]; } +#[repr(C)] +struct D { + // should not warn, since we don't have control over the signature (#3222) + test4: extern "C" fn( + itself: &D, + a: usize, + b: usize, + c: usize, + d: usize, + e: usize, + f: usize, + g: usize, + h: usize, + i: usize, + ), +} + fn main() { } |
