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

FP: mut_mut in external macro #6922

Closed
Y-Nak opened this issue Mar 17, 2021 · 1 comment · Fixed by #7795
Closed

FP: mut_mut in external macro #6922

Y-Nak opened this issue Mar 17, 2021 · 1 comment · Fixed by #7795
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-positive Issue: The lint was triggered on code it shouldn't have

Comments

@Y-Nak
Copy link
Contributor

Y-Nak commented Mar 17, 2021

Lint name: mut_mut

I tried this code:
the example of async-book also triggered the lint, though this is not the original one.

use futures::{
    future::FutureExt, // for `.fuse()`
    pin_mut,
    select,
};

async fn task_one() { /* ... */
}
async fn task_two() { /* ... */
}

async fn race_tasks() {
    let t1 = task_one().fuse();
    let t2 = task_two().fuse();

    pin_mut!(t1, t2);

    select! {
        () = t1 => println!("task one completed first"),
        () = t2 => println!("task two completed first"),
    }
}

I expected to see this happen: None.
Instead, this happened:

error: generally you want to avoid `&mut &mut _` if possible
  --> src/lib.rs:18:5
   |
18 | /     select! {
19 | |         () = t1 => println!("task one completed first"),
20 | |         () = t2 => println!("task two completed first"),
21 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#mut_mut
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

Meta

  • cargo clippy -V: clippy 0.1.52 (f5d8117 2021-03-16)
  • rustc -Vv:
rustc 1.52.0-nightly (f5d8117c3 2021-03-16)
binary: rustc
commit-hash: f5d8117c338a788bd24abec733fd143dfceb25a0
commit-date: 2021-03-16
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 12.0.0

This would be caused by the missing of in_external_macro here.

@Y-Nak Y-Nak added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Mar 17, 2021
@Y-Nak

This comment has been minimized.

@rustbot rustbot added the good-first-issue These issues are a good way to get started with Clippy label Mar 17, 2021
@bors bors closed this as completed in bc9ad84 Oct 11, 2021
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-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants