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

Arnavion opened this issue Feb 23, 2019 · 0 comments


None yet
2 participants
Copy link

commented Feb 23, 2019

clippy 0.0.212 (d61b2541 2019-02-19)


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/
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/
9 |     let _ = dependencies.iter().filter(Dependency::required);
  |                                        ^^^^^^^^^^^^^^^^^^^^ the trait `Dependency` is not implemented for `&D`
note: required by `Dependency::required`

bors added a commit that referenced this issue Feb 26, 2019

Auto merge of #3821 - g-bartoszek:redundant_closure-different-borrow-…
…levels, r=oli-obk

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

… level between closure parameter and "self", fixes  #3802

@bors bors closed this in #3821 Feb 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.