about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMaybe Waffle <waffle.lapkin@gmail.com>2021-11-25 12:47:29 +0300
committerMaybe Waffle <waffle.lapkin@gmail.com>2021-11-25 12:47:29 +0300
commit40a6c519b447a45c4ec1cdda4be067207d836306 (patch)
tree5ef95d3620b3ca64d5853988157d7c17deaa0ea8
parent063f8aa094a740b98b0dab49d8361441c8f1d0c4 (diff)
downloadrust-40a6c519b447a45c4ec1cdda4be067207d836306.tar.gz
rust-40a6c519b447a45c4ec1cdda4be067207d836306.zip
Update tests for type_complexity lint
-rw-r--r--tests/ui/type_complexity.rs8
-rw-r--r--tests/ui/type_complexity.stderr20
-rw-r--r--tests/ui/type_complexity_issue_1013.rs23
3 files changed, 24 insertions, 27 deletions
diff --git a/tests/ui/type_complexity.rs b/tests/ui/type_complexity.rs
index 383bbb49dbe..62d00e00729 100644
--- a/tests/ui/type_complexity.rs
+++ b/tests/ui/type_complexity.rs
@@ -30,6 +30,14 @@ trait T {
     fn def_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
 }
 
+impl T for () {
+    const A: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![];
+
+    // Should not warn since there is likely no way to simplify this (#1013)
+    type B = Vec<Vec<Box<(u32, u32, u32, u32)>>>;
+    fn method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
+}
+
 fn test1() -> Vec<Vec<Box<(u32, u32, u32, u32)>>> {
     vec![]
 }
diff --git a/tests/ui/type_complexity.stderr b/tests/ui/type_complexity.stderr
index 7879233fdf2..693f2adcfc8 100644
--- a/tests/ui/type_complexity.stderr
+++ b/tests/ui/type_complexity.stderr
@@ -73,22 +73,34 @@ LL |     fn def_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
    |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: very complex type used. Consider factoring parts into `type` definitions
-  --> $DIR/type_complexity.rs:33:15
+  --> $DIR/type_complexity.rs:34:14
+   |
+LL |     const A: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![];
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: very complex type used. Consider factoring parts into `type` definitions
+  --> $DIR/type_complexity.rs:38:25
+   |
+LL |     fn method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
+   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: very complex type used. Consider factoring parts into `type` definitions
+  --> $DIR/type_complexity.rs:41:15
    |
 LL | fn test1() -> Vec<Vec<Box<(u32, u32, u32, u32)>>> {
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: very complex type used. Consider factoring parts into `type` definitions
-  --> $DIR/type_complexity.rs:37:14
+  --> $DIR/type_complexity.rs:45:14
    |
 LL | fn test2(_x: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: very complex type used. Consider factoring parts into `type` definitions
-  --> $DIR/type_complexity.rs:40:13
+  --> $DIR/type_complexity.rs:48:13
    |
 LL |     let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![];
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error: aborting due to 15 previous errors
+error: aborting due to 17 previous errors
 
diff --git a/tests/ui/type_complexity_issue_1013.rs b/tests/ui/type_complexity_issue_1013.rs
deleted file mode 100644
index c68ab3aaf94..00000000000
--- a/tests/ui/type_complexity_issue_1013.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-#![warn(clippy::type_complexity)]
-use std::iter::{Filter, Map};
-use std::vec::IntoIter;
-
-struct S;
-
-impl IntoIterator for S {
-    type Item = i32;
-    // Should not warn since there is no way to simplify this
-    type IntoIter = Filter<Map<IntoIter<i32>, fn(i32) -> i32>, fn(&i32) -> bool>;
-
-    fn into_iter(self) -> Self::IntoIter {
-        fn m(a: i32) -> i32 {
-            a
-        }
-        fn p(_: &i32) -> bool {
-            true
-        }
-        vec![1i32, 2, 3].into_iter().map(m as fn(_) -> _).filter(p)
-    }
-}
-
-fn main() {}