Skip to content

private_macro_use warning needs more information #136820

Open
@axos88

Description

@axos88

Related: #120192 Tracking Issue for private_macro_use lint

The warning needs more information on why a macro is considered private, possibly with full module path. The following produces a warning with very little information to go on to figure out that it's picking up the Serialize coming from serde_with, instead of serde. Having the definition of Foo in another module makes it magic on how the Serialize is not imported. (but I would guess that's an issue with #[macro_use]

Interestingly the #[macro_use] is considered unused by the compiler as well, but removing that produces an import error (correctly).

#[macro_use]
extern crate serde_with;


#[derive(Serialize)]
pub struct Foo;

pub fn main() {}

My Cargo.toml contains:

[dependencies]
serde = { version = "1.0.192", features = ["derive"] }
serde_with = "1.10.0"

warning: macro `Serialize` is private
 --> src/main.rs:5:10
  |
5 | #[derive(Serialize)]
  |          ^^^^^^^^^
  |
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #120192 <https://github.com/rust-lang/rust/issues/120192>
  = note: `#[warn(private_macro_use)]` on by default

warning: unused `#[macro_use]` import
 --> src/main.rs:1:1
  |
1 | #[macro_use]
  | ^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: `private-macro-test` (bin "private-macro-test") generated 2 warnings

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.L-private_macro_useLint: private_macro_useT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions