From 40a6c519b447a45c4ec1cdda4be067207d836306 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 25 Nov 2021 12:47:29 +0300 Subject: [PATCH] Update tests for type_complexity lint --- tests/ui/type_complexity.rs | 8 ++++++++ tests/ui/type_complexity.stderr | 20 ++++++++++++++++---- tests/ui/type_complexity_issue_1013.rs | 23 ----------------------- 3 files changed, 24 insertions(+), 27 deletions(-) delete mode 100644 tests/ui/type_complexity_issue_1013.rs 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>>) {} } +impl T for () { + const A: Vec>> = vec![]; + + // Should not warn since there is likely no way to simplify this (#1013) + type B = Vec>>; + fn method(&self, p: Vec>>) {} +} + fn test1() -> Vec>> { 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>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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![]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: very complex type used. Consider factoring parts into `type` definitions + --> $DIR/type_complexity.rs:38:25 + | +LL | fn method(&self, p: Vec>>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: very complex type used. Consider factoring parts into `type` definitions + --> $DIR/type_complexity.rs:41:15 | LL | fn test1() -> Vec>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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>>) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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![]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -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, 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() {}