Skip to content
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

Suggest importing macros from crate roots #59764

Closed
varkor opened this issue Apr 7, 2019 · 0 comments · Fixed by #59784
Closed

Suggest importing macros from crate roots #59764

varkor opened this issue Apr 7, 2019 · 0 comments · Fixed by #59784
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`

Comments

@varkor
Copy link
Member

varkor commented Apr 7, 2019

Consider a directory for a crate mycrate:

src
	- lib.rs
	- foo.rs

foo.rs declares a macro_rules! makro macro and #[macro_export]s it.

In a separate crate, a user writes:

use mycrate::foo::makro; // error: cannot find macro `makro!` in this scope

This is because #[macro_export] exports the macro in the crate root rather than the module in which it is defined.

It's very difficult to debug this if you're not aware of this behaviour. It would be really helpful to have a suggestion to replace the suggestion with use mycrate::makro;, or have a message saying that makro exists in mycrate (ideally with some background information describing the problem).

@varkor varkor added A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` labels Apr 7, 2019
@davidtwco davidtwco self-assigned this Apr 7, 2019
Centril added a commit to Centril/rust that referenced this issue Apr 13, 2019
Centril added a commit to Centril/rust that referenced this issue Apr 13, 2019
Centril added a commit to Centril/rust that referenced this issue Apr 13, 2019
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-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants