Skip to content

Suggest importing macros from crate roots #59764

Closed
@varkor

Description

@varkor

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).

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions