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

Usage of tokio::select! triggers redundant_pub_crate (nursery) #12213

Closed
barafael opened this issue Jan 29, 2024 · 0 comments · Fixed by #13952
Closed

Usage of tokio::select! triggers redundant_pub_crate (nursery) #12213

barafael opened this issue Jan 29, 2024 · 0 comments · Fixed by #13952
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@barafael
Copy link

Summary

On nursery lint level, any usage of tokio::select! wrongly triggers the redundant_pub_crate lint.

Lint Name

redundant_pub_crate

Reproducer

I tried this code:

use std::future::Future;
use tokio::select;

pub async fn selects(number: impl Future<Output = i32>, boolean: impl Future<Output = bool>) {
    select! {
        n = number => {
            println!("A number: {n}");
        },
        b = boolean => {
            println!("A boolean: {b}");
        }
    }
}

I saw this happen:

  --> src\lib.rs:5:5
   |
5  | /     select! {
6  | |         n = number => {
7  | |             println!("A number: {n}");
8  | |         },
...  |
11 | |         }
12 | |     }
   | |_____^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pub_crate
   = note: `-W clippy::redundant-pub-crate` implied by `-W clippy::nursery`
   = help: to override `-W clippy::nursery` add `#[allow(clippy::redundant_pub_crate)]`
   = note: this warning originates in the macro `$crate::select_priv_declare_output_enum` which comes from the expansion of the macro `select` (in Nightly builds, run with -Z macro-backtrace for more info)

I expected to see this happen: no lint triggered on select!.

Version

rustc 1.77.0-nightly (5d3d3479d 2024-01-23)
binary: rustc
commit-hash: 5d3d3479d774754856db2db3e439dfb88ef3c52f
commit-date: 2024-01-23
host: x86_64-pc-windows-msvc
release: 1.77.0-nightly
LLVM version: 17.0.6

Additional Labels

No response

@barafael barafael 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 Jan 29, 2024
github-merge-queue bot pushed a commit that referenced this issue Jan 12, 2025
Some widely used crates, such as `pin-project-lite`, make use of a
`pub(crate)` construct in a private module inside a public macro. This
makes unrelated project trigger the lint.

There is also an unfortunate situation for Clippy itself: when a new
version of `pin-project-lite` or similar lint-trigerring crates is
released, those lints which can be found in hundreds of occurrences in
dependent crates will change, and appear as diffs in unrelated Clippy PR
because the base lintcheck run will be cached with the ancient release
of the crates. We currently have the situation
[here](https://github.com/rust-lang/rust-clippy/actions/runs/12635410895?pr=13851#user-content-redundant-pub-crate-removed),
which 219 lints removed and 219 lints added because of a
`pin-project-lite` version change between runs, and the fact that
`redundant_pub_crate` triggers on external macros.

Also:
- Fix #10636
- Fix #12213

changelog: [`redundant_pub_crate`]: do not trigger on external macros
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 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.

1 participant