Skip to content

Weird help message suggest to place use randomly, when a macro is called in scope #42548

Closed
@kennytm

Description

@kennytm

Repro case (1.19.0-beta.1 as well as nightly):

macro_rules! y {
    () => {}
}
mod m {
    pub const A: i32 = 0;
}
fn main() {
    y!();
    let _ = A;
}

When running it in nightly, it produces a weird error message:

error[E0425]: cannot find value `A` in this scope
 --> 1.rs:9:13
  |
9 |     let _ = A;
  |             ^ not found in this scope
  |
help: possible candidate is found in another module, you can import it into scope
  | fn main() use m::A;

error: aborting due to previous error(s)
No repro on 1.18 or before
error[E0425]: cannot find value `A` in this scope
 --> <source>:9:13
  |
9 |     let _ = A;
  |             ^ not found in this scope
  |
  = help: possible candidate is found in another module, you can import it into scope:
            `use m::A;`
error: aborting due to previous error
Version
rustc 1.19.0-nightly (f062832b2 2017-06-07)
binary: rustc
commit-hash: f062832b208e94f2f0f26ed7fb5c48c172069fbe
commit-date: 2017-06-07
host: x86_64-apple-darwin
release: 1.19.0-nightly
LLVM version: 4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions