Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect span produced when using encoded } #103826

Closed
cassaundra opened this issue Nov 1, 2022 · 1 comment · Fixed by #103828
Closed

Incorrect span produced when using encoded } #103826

cassaundra opened this issue Nov 1, 2022 · 1 comment · Fixed by #103828
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-fmt Area: `std::fmt` C-bug Category: This is a bug.

Comments

@cassaundra
Copy link
Contributor

The following code produces an incorrect span on nightly:

fn main() {
    format!("{\x7D");
}

Expected:

error: 1 positional argument in format string, but no arguments were given
 --> src/main.rs:2:14
  |
2 |     format!("{\x7D");
  |              ^^^^^

error: aborting due to previous error

Actual:

error: 1 positional argument in format string, but no arguments were given
 --> src/main.rs:2:14
  |
2 |     format!("{\x7D");
  |              ^^

error: aborting due to previous error

Meta

rustc --version --verbose:

rustc 1.67.0-nightly (95a3a7277 2022-10-31)
binary: rustc
commit-hash: 95a3a7277b44bbd2dd3485703d9a05f64652b60e
commit-date: 2022-10-31
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4

This was knowingly introduced as part of #102214. I have already fixed this, and will open a PR shortly.

@cassaundra cassaundra added the C-bug Category: This is a bug. label Nov 1, 2022
@cassaundra
Copy link
Contributor Author

@rustbot label +A-diagnostics +A-fmt

@rustbot rustbot added A-diagnostics Area: Messages for errors, warnings, and lints A-fmt Area: `std::fmt` labels Nov 1, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 26, 2022
…cjgillot

Fix incorrect span when using byte-escaped rbrace

Fix rust-lang#103826, a format args span issue introduced in rust-lang#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](rust-lang#102214 (comment)).
@bors bors closed this as completed in 35c7939 Dec 26, 2022
Aaron1011 pushed a commit to Aaron1011/rust that referenced this issue Jan 6, 2023
…cjgillot

Fix incorrect span when using byte-escaped rbrace

Fix rust-lang#103826, a format args span issue introduced in rust-lang#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](rust-lang#102214 (comment)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-fmt Area: `std::fmt` C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants