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

Incorrect hint for decl_macro import. #88636

Open
crlf0710 opened this issue Sep 4, 2021 · 2 comments
Open

Incorrect hint for decl_macro import. #88636

crlf0710 opened this issue Sep 4, 2021 · 2 comments
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@crlf0710
Copy link
Member

crlf0710 commented Sep 4, 2021

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.

@crlf0710 crlf0710 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. requires-nightly This issue requires a nightly compiler in some way. labels Sep 4, 2021
@FabianWolff
Copy link
Contributor

@rustbot claim

This is not quite fixed by #88838 yet, but I have a patch that should solve this. Since the patch is based on #88838, I'll wait until that PR is merged before opening a PR for this issue.

@camelid
Copy link
Member

camelid commented Oct 20, 2021

triage: #88838 has merged now.

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 requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants