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

private_macro_use warning needs more information #136820

Open
axos88 opened this issue Feb 10, 2025 · 0 comments
Open

private_macro_use warning needs more information #136820

axos88 opened this issue Feb 10, 2025 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. L-private_macro_use Lint: private_macro_use T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@axos88
Copy link

axos88 commented Feb 10, 2025

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

@axos88 axos88 added the C-bug Category: This is a bug. label Feb 10, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 10, 2025
@jieyouxu jieyouxu added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. L-private_macro_use Lint: private_macro_use and removed C-bug Category: This is a bug. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. L-private_macro_use Lint: private_macro_use T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants