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

Weird error message for missing symbol if module name is the same as a macro #40788

Open
tbu- opened this issue Mar 24, 2017 · 1 comment
Open
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-resolve Area: Path resolution C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tbu-
Copy link
Contributor

tbu- commented Mar 24, 2017

mod format {
    mod sub {
        pub fn foobar() { }
    }
}

fn main() {
    format::foobar();
}
$ rustc a.rs
error[E0423]: expected function, found macro `format::foobar`
 --> a.rs:8:5
  |
8 |     format::foobar();
  |     ^^^^^^^^^^^^^^ did you mean `format::foobar!(...)`?
  |
  = help: possible better candidate is found in another module, you can import it into scope:
            `use format::sub::foobar;`

error: aborting due to previous error
$ rustc --version
rustc 1.17.0-nightly (134c4a0f0 2017-03-20)

The weird thing is "expected function, found macro". format::foobar doesn't look like a macro. This also happens without the submodule sub (i.e. with an empty module format), the only difference is that no other candidate is suggested.

@petrochenkov petrochenkov added A-diagnostics Area: Messages for errors, warnings, and lints A-resolve Area: Path resolution A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) labels Mar 24, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 26, 2017
@antoyo
Copy link
Contributor

antoyo commented Jan 17, 2018

I got a similar error with this code:

mod file {
}

fn main() {
    file::create();
}

The error is:

error[E0423]: expected function, found macro `file::create`
 --> src/main.rs:5:5
  |
5 |     file::create();
  |     ^^^^^^^^^^^^ did you mean `file::create!(...)`?

@crlf0710 crlf0710 added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 11, 2020
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 A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-resolve Area: Path resolution C-enhancement Category: An issue proposing an enhancement or a PR with one. 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

5 participants