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

Wrong code example for the "ref on an entire let pattern is discouraged" lint #1882

Closed
stanislav-tkach opened this issue Jul 10, 2017 · 2 comments
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@stanislav-tkach
Copy link
Contributor

Clippy gives confusing help-message for the following code:

let mut v = vec![1i8, 2, 3];
for ref mut val in &mut v {
    ...
}
warning: `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead
 --> src/main.rs:3:9
  |
3 |     for ref mut _val in &mut v {
  |         ^^^^^^^^^^^^
  |
  = note: #[warn(toplevel_ref_arg)] on by default
  = help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#toplevel_ref_arg
help: try
  |     let _val = &mut for ref mut _val in &mut v {
  |     };

ref mut can simply be removed, let isn't needed here.

@oli-obk oli-obk added the C-bug Category: Clippy is not doing the correct thing label Jul 10, 2017
@oli-obk
Copy link
Contributor

oli-obk commented Jul 10, 2017

This occurs due to the lack of expansion info we get from rustc. This should get fixed along with those fixes.

@camsteffen
Copy link
Contributor

No longer reproducible

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
Projects
None yet
Development

No branches or pull requests

3 participants