Skip to content

redundant_pub_crate FP for macro definition #8732

Closed
@Kage-Yami

Description

@Kage-Yami

Summary

I've written an "internal" macro in my crate, and don't want it to be exported at the root/publicly, so instead of annotating it with #[macro_export], I've added pub(crate) use bit; after the definition. Following the recommendation from clippy::redundant_pub_crate to remove (crate) prevents the crate from compiling because the macro:

is only public within the crate, and cannot be re-exported outside

Lint Name

redundant_pub_crate

Reproducer

I tried this code:

// in lib.rs
#![warn(clippy::nursery)]
mod util;

// in util.rs
macro_rules! bit {
    ($bit:literal, $value:ident) => {
        $value >> $bit & 1 == 1
    };

    ($bit:ident, $value:ident) => {
        $value >> $bit & 1 == 1
    };
}

pub(crate) use bit;

I saw this happen:

warning: pub(crate) import inside private module
  --> src\util.rs:40:1
   |
40 | pub(crate) use bit;
   | ----------^^^^^^^^
   | |
   | help: consider using: `pub`
   |
note: the lint level is defined here
  --> src\lib.rs:1:24
   |
1  | #![warn(clippy::cargo, clippy::nursery, clippy::pedantic)]
   |                        ^^^^^^^^^^^^^^^
   = note: `#[warn(clippy::redundant_pub_crate)]` implied by `#[warn(clippy::nursery)]`
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_pub_crate

I expected to not see a lint warning.

Version

rustc 1.60.0 (7737e0b5c 2022-04-04)
binary: rustc
commit-hash: 7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c
commit-date: 2022-04-04
host: x86_64-pc-windows-msvc
release: 1.60.0
LLVM version: 14.0.0

Additional Labels

@rustbot label +I-suggestion-causes-error

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions