Repository navigation
impl fmt::Display for u32 compiles to large binary #118940
Copy link
Copy link
Open
Labels
C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchI-heavyIssue: Problems and improvements with respect to binary size of generated code.Issue: Problems and improvements with respect to binary size of generated code.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
Activity
- addedneeds-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triagingThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
on Dec 14, 2023 - addedI-heavyIssue: Problems and improvements with respect to binary size of generated code.Issue: Problems and improvements with respect to binary size of generated code.
on Dec 14, 2023 - removedneeds-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triagingThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
on Dec 16, 2023 - addedT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.and removedT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
on Dec 17, 2023 At present, both
{}and (e.g.){:06}pass the integer toArgument::new_display, which returns a pointer toDisplay::fmtunconditionally.new_displaydoesn't see whether this has extra flags or not so it has no opportunity to return a simplified formatting function. You would have to changeformat_argsto givenew_displayvisibility of thePlaceholderstruct to allow a specialized formatting function to be returned instead. (Edit: anew_simple_displaywas tried in #104525 but not merged, with tracking issue #99012.)- addedC-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing such
on Feb 14, 2025
Metadata
Metadata
Assignees
Labels
C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchI-heavyIssue: Problems and improvements with respect to binary size of generated code.Issue: Problems and improvements with respect to binary size of generated code.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
My target is
wasm32-unknown-unknownbut I think it can be applied to any embedded systems. I just want to define panic handler, but formattingcore::panic::Locationcosts amlost 3 KiB in binary. This is because inefficientimpl Display for u32. Also see: https://github.com/dtolnay/itoaThis is mostly because this line:
rust/library/core/src/fmt/num.rs
Line 277 in 1aa6aef
Could we have something like specialization for more simpler
impl Display for $num?