Skip to content

fix: make analysis-stats progress bar Unicode-safe - #22909

Merged
ChayimFriedman2 merged 1 commit into
rust-lang:masterfrom
AayushMainali-Github:fix/22844-unicode-progress-report
Jul 27, 2026
Merged

fix: make analysis-stats progress bar Unicode-safe#22909
ChayimFriedman2 merged 1 commit into
rust-lang:masterfrom
AayushMainali-Github:fix/22844-unicode-progress-report

Conversation

@AayushMainali-Github

@AayushMainali-Github AayushMainali-Github commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #22844

The analysis-stats progress bar compared byte lengths with character indices when updating its message. Non-ASCII identifiers such as 消息 made chars().nth(...).unwrap() panic.

Measure common prefixes and clear widths in Unicode scalar values instead, and add regression tests.

Test plan

  • cargo test -p rust-analyzer --lib cli::progress_report::
  • rustfmt --check crates/rust-analyzer/src/cli/progress_report.rs
  • cargo clippy -p rust-analyzer --lib -- -D warnings

AI disclosure: Assisted by Cursor (Grok).

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 25, 2026
@rustbot

This comment has been minimized.

@ChayimFriedman2

Copy link
Copy Markdown
Contributor

Please note that our AI policy disallows using AI to write GitHub comments or PR descriptions.

@ChayimFriedman2 ChayimFriedman2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The only change necessary is to change len() to chars().count() where it appears.

View changes since this review

@AayushMainali-Github

Copy link
Copy Markdown
Contributor Author

The only change necessary is to change len() to chars().count() where it appears.

View changes since this review

sure will do

@AayushMainali-Github
AayushMainali-Github force-pushed the fix/22844-unicode-progress-report branch from c2762aa to 5c7381c Compare July 27, 2026 18:34

@ChayimFriedman2 ChayimFriedman2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

chars().count() is O(N), please save it in (two) variables.

View changes since this review

@AayushMainali-Github

Copy link
Copy Markdown
Contributor Author

chars().count() is O(N), please save it in (two) variables.

View changes since this review

done!

@ChayimFriedman2 ChayimFriedman2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please squash. Also, why did you remove the tests you added?

View changes since this review

@AayushMainali-Github

Copy link
Copy Markdown
Contributor Author

Please squash. Also, why did you remove the tests you added?

View changes since this review

I thought the only change required was to just convert len() to chars().count(), should I add the tests back?

@AayushMainali-Github
AayushMainali-Github force-pushed the fix/22844-unicode-progress-report branch from 79e117f to e5197b0 Compare July 27, 2026 18:54
@AayushMainali-Github

Copy link
Copy Markdown
Contributor Author

squashed and added tests back (all are passing locally)

@ChayimFriedman2 ChayimFriedman2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ChayimFriedman2
ChayimFriedman2 added this pull request to the merge queue Jul 27, 2026
Merged via the queue into rust-lang:master with commit 0a032f2 Jul 27, 2026
18 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

panic when code uses none-ascii identifiers which are referenced in progress printing

3 participants