Skip to content

Shift no characters when using raw string literals - #104193

Merged
bors merged 1 commit into
rust-lang:masterfrom
TaKO8Ki:fix-104142
Nov 16, 2022
Merged

Shift no characters when using raw string literals#104193
bors merged 1 commit into
rust-lang:masterfrom
TaKO8Ki:fix-104142

Conversation

@TaKO8Ki

Copy link
Copy Markdown
Member

Fixes#104142

Given the following code:

fnmain(){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.

@rustbot

Copy link
Copy Markdown
Collaborator

r? @cjgillot

(rustbot has picked a reviewer for you, use r? to override)

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 9, 2022
Comment threadcompiler/rustc_parse_format/src/lib.rs Outdated
Comment threadcompiler/rustc_parse_format/src/lib.rs Outdated
Comment threadcompiler/rustc_parse_format/src/lib.rs Outdated
remove `find_skips`
remove unnecessary variables
@cjgillot

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Nov 15, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit 9857de2 has been approved by cjgillot

It is now in the queue for this repository.

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 15, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 16, 2022
Shift no characters when using raw string literals
Fixesrust-lang#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.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 16, 2022
Shift no characters when using raw string literals
Fixesrust-lang#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.
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 16, 2022
…iaskrgr
Rollup of 10 pull requests
Successful merges:
- rust-lang#103484 (Add `rust` to `let_underscore_lock` example)
- rust-lang#103489 (Make `pointer::byte_offset_from` more generic)
- rust-lang#104193 (Shift no characters when using raw string literals)
- rust-lang#104348 (Respect visibility & stability of inherent associated types)
- rust-lang#104401 (avoid memory leak in mpsc test)
- rust-lang#104419 (Fix test/ui/issues/issue-30490.rs)
- rust-lang#104424 (rustdoc: remove no-op CSS `.popover { font-size: 1rem }`)
- rust-lang#104425 (rustdoc: remove no-op CSS `.main-header { justify-content }`)
- rust-lang#104450 (Fuchsia test suite script fix)
- rust-lang#104471 (Update PROBLEMATIC_CONSTS in style.rs)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 88a1919 into rust-lang:masterNov 16, 2022
@rustbotrustbot added this to the 1.67.0 milestone Nov 16, 2022
@TaKO8Ki
TaKO8Ki deleted the fix-104142 branch November 17, 2022 00:52
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error in raw string

4 participants

@TaKO8Ki@rustbot@cjgillot@bors