private_macro_use warning needs more information
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the warning using the example in src/main.rs and the dependencies in Cargo.toml, then read the related tracking issue #120192. Trace the compiler diagnostic for private_macro_use and determine what information is available about the selected macro. Done means the warning explains why Serialize is private and identifies its source clearly, with coverage for this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100