]> git.lizzy.rs Git - rust.git/commitdiff
Solves #3222 by checking the BareFnTy Abi type
authorJoel Gallant <joel@joelgallant.me>
Thu, 4 Oct 2018 23:30:45 +0000 (17:30 -0600)
committerJoel Gallant <joel@joelgallant.me>
Fri, 5 Oct 2018 00:49:03 +0000 (18:49 -0600)
clippy_lints/src/types.rs
tests/ui/complex_types.rs

index 857238e9002bf5a8092c2f02c3701df94f42889a..6f024e596107976e5097086567778792d49e22e0 100644 (file)
@@ -16,6 +16,7 @@
 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 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
             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
index a6875793c8310c93078b10a9d033d5bda718f93c..eac2c07c12ea9a4d7fb56bb756f137a50a910ea7 100644 (file)
@@ -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() {
 }