Summary
The type_complexity lint suggests extracting the complex type as an alias, but this is not allowed (in stable Rust) when the type involves an impl Trait.
Lint Name
type_complexity
Reproducer
I tried this code:
use std::iter::{Map, Zip};
pub fn main() {
for [x, y] in array_zip([1, 2, 3], [4, 5, 6]) {
println!("{x} <-> {y}");
}
}
pub fn array_zip<I, J>(
left: I,
right: J,
) -> Map<Zip<I::IntoIter, J::IntoIter>, impl FnMut((I::Item, I::Item)) -> [I::Item; 2]>
where
I: IntoIterator,
J: IntoIterator<Item = I::Item>,
{
left.into_iter().zip(right).map(<[I::Item; 2]>::from)
}
I saw this happen:
Checking playground v0.0.1 (/playground)
warning: very complex type used. Consider factoring parts into `type` definitions
--> src/main.rs:12:6
|
12 | ) -> Map<Zip<I::IntoIter, J::IntoIter>, impl FnMut((I::Item, I::Item)) -> [I::Item; 2]>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.96.0/index.html#type_complexity
= note: `#[warn(clippy::type_complexity)]` on by default
warning: `playground` (bin "playground") generated 1 warning
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.63s
I expected to see this happen: No lints triggered.
Version
Playground, running 1.96.0 (stable)
Additional Labels
@rustbot label +I-suggestion-causes-error
Summary
The
type_complexitylint suggests extracting the complex type as an alias, but this is not allowed (in stable Rust) when the type involves an impl Trait.Lint Name
type_complexity
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen: No lints triggered.
Version
Additional Labels
@rustbot label +I-suggestion-causes-error