Skip to content

println!, eprintln! and writeln! accept other literals not just format strings #30143

Closed
@ollie27

Description

@ollie27

The following all compile and run for example:

println!(0);
writeln!(b, true);
println!('a');

I would expect them to produce "error: format argument must be a string literal." like print!(0); does.

This is because they use things like concat!($fmt, "\n") but concat! accepts other literals not just str.

I assume this isn't intentional.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)T-libs-apiRelevant to the library API 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