Skip to content

Incorrect hint for decl_macro import. #88636

Open
@crlf0710

Description

@crlf0710

In this program:

#![feature(decl_macro)]

mod foo1 {
    pub macro foo() {}
}

mod foo2 {
    pub macro bar() {
        foo!();
    }
   
}

mod foo3 {
    fn bar() {
        crate::foo2::bar!();
    }
    use crate::foo1::foo;
}

The compilation output is:

error: cannot find macro `foo` in this scope
  --> src/lib.rs:9:9
   |
9  |         foo!();
   |         ^^^
...
16 |         crate::foo2::bar!();
   |         -------------------- in this macro invocation
   |
   = note: consider importing this macro:
           crate::foo3::foo
   = note: this error originates in the macro `crate::foo2::bar` (in Nightly builds, run with -Z macro-backtrace for more info)

However the hint is wrong - crate::foo3::foo is inaccessible to foo2. The correct hint should be suggesting crate::foo1::foo.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions