Skip to content

Suggest importing macros from crate roots #59764

Closed

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

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
    A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`
    on Apr 7, 2019
  2. self-assigned this
    on Apr 7, 2019
  3. added 3 commits that reference this issue on Apr 13, 2019
    dbaf5fc
    ae90d8d
    c4a3332
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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