You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
features: Switch no-assert-string feature to descriptive-errors
Replace DekuError::AssertionNoStr with DekuError::Assertion, in concert
with the deku_error!() macro. deku_error!() discards dynamic formatting
when the capability unavailable, usually due to feature selection.
Discarding the unique portion of error strings provides the compiler the
opportunity to coalesce string constants, reducing space required for
.rodata in the spirit of AssertionNoStr.
Introducing descriptive-errors and enabling it by default gives us a
couple of things:
- Maintains the current behaviour where `--features no-assert-string`
_isn't_ specified,
- What I feel is desirable behaviour if we pass --all-features to `cargo
build`, where the no-assert-string feature didn't, and
- The ability to control the error message behaviour (though alloc is
required for descriptive messages)
Demonstrating the impact on wcampbell0x2a/backhand, with
descriptive-errors enabled[^1] we have:
$ cargo build --release --features="deku/descriptive-errors"
Finished `release` profile [optimized] target(s) in 0.06s
$ bloaty -d sections target/release/unsquashfs-backhand | grep '[.]rodata$'
8.5% 530Ki 10.7% 530Ki .rodata
$ readelf --string-dump .rodata target/release/unsquashfs-backhand | grep --color=never --only-matching -E "Field failed assertion.{5}"
Field failed assertion: Dir
Field failed assertion: Sup
Field failed assertion: Sup
Field failed assertion: Sup
Field failed assertion: Ext
Field failed assertion: Bas
Field failed assertion: Dir
$
And without:
$ cargo build --release
Finished `release` profile [optimized] target(s) in 0.05s
$ bloaty -d sections target/release/unsquashfs-backhand | grep '[.]rodata$'
8.5% 529Ki 10.7% 529Ki .rodata
$ readelf --string-dump .rodata target/release/unsquashfs-backhand | grep --color=never --only-matching -E "Field failed assertion.{5}"
Field failed assertionevent
Field failed assertionCould
$
[^1]: For the purpose of clarity in the demonstration I temporarily
changed the patch such that descriptive-errors _isn't_ in the
default features
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
0 commit comments