Skip to content

Commit ed9df28

Browse files
committed
Fix ICE due to carriage return w/ multibyte char
Based off of kfitch@972560b
1 parent 45a83e9 commit ed9df28

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/librustc_parse_format/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ fn find_skips_from_snippet(
760760
(' ' | '\n' | '\t', _) if eat_ws => {
761761
skips.push(pos);
762762
}
763-
('\\', Some((next_pos, 'n' | 't' | '0' | '\\' | '\'' | '\"'))) => {
763+
('\\', Some((next_pos, 'n' | 't' | 'r' | '0' | '\\' | '\'' | '\"'))) => {
764764
skips.push(*next_pos);
765765
let _ = s.next();
766766
}

src/test/ui/issues/issue-70381.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Test that multi-byte unicode characters with missing parameters do not ICE.
2+
3+
fn main() {
4+
println!("\r¡{}")
5+
//~^ ERROR 1 positional argument in format string
6+
}

src/test/ui/issues/issue-70381.stderr

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: 1 positional argument in format string, but no arguments were given
2+
--> $DIR/issue-70381.rs:4:16
3+
|
4+
LL | println!("\r¡{}")
5+
| ^^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)