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

Compiler suggests use of non-existent macro #57588

Closed
jethrogb opened this issue Jan 14, 2019 · 5 comments
Closed

Compiler suggests use of non-existent macro #57588

jethrogb opened this issue Jan 14, 2019 · 5 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)

Comments

@jethrogb
Copy link
Contributor

I'm quite puzzled by the compiler guidance here:

use std::env;

fn main() {
    env::vav_os("PATH");
}
error[E0423]: expected function, found macro `env::vav_os`
 --> src/main.rs:4:5
  |
4 |     env::vav_os("PATH");
  |     ^^^^^------
  |     |    |
  |     |    did you mean `var_os`?
  |     did you mean `env::vav_os!(...)`?

Why does it think env::vav_os is a macro?

@jethrogb jethrogb changed the title expected function, found macro Compiler suggests use of non-existent macro Jan 14, 2019
@Centril Centril added A-diagnostics Area: Messages for errors, warnings, and lints A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) labels Jan 14, 2019
@Centril
Copy link
Contributor

Centril commented Jan 14, 2019

r? @estebank

@petrochenkov
Copy link
Contributor

Duplicate of #47361, diagnostics check whether the first segment of the path is a macro, and it its (env!(...)).

@petrochenkov
Copy link
Contributor

Suggestions for macros were written before all the macro modularization reforms.

@jethrogb
Copy link
Contributor Author

This can be closed as a duplicate if the description of #47361 is updated to be more generic.

@estebank
Copy link
Contributor

estebank commented May 7, 2019

Current output:

error[E0423]: expected function, found macro `env::vav_os`
 --> src/main.rs:4:5
  |
4 |     env::vav_os("PATH");
  |     ^^^^^^^^^^^
help: a function with a similar name exists
  |
4 |     env::var_os("PATH");
  |          ^^^^^^
help: use `!` to invoke the macro
  |
4 |     env::vav_os!("PATH");
  |     ^^^^^^^^^^^^

Closing as duplicate of #47361.

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, ..)
Projects
None yet
Development

No branches or pull requests

4 participants