Skip to content

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

Closed
@jruderman

Description

@jruderman

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)

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions