Rollup merge of #81071 - osa1:fix_81006, r=estebank
rustc_parse_format: Fix character indices in find_skips Fixes #81006
This commit is contained in:
commit
c7ca540da2
@ -736,7 +736,7 @@ fn find_skips_from_snippet(
|
||||
|
||||
fn find_skips(snippet: &str, is_raw: bool) -> Vec<usize> {
|
||||
let mut eat_ws = false;
|
||||
let mut s = snippet.chars().enumerate().peekable();
|
||||
let mut s = snippet.char_indices().peekable();
|
||||
let mut skips = vec![];
|
||||
while let Some((pos, c)) = s.next() {
|
||||
match (c, s.peek()) {
|
||||
|
10
src/test/ui/macros/issue-81006.rs
Normal file
10
src/test/ui/macros/issue-81006.rs
Normal file
@ -0,0 +1,10 @@
|
||||
// check-fail
|
||||
|
||||
// First format below would cause a panic, second would generate error with incorrect span
|
||||
|
||||
fn main() {
|
||||
let _ = format!("→{}→\n");
|
||||
//~^ ERROR 1 positional argument in format string, but no arguments were given
|
||||
let _ = format!("→{} \n");
|
||||
//~^ ERROR 1 positional argument in format string, but no arguments were given
|
||||
}
|
14
src/test/ui/macros/issue-81006.stderr
Normal file
14
src/test/ui/macros/issue-81006.stderr
Normal file
@ -0,0 +1,14 @@
|
||||
error: 1 positional argument in format string, but no arguments were given
|
||||
--> $DIR/issue-81006.rs:6:23
|
||||
|
|
||||
LL | let _ = format!("→{}→\n");
|
||||
| ^^
|
||||
|
||||
error: 1 positional argument in format string, but no arguments were given
|
||||
--> $DIR/issue-81006.rs:8:23
|
||||
|
|
||||
LL | let _ = format!("→{} \n");
|
||||
| ^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
Loading…
Reference in New Issue
Block a user