Skip to content

Subpar span on multiline format string with unclosed brace #53837

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

Closed
estebank opened this issue Aug 30, 2018 · 0 comments
Closed

Subpar span on multiline format string with unclosed brace #53837

estebank opened this issue Aug 30, 2018 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@estebank
Copy link
Contributor

Given a format string with an unclosed opening brace, the span points to the next element where a closing brace is expected. If this happens in a multiline format string, the span might be pointing to the line after the problem, with no secondary span referencing the opening brace. Either modify the error to be about "unclosed opening brace" pointing at the opening brace or add a secondary span pointing at it.

Introduced in #52649. CC #53836.

@estebank estebank added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. A-diagnostics Area: Messages for errors, warnings, and lints and removed E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Aug 30, 2018
bors added a commit that referenced this issue Dec 27, 2018
Various changes to string format diagnostics

- Point at opening mismatched formatting brace
- Account for differences between raw and regular strings
- Account for differences between the code snippet and `InternedString`
- Add more tests

```
error: invalid format string: expected `'}'`, found `'t'`
  --> $DIR/ifmt-bad-arg.rs:85:1
   |
LL | ninth number: {
   |               - because of this opening brace
LL | tenth number: {}",
   | ^ expected `}` in format string
   |
   = note: if you intended to print `{`, you can escape it using `{{`
```

Fix #53837.
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
Projects
None yet
Development

No branches or pull requests

1 participant