Skip to content

Misleading error in println!/format! invocation #13876

Closed
@yuriks

Description

@yuriks

The expression println!(format!("test")) produces the following error:

<anon>:18:18: 18:24 error: macro undefined: 'format'
<anon>:18         println!(format!("test"))
                           ^~~~~~
<anon>:18:18: 18:33 error: format argument must be a string literal.
<anon>:18         println!(format!("test"))
                           ^~~~~~~~~~~~~~~
error: aborting due to 2 previous errors

The macro undefined: 'format' error is pretty misleading, implying that the user mispelled format! or that it has a different name, but in reality it's just complaining because you're supposed to pass a literal to println!. Why does this error get generated and is there a way to make it clearer?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions