-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #103828 - cassaundra:fix-format-args-span2, r=cjgillot
Fix incorrect span when using byte-escaped rbrace Fix #103826, a format args span issue introduced in #102214. The current solution for tracking skipped characters made it so that certain situations were ambiguous enough that the original span couldn't be worked out later. This PR improves on the original solution by keeping track of groups of skipped characters using a map, and fixes the previous bug. See an example of this ambiguity in the [previous PR's discussion](#102214 (comment)).
- Loading branch information
Showing
3 changed files
with
107 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
fn main() { | ||
format!("{\x7D"); | ||
//~^ ERROR 1 positional argument in format string, but no arguments were given | ||
format!("\x7B\x7D"); | ||
//~^ ERROR 1 positional argument in format string, but no arguments were given | ||
format!("{\x7D {\x7D"); | ||
//~^ ERROR 2 positional arguments in format string, but no arguments were given | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error: 1 positional argument in format string, but no arguments were given | ||
--> $DIR/issue-103826.rs:2:14 | ||
| | ||
LL | format!("{\x7D"); | ||
| ^^^^^ | ||
|
||
error: 1 positional argument in format string, but no arguments were given | ||
--> $DIR/issue-103826.rs:4:14 | ||
| | ||
LL | format!("\x7B\x7D"); | ||
| ^^^^^^^^ | ||
|
||
error: 2 positional arguments in format string, but no arguments were given | ||
--> $DIR/issue-103826.rs:6:14 | ||
| | ||
LL | format!("{\x7D {\x7D"); | ||
| ^^^^^ ^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|