Skip to content

Reduce derived Debug impl binary size - #165195

Closed
Jules-Bertholet wants to merge 1 commit into
rust-lang:mainfrom
Jules-Bertholet:debug-size
Closed

Jules-Bertholet wants to merge 1 commit into
rust-lang:mainfrom
Jules-Bertholet:debug-size

Conversation

@Jules-Bertholet

@Jules-Bertholet Jules-Bertholet commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

str::split brings in a lot of code to handle multi-byte UTF-8 codepoints. Let's skip all that.

Fixes #165189. (I confirmed that @folkertdev's Godbolt example gets a lot smaller, but have not checked the original MSP430 reproducer.)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Oct 30, 2026
@rustbot

rustbot commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

r? @JohnTitor

rustbot has assigned @JohnTitor.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 37 candidates
  • Random selection from ChrisDenton, JohnTitor, Mark-Simulacrum, clarfonthey, hanna-kruppe

@Jules-Bertholet Jules-Bertholet changed the title Reduce Debug impl binary size Reduce derived Debug impl binary size Oct 30, 2026
names: &str,
start_index: usize,
) -> Result {
self.write_str(names[start_index..].split(' ').next().unwrap())

@panstromek panstromek Oct 30, 2026 •

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.

This one should be the cause of the issue. The ones above were added yesterday, after the regression was already there (they reported that it was introduced on 22 and 23 of October)

View changes since the review

Comment on lines 2499 to 2503
pub fn debug_struct_field1_finish<'b>(&'b mut self, names: &str, value1: &dyn Debug) -> Result {
let mut names = names.split(' ');
let mut names = split_str_by_space(names);
let mut builder = builders::debug_struct_new(self, names.next().unwrap());
builder.field(names.next().unwrap(), value1);
builder.finish()

@panstromek panstromek Oct 30, 2026 •

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.

Also just note that all those will be removed in #165140, which is in the queue atm.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Alright, closing in favor of my suggestions at #165140 (review). Maybe worth applying those and then resubmitting the PR to bors?

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 30, 2026
@Jules-Bertholet
Jules-Bertholet deleted the debug-size branch October 30, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Binary size regression on MSP430

4 participants