You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a tracking issue for the private_macro_use, a lint that follows the breaking change policy.
Description
The root of this issue was originally posted in #119301. A macro that should not have been exported was indeed exported. A minimal example to illustrate this issue is shown below:
// extern_macro.rsmacro_rules! foo_ {() => {}};use foo_ as foo;// code.rs#[macro_use]externcrate extern_macro;fnmain(){foo!();// this should trigger a compile error, but it doesn't}
The problem was triggered by an oversight where a visibility check for the macro, defined in an external crate, was omitted. Now, we have reintroduced this check to prevent such issues from occurring.
The new imposition of private_macro_use is a really bad idea, and it is going to cause chaos in the Rust community, because cargo check on the "offending" crate does not raise this lint, and now it is becoming deny and therefore will raise a compile error on the downstream crate, and will be completely invisible to the upstream author who caused the issue.
This is utterly ridiculous developer experience and very anti-Rust. The lint does not provide enough information. It does not help developers to raise compile errors in dependent crates when the upstream crate compiles without error or warning. And if the used macro is truly private, I would think the dependent crate would not compile anyway, so what is the additional use of this lint if it adds absolutely no value beyond what the compile error itself would offer (and indeed would likely provide more useful information)?
It seems to me that private_macro_use should be kept internal to rustc to keep the rustc developers in check about what private macros they might be inadvertently exporting, and should, if made public, be totally optional.
Look at num-bigint-dig crate, which is used by rsa and others. It will soon no longer compile without a patch because of this lint, especially if it is changed to deny by default. I forked and cloned that crate, and could not get this lint to show on cargo check using any combination of flags on that crate.
This will raise random errors all over the place in any crate that uses even public macros such as vec![] that do not pub use alloc::vec, etc. This is just a major disaster waiting to happen. Please fix it. Take this back to the drawing board and make it:
not lint on any public macros (clearly it doesn't respect this rule, because vec![] is public by definition);
lint on the offending crate as well as in any downstream crate (currently does not lint at all on the offending crate);
able to be overridden with something more convenient than -Aprivate-macro-use rustc flag or #![allow(Aprivate_macro_use)] directive, because this will raise warnings everywhere.
Reacted by Artem Tokarev, Ellen Emilia Anna Zscheile, Lucas Vienna, Gerald Pinder, Jacob Elder, Alexander van Saase, Lucas Fehres and r-comeau
Just upgraded to newest nightly and also got the warning mentioning num-bigint-dig. For now, until this warning works correctly, I've suppressed all future incompat warnings by putting the following in .cargo/config.toml in my project
Activity
Auto merge of #143929 - petrochenkov:depresolve, r=<try>
Rollup merge of rust-lang#143929 - petrochenkov:depresolve, r=lcnr
Rollup merge of rust-lang#143929 - petrochenkov:depresolve, r=lcnr
Rollup merge of rust-lang#143929 - petrochenkov:depresolve, r=lcnr
Rollup merge of rust-lang#143929 - petrochenkov:depresolve, r=lcnr
Rollup merge of rust-lang#143929 - petrochenkov:depresolve, r=lcnr
Rollup merge of rust-lang#143929 - petrochenkov:depresolve, r=lcnr
Unrolled build for #143929
Rollup merge of #143929 - petrochenkov:depresolve, r=lcnr
chore: Fix future incompatibility warning (#60)
Rollup merge of #143929 - petrochenkov:depresolve, r=lcnr
tgrushka commentedon Aug 30, 2025
The new imposition of
private_macro_useis a really bad idea, and it is going to cause chaos in the Rust community, becausecargo checkon the "offending" crate does not raise this lint, and now it is becoming deny and therefore will raise a compile error on the downstream crate, and will be completely invisible to the upstream author who caused the issue.This is utterly ridiculous developer experience and very anti-Rust. The lint does not provide enough information. It does not help developers to raise compile errors in dependent crates when the upstream crate compiles without error or warning. And if the used macro is truly private, I would think the dependent crate would not compile anyway, so what is the additional use of this lint if it adds absolutely no value beyond what the compile error itself would offer (and indeed would likely provide more useful information)?
It seems to me that
private_macro_useshould be kept internal to rustc to keep the rustc developers in check about what private macros they might be inadvertently exporting, and should, if made public, be totally optional.Look at
num-bigint-digcrate, which is used byrsaand others. It will soon no longer compile without a patch because of this lint, especially if it is changed to deny by default. I forked and cloned that crate, and could not get this lint to show oncargo checkusing any combination of flags on that crate.This will raise random errors all over the place in any crate that uses even public macros such as
vec![]that do notpub use alloc::vec, etc. This is just a major disaster waiting to happen. Please fix it. Take this back to the drawing board and make it:vec![]is public by definition);-Aprivate-macro-userustc flag or#![allow(Aprivate_macro_use)]directive, because this will raise warnings everywhere.tokarevart commentedon Sep 19, 2025
Just upgraded to newest nightly and also got the warning mentioning
num-bigint-dig. For now, until this warning works correctly, I've suppressed all future incompat warnings by putting the following in.cargo/config.tomlin my projectdocs: update changelog and document known issues for 2.1.3 release
1 remaining item
Update outdated dependencies (zed-industries#42611)
xtqqczze commentedon Dec 3, 2025
This has since been fixed in
num-bigint-digv0.8.6.chore: Update num-bigint-dig to 0.8.6 to fix future incompatibility w…
fix: Filter terminal escape sequence responses in PTY sessions (#77)
Rollup merge of #143929 - petrochenkov:depresolve, r=lcnr
fix: Update internal dependency to remove future incompatibilities
core: address warning about private macro usage
core: Address warning about private macro usage (#270)
bump num-bigint-dig 0.8.4 → 0.8.6 to fix future rust incompatibility
Update outdated dependencies (#42611)
[deps] Bump num-bigint-dig 0.8.4 -> 0.8.6
[deps] Bump num-bigint-dig 0.8.4 -> 0.8.6
[deps] Bump num-bigint-dig 0.8.4 -> 0.8.6
build(deps): bump num-bigint-dig 0.8.4 → 0.8.6 to clear a future-inco…
Update outdated dependencies (zed-industries#42611)