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

default_numeric_fallback should not warn code generated by external macros #7304

Closed
taiki-e opened this issue Jun 1, 2021 · 2 comments · Fixed by #7325
Closed

default_numeric_fallback should not warn code generated by external macros #7304

taiki-e opened this issue Jun 1, 2021 · 2 comments · Fixed by #7325
Assignees
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

@taiki-e
Copy link
Member

taiki-e commented Jun 1, 2021

I tried this code:

#[warn(clippy::default_numeric_fallback)]
pub async fn myfunc() {
    tokio::select! {
        _ = async {} => (),
        else => (),
    }
}

I expected to see this happen: no warning

Instead, this happened: default_numeric_fallback warns code generated by external macros

warning: default numeric fallback might occur
 --> src/lib.rs:3:5
  |
3 | /     tokio::select! {
4 | |         _ = async {} => (),
5 | |         else => (),
6 | |     }
  | |_____^
  |
note: the lint level is defined here
 --> src/lib.rs:1:8
  |
1 | #[warn(clippy::default_numeric_fallback)]
  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#default_numeric_fallback
  = note: this warning originates in the macro `$crate::count` (in Nightly builds, run with -Z macro-backtrace for more info)

playground

This originally reported by @kamulos in tokio-rs/tokio#3830.

Meta

  • cargo clippy -V: e.g. clippy 0.1.54 (c1e8f3a 2021-05-30)
  • rustc -Vv:
    rustc 1.54.0-nightly (c1e8f3a58 2021-05-30)
    binary: rustc
    commit-hash: c1e8f3a5857c3c8d095fd212acc6ed442f4cc58b
    commit-date: 2021-05-30
    host: x86_64-apple-darwin
    release: 1.54.0-nightly
    LLVM version: 12.0.1
    
@taiki-e
Copy link
Member Author

taiki-e commented Jun 1, 2021

Mentioning @Y-Nak who implemented this lint in #6662.

@giraffate giraffate added 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 labels Jun 2, 2021
@Y-Nak
Copy link
Contributor

Y-Nak commented Jun 2, 2021

@rustbot claim
I'll fix this in this week.

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.

3 participants