Skip to content

Commit

Permalink
Solves #3222 by checking the BareFnTy Abi type
Browse files Browse the repository at this point in the history
  • Loading branch information
joelgallant committed Oct 5, 2018
1 parent eb2cfe6 commit 163780e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clippy_lints/src/types.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions tests/ui/complex_types.rs
Expand Up @@ -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() {
}

0 comments on commit 163780e

Please sign in to comment.