Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up[RFC] Allow for crates to define their own fmt or disable it #247
Comments
sajattack
changed the title
[RFC] Allow for crates to define their own fmt/disable it
[RFC] Allow for crates to define their own fmt or disable it
Nov 4, 2018
This comment has been minimized.
This comment has been minimized.
|
As written I don't think this would work in practice.
This breaks functionality.
The panic handler is a terminator and most applications won't rely on it having a specific behavior for their functionality (with the exception of the
cc @nagisa who probably have some thoughts about ^
Why is alloc a problem and not core? core contains fmt::Debug and fmt::Display implementations for (almost) all the types defined in it as well as for all primitives. Most of these won't make it to the final binary because the linker will discard everything not referenced by the application.
If you are not using |
This comment has been minimized.
This comment has been minimized.
|
I was compiling in release mode and my binary wound up with core::fmt, the only place I could figure it was coming from was core::fmt::Debug/Display in alloc::boxed::Box ¯\_(ツ)_/¯ |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@sajattack you may want to run cargo-call-stack on your program to see what's calling the fmt stuff. @jonas-schievink that sounds more reasonable. I personally keep hearing this "trait objects make your code small / inlining bloats your code" mantra even though all my no_std experience indicates the contrary so I would like to see a Cargo.toml option along the lines of |
This comment has been minimized.
This comment has been minimized.
|
@japaric I get this error with cargo call-stack
|
This comment has been minimized.
This comment has been minimized.
|
@sajattack please file a bug report in the issue tracker |
sajattack commentedNov 4, 2018
Similar to the panic_fmt of old, which allowed us to provide our own implementations of what to do when panicking, I think we should be able to have our own formatters, and especially to be able to provide an empty fmt, for crates like alloc that use fmt::Display, fmt::Debug, everywhere. Most of the time we have nowhere to display anything so having this huge dependency is a waste.