-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #104193 - TaKO8Ki:fix-104142, r=cjgillot
Shift no characters when using raw string literals Fixes #104142 Given the following code: ```rust fn main() { println!(r#"\'\'\'\'\'\'\'\'\'\'\'\'\'\'}"#); } ``` The current output is: ``` error: invalid format string: unmatched `}` found --> src/main.rs:2:59 | 2 | println!(r#"\'\'\'\'\'\'\'\'\'\'\'\'\'\'}"#); //~ ERROR invalid format string: unmatched `}` found | ^ unmatched `}` in format string | = note: if you intended to print `}`, you can escape it using `}}` error: could not compile `debug_playground` due to previous error ``` The output should look like: ``` error: invalid format string: unmatched `}` found --> src/main.rs:2:45 | 2 | println!(r#"\'\'\'\'\'\'\'\'\'\'\'\'\'\'}"#); //~ ERROR invalid format string: unmatched `}` found | ^ unmatched `}` in format string | = note: if you intended to print `}`, you can escape it using `}}` error: could not compile `debug_playground` due to previous error ``` This pull request fixes the wrong span for `invalid format string` error and also solves the ICE.
- Loading branch information
Showing
5 changed files
with
103 additions
and
76 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,3 @@ | ||
fn main() { | ||
println!(r#"\'\'\'\'\'\'\'\'\'\'\'\'\'\'}"#); //~ ERROR invalid format string: unmatched `}` found | ||
} |
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,10 @@ | ||
error: invalid format string: unmatched `}` found | ||
--> $DIR/format-raw-string-error.rs:2:45 | ||
| | ||
LL | println!(r#"\'\'\'\'\'\'\'\'\'\'\'\'\'\'}"#); | ||
| ^ unmatched `}` in format string | ||
| | ||
= note: if you intended to print `}`, you can escape it using `}}` | ||
|
||
error: aborting due to previous error | ||
|
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,6 @@ | ||
fn main() { | ||
println!( | ||
r#" | ||
\"\'}、"# //~ ERROR invalid format string: unmatched `}` found | ||
); | ||
} |
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,10 @@ | ||
error: invalid format string: unmatched `}` found | ||
--> $DIR/issue-104142.rs:4:9 | ||
| | ||
LL | \"\'}、"# | ||
| ^ unmatched `}` in format string | ||
| | ||
= note: if you intended to print `}`, you can escape it using `}}` | ||
|
||
error: aborting due to previous error | ||
|