Skip to content

Type complexity should not be considered when defining an associated type #1013

Closed
@malbarbo

Description

@malbarbo

Consider this example:

use std::vec::IntoIter;
use std::iter::{Map, Filter};

struct S;

impl IntoIterator for S {
    type Item = i32;
    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)
    }
}

Clippy warns that Filter<Map<IntoIter<i32>, fn(i32) -> i32>, fn(&i32) -> bool> is a very complex type and suggest creating a type definition, but it already is type definition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions