String literals in asm!() and ABIs are not escaped #60493
Labels
A-frontend
Area: Compiler frontend (errors, parsing and HIR)
A-grammar
Area: The grammar of Rust
A-inline-assembly
Area: Inline assembly (`asm!(…)`)
C-bug
Category: This is a bug.
P-low
Low priority
requires-nightly
This issue requires a nightly compiler in some way.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
String literals in
asm!()
's outputs, inputs, clobbers and options are lexed like usual non-raw strings (asm!("something" : "outputs" : "inputs" : "clobbers" : "options")
).String literals in ABI specifications are also lexed like usual non-raw strings (
extern "C" fn f();
).In particular, all escapes are checked for correctness and corresponding errors are reported.
However, during parsing strings from those literals are directly transplanted into AST.
Directly means all those sweet
\r\n
s are preserved, that's even raw-er than raw string literals!That's not good.
Proposed solutions:
That would mean
extern "\x43" fn f();
being legal code.This is slightly weird, but
extern r#"C"# fn f() {}
is already accepted, if we are talking about weird.This is slightly weird because lexing errors about escaping make no sense if the escaping is not even used.
I tend to prefer the first alternative for simplicity/consistency -
"..."
means non-raw,r"..."
means raw, end of the story.The text was updated successfully, but these errors were encountered: