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

When a macro isn't found, suggest calling a function with the same name #103112

Closed
jruderman opened this issue Oct 16, 2022 · 1 comment · Fixed by #103140
Closed

When a macro isn't found, suggest calling a function with the same name #103112

jruderman opened this issue Oct 16, 2022 · 1 comment · Fixed by #103140
Assignees
Labels
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.

Comments

@jruderman
Copy link
Contributor

jruderman commented Oct 16, 2022

Given the following code (playground):

fn main() {
    std::process::abort!();
}

The current output is:

error[E0433]: failed to resolve: could not find `abort` in `process`
 --> src/main.rs:2:19
  |
2 |     std::process::abort!();
  |                   ^^^^^ could not find `abort` in `process`

For more information about this error, try `rustc --explain E0433`.

Ideally the output should include:

std::process::abort is not a macro

help: remove `!` to call the function

Motivation

Note that the opposite mistake, trying to use a macro without the !:

fn main() {
    println("Hello")
}

gives:

error[E0423]: expected function, found macro `println`
 --> src/main.rs:2:5
  |
2 |     println("Hello")
  |     ^^^^^^^ not a function
  |
help: use `!` to invoke the macro
  |
2 |     println!("Hello")
  |            +

For more information about this error, try `rustc --explain E0423`.

Related issues

This would complement #102601 (suggesting alternative paths when a macro isn't found)

@jruderman jruderman 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. labels Oct 16, 2022
@chenyukang
Copy link
Member

@rustbot claim

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Oct 23, 2022
…tebank

Add diagnostic for calling a function with the same name with unresolved Macro

Fixes rust-lang#103112
notriddle added a commit to notriddle/rust that referenced this issue Oct 23, 2022
…tebank

Add diagnostic for calling a function with the same name with unresolved Macro

Fixes rust-lang#103112
@bors bors closed this as completed in 1225c3f Oct 24, 2022
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 T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants