Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FN: needless_collect: collecting without turbofish #6932

Closed
matthiaskrgr opened this issue Mar 18, 2021 · 1 comment
Closed

FN: needless_collect: collecting without turbofish #6932

matthiaskrgr opened this issue Mar 18, 2021 · 1 comment
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@matthiaskrgr
Copy link
Member

Lint name: needless_collect

I tried this code:

struct A {
    i: i32,
}

fn fun(numbers: &[i32]) -> impl Iterator<Item = A> {
    let v: Vec<_> = numbers.iter().map(|x| A { i: *x }).collect();
    v.into_iter()
}

does not trigger the lint while

struct A {
    i: i32,
}

pub fn fun(numbers: &[i32]) -> impl Iterator<Item = A> {
    let v = numbers.iter().map(|x| A { i: *x }).collect::<Vec<A>>();
    v.into_iter()
}

does

Meta

  • cargo clippy -V: clippy 0.1.52 (36f1f04 2021-03-17)
  • rustc -Vv:
    rustc 1.46.0-nightly (f455e46ea 2020-06-20)
    binary: rustc
    commit-hash: f455e46eae1a227d735091091144601b467e1565
    commit-date: 2020-06-20
    host: x86_64-unknown-linux-gnu
    release: 1.46.0-nightly
    LLVM version: 10.0
    
    
@matthiaskrgr matthiaskrgr added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Mar 18, 2021
@camsteffen camsteffen added the good-first-issue These issues are a good way to get started with Clippy label May 3, 2021
@camsteffen
Copy link
Contributor

Fixed by #7163

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing good-first-issue These issues are a good way to get started with Clippy I-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants