-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code
mod macros {
macro_rules! foo { () => {}; }
pub use foo;
}
Current output
error[E0364]: `foo` is only public within the crate, and cannot be re-exported outside
--> src/lib.rs:3:13
|
3 | pub use foo;
| ^^^
|
help: consider adding a `#[macro_export]` to the macro in the imported module
--> src/lib.rs:2:5
|
2 | macro_rules! foo { () => {}; }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Desired output
In addition to the current output:
help: or, if you want to use the macro within this crate only, reduce the visibility to `pub(crate)`
|
| pub(crate) use foo;
| ^^^^^^^^^^
Rationale and extra context
macro_rules!
export behavior is unique and weirdly restricted, and needs to be taught in more detail so users can write the program that is as close to what they actually want as possible.
Rust Version
1.89.0
Anything else?
@rustbot label +A-macros
Brayan-724Brayan-724
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.