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

format! error has wrong span when using encoded { #102057

Closed
Nemo157 opened this issue Sep 20, 2022 · 3 comments · Fixed by #102214
Closed

format! error has wrong span when using encoded { #102057

Nemo157 opened this issue Sep 20, 2022 · 3 comments · Fixed by #102214
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-fmt Area: `std::fmt` C-bug Category: This is a bug.

Comments

@Nemo157
Copy link
Member

Nemo157 commented Sep 20, 2022

I tried this code:

format!("\x7Ba}")

I expected to see this happen: a "no value found" error pointing at the a token

Instead, this happened: a "no value found" error pointing at the x7Ba:

error[E0425]: cannot find value `a` in this scope
 --> src/main.rs:2:11
  |
2 | format!("\x7Ba}")
  |           ^^^^ not found in this scope
@Nemo157 Nemo157 added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. A-fmt Area: `std::fmt` labels Sep 20, 2022
@cassaundra
Copy link
Contributor

This doesn't seem to be an issue on stable, interestingly.

@Nemo157
Copy link
Member Author

Nemo157 commented Sep 21, 2022

Yep, it works fine on 1.63.0, but has the problem on 1.65.0-beta.1 and the latest nightly.

@cassaundra
Copy link
Contributor

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Sep 29, 2022
…=cjgillot

Fix span of byte-escaped left format args brace

Fix rust-lang#102057 (see issue for example).

Previously, the use of escaped left braces (`\x7B`) in format args resulted in an incorrectly offset span. This patch fixes that by considering any escaped characters within the string instead of using a constant offset.
notriddle added a commit to notriddle/rust that referenced this issue Sep 29, 2022
…=cjgillot

Fix span of byte-escaped left format args brace

Fix rust-lang#102057 (see issue for example).

Previously, the use of escaped left braces (`\x7B`) in format args resulted in an incorrectly offset span. This patch fixes that by considering any escaped characters within the string instead of using a constant offset.
@bors bors closed this as completed in e5096d4 Sep 29, 2022
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