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

redundant_closure fires for trait function that differs in levels of borrow from point-free form #3802

Closed
Arnavion opened this issue Feb 23, 2019 · 0 comments · Fixed by #3821
Labels
C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@Arnavion
Copy link
Contributor

clippy 0.0.212 (d61b2541 2019-02-19)

#![deny(clippy::redundant_closure)]

pub trait Dependency {
    fn required(&self) -> bool;
}

pub fn foo<D>(dependencies: &[D]) where D: Dependency {
    let _ = dependencies.iter().filter(|dep| dep.required());
}
error: redundant closure found
 --> src/lib.rs:8:40
  |
8 |     let _ = dependencies.iter().filter(|dep| dep.required());
  |                                        ^^^^^^^^^^^^^^^^^^^^ help: remove closure as shown: `Dependency::required`

But that suggestion will not compile because dep is a &&D and Dependency::required wants a &D

    let _ = dependencies.iter().filter(Dependency::required);
error[E0277]: the trait bound `&D: Dependency` is not satisfied
 --> src/lib.rs:9:40
  |
9 |     let _ = dependencies.iter().filter(Dependency::required);
  |                                        ^^^^^^^^^^^^^^^^^^^^ the trait `Dependency` is not implemented for `&D`
  |
note: required by `Dependency::required`
@flip1995 flip1995 added C-bug Category: Clippy is not doing the correct thing I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied labels Feb 23, 2019
bors added a commit that referenced this issue Feb 26, 2019
…levels, r=oli-obk

do not trigger redundant_closure when there is a difference in borrow…

… level between closure parameter and "self", fixes  #3802
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 I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants