Skip to content

Raw Byte strings do not handle \r #60604

Closed
@matklad

Description

@matklad

Everywhere in the language we treat \r\n as \n, and forbid bare \r. In particular, in raw strings we do translate \r\n to \n, which makes sense, given that line ending depends on git config.

However, for raw byte string literals we don't do this, and this looks like a bug?

16:22:13|~/tmp
λ echo -e "fn main() {\n    let (s1, s2) = (br\"\r\", br\"\r\n\");\n    println!(\"{:?} {:?}\", s1, s2);\n}" > main.rs

16:25:49|~/tmp
λ rustc main.rs

16:25:50|~/tmp
λ ./main
[13] [13, 10]

Metadata

Metadata

Assignees

Labels

A-parserArea: The lexing & parsing of Rust source code to an AST

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions