Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
halvko opened this issue Jun 1, 2022 · 0 comments · Fixed by #98087
Closed

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

halvko opened this issue Jun 1, 2022 · 0 comments · Fixed by #98087
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@halvko
Copy link

halvko commented Jun 1, 2022

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.

@halvko halvko added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 1, 2022
@compiler-errors compiler-errors added A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. labels Jun 1, 2022
@TaKO8Ki TaKO8Ki self-assigned this Jun 13, 2022
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jun 14, 2022
…, r=oli-obk

Suggest adding a `#[macro_export]` to a private macro

fixes rust-lang#97628
@bors bors closed this as completed in b2d0e78 Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants