Repository navigation
types: add compact-errors feature - #1064
benma-agent wants to merge 1 commit into
Conversation
Let size-sensitive applications omit fragment strings from type-checking errors so otherwise unused fragment-formatting code can be removed from the binary. Add an opt-in compact-errors feature that leaves Error::fragment_string empty while preserving ErrorKind and all parsing and validation behavior. Reuse the existing error wrapper for threshold errors so both paths follow the same feature setting. Display still includes the error reason with an empty fragment; detailed diagnostics remain the default. Assisted-by: OpenAI Codex (GPT-6)
|
We use this dep in the BitBox02 firmware and would appreciate this (or something similar) being included, as it would significantly reduce binary size. |
|
Yeah, I think this is fine. Does it really reduce your binary size though? It just removes a runtime descriptor serialization. |
Yes, it reduces the binary size by about 6.3kb (Rust 1.96.0, From the agent:
|
|
Yeah, my guess was that this was eliminating the only callsite to So, this seems pretty fragile. Like, if anybody formats a descriptor anywhere in your codebase then the formatting code would be reintroduced and the feature gate would be negated. A better approach might be to directly feature-gate the formatting logic. But then, I wonder if the formatting logic is the best target. It seems like there are lots of "big algorithms" in this codebase and different users might like to avoid different subsets of them. |
Let size-sensitive applications omit fragment strings from type-checking
errors so otherwise unused fragment-formatting code can be removed from
the binary.
Add an opt-in compact-errors feature that leaves Error::fragment_string
empty while preserving ErrorKind and all parsing and validation behavior.
Reuse the existing error wrapper for threshold errors so both paths follow
the same feature setting. Display still includes the error reason with an
empty fragment; detailed diagnostics remain the default.
Assisted-by: OpenAI Codex (GPT-6)