Skip to content

Tracking Issue for private_macro_use lint #120192

Open

Description

@bvanjoi

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.rs
macro_rules! foo_ { () => {} };
use foo_ as foo;

// code.rs
#[macro_use]
extern crate extern_macro;

fn main() {
    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.

Steps

Activity

  1. added
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    on Jan 21, 2024
  2. added a commit that references this issue on Jul 14, 2025
  3. added 6 commits that reference this issue on Aug 6, 2025
  4. added a commit that references this issue on Aug 7, 2025
  5. tgrushka commented on Aug 30, 2025

    @tgrushka

    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:

    1. not lint on any public macros (clearly it doesn't respect this rule, because vec![] is public by definition);
    2. lint on the offending crate as well as in any downstream crate (currently does not lint at all on the offending crate);
    3. 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.
  6. tokarevart commented on Sep 19, 2025

    @tokarevart

    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

    [future-incompat-report]
    frequency = "never"
  7. 1 remaining item

  8. xtqqczze commented on Dec 3, 2025

    @xtqqczze
    Contributor

    Just upgraded to newest nightly and also got the warning mentioning num-bigint-dig.

    This has since been fixed in num-bigint-dig v0.8.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions