Skip to content

False positive for needless_lifetimes #740

@andybarron

Description

@andybarron

Here's a trivial example that should trigger it. Removing the lifetime annotations causes the code not to compile (cannot infer an appropriate lifetime ...), but clippy gives a needless_lifetimes warning.

struct Test {
    vec: Vec<usize>,
}

impl Test {
    fn iter<'a>(&'a self) -> Box<Iterator<Item = usize> + 'a> {
        Box::new(self.vec.iter().cloned())
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingE-hardCall for participation: This a hard problem and requires more experience or effort to work on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions