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

clippy gives bad suggestions when Deref is involved #4097

Closed
elichai opened this issue May 14, 2019 · 1 comment
Closed

clippy gives bad suggestions when Deref is involved #4097

elichai opened this issue May 14, 2019 · 1 comment

Comments

@elichai
Copy link
Contributor

elichai commented May 14, 2019

Hi, If I use a closure to pass something to a function using the Deref trait clippy tries to suggest to remove the closure but that doesn't compile.

Suggestion:

warning: redundant closure found
 --> src/lib.rs:5:22
  |
5 |     addrs.iter().map(|a| a.to_string()).collect()
  |                      ^^^^^^^^^^^^^^^^^ help: remove closure as shown: `ToString::to_string`
  |
  = note: #[warn(clippy::redundant_closure)] on by default
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure

Code before: https://play.rust-lang.org/?gist=67e025045af6f7989d554b2084f57d13
Code after applying the suggestion(doesn't compile): https://play.rust-lang.org/?gist=83ed70c09362c87cfe584e4744513a11

@Manishearth
Copy link
Member

#3942

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants