Code
fn main() {
println!(
"fn main() {\n\
\n\
}"
);
}
Current output
error: 1 positional argument in format string, but no arguments were given
--> src/main.rs:3:20
|
3 | "fn main() {\n\
| ____________________^
4 | | \n\
5 | | }"
| |_________^
Desired output
The above, followed by
= note: if you intended to print `{`, you can escape it using `{{`
Rationale and extra context
It’s not necessarily obvious that the problem is unescaped braces, in this situation. The proposed note (which already exists for other cases) should, in my opinion, be included in the error whenever there is any kind of whitespace within the braces, which is unusual in correct code.
Other cases
println!(
"fn main() {\n\
println!();\n\
}"
);
println!(
"fn none() -> Option<()> {\n\
None\n\
}"
);
Rust Version
Anything else?
@rustbot label A-fmt
Code
Current output
Desired output
The above, followed by
Rationale and extra context
It’s not necessarily obvious that the problem is unescaped braces, in this situation. The proposed note (which already exists for other cases) should, in my opinion, be included in the error whenever there is any kind of whitespace within the braces, which is unusual in correct code.
Other cases
Rust Version
Anything else?
@rustbot label A-fmt