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

Correctly handle string indices in literal_string_with_formatting_arg #13841

Conversation

GuillaumeGomez
Copy link
Member

Fixes #13838.

r? @klensy

changelog: Correctly handle string indices in literal_string_with_formatting_arg

@rustbot
Copy link
Collaborator

rustbot commented Dec 16, 2024

Failed to set assignee to klensy: invalid assignee

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 16, 2024
@GuillaumeGomez
Copy link
Member Author

r?

@rustbot
Copy link
Collaborator

rustbot commented Dec 16, 2024

Error: Parsing assign command in comment failed: ...'' | error: specify user to assign to at >| ''...

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

@GuillaumeGomez
Copy link
Member Author

Ah funny, I thought it would reroll. Oh well.

r? clippy

current = &current[error.span.end + 1..];
let mut pos = 0;
// We find the closest char to where the error location ends.
for (char_pos, _) in current.char_indices() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first thought was to use ceil_char_boundary, also is_char_boundary exists. Any reason to not use them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know they existed. :o

Thanks!

@GuillaumeGomez GuillaumeGomez force-pushed the fix-literal_string_with_formatting_arg-str-indices branch from 5f27365 to ad695da Compare December 16, 2024 16:06
@flip1995 flip1995 added this pull request to the merge queue Dec 16, 2024
Copy link
Member

@flip1995 flip1995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

TIL about floor_char_boundary.

@GuillaumeGomez
Copy link
Member Author

Welcome to the club! \o/

Merged via the queue into rust-lang:master with commit 77c9ddd Dec 16, 2024
9 checks passed
@klensy
Copy link
Contributor

klensy commented Dec 16, 2024

Once again i avoided ?r, nice.

Btw, this one was found while i run clippy over r-a, so expect more reports until rust sync.

@GuillaumeGomez GuillaumeGomez deleted the fix-literal_string_with_formatting_arg-str-indices branch December 16, 2024 16:32
@GuillaumeGomez
Copy link
Member Author

It's very welcome, thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

literal_string_with_formatting_args ices on {…}
5 participants