Skip to content

E0364: Bad output for macros/no explanation of #[macro_export] #97628

Closed
@halvko

Description

@halvko

Given the following code: playground

macro_rules! foo {
    () => {};
}
pub use foo;

The current output is:

error[[E0364]](https://doc.rust-lang.org/stable/error-index.html#E0364): `foo` is only public within the crate, and cannot be re-exported outside
 --> src/lib.rs:4:9
  |
4 | pub use foo;
  |         ^^^
  |
note: consider marking `foo` as `pub` in the imported module
 --> src/lib.rs:4:9
  |
4 | pub use foo;
  |         ^^^

Ideally the output should probably look like:

error[[E0364]](https://doc.rust-lang.org/stable/error-index.html#E0364): `foo` is only public within the crate, and cannot be re-exported outside
 --> src/lib.rs:4:9
  |
4 | pub use foo;
  |         ^^^
  |
note: consider marking `foo` as `#[macro_export]`
 --> src/lib.rs:4:9
  | 
  | #[macro_export]
1 | macro_rules! foo {
  | 

This error does not help explain how to fix it. In addition to explaining #[macro_export], pub(crate) use foo; could also be shown, so the user can decide what they wanted to do.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-papercutDiagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions