-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make Size and Align debug-printing a bit more compact #96581
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
compiler/rustc_target/src/abi/mod.rs
Outdated
// This is debug-printed a lot in larger structs, don't waste too much space there | ||
impl fmt::Debug for Align { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!(f, "Align::from_bytes({})", self.bytes()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, this is not actually runnable code -- the result of from_bytes
needs to be unwrap
ed.
This comment has been minimized.
This comment has been minimized.
@@ -50,7 +50,7 @@ fn main() -> () { | |||
_6 = const "D"; // scope 0 at $DIR/uninhabited_enum_branching.rs:27:21: 27:24 | |||
// mir::Constant | |||
// + span: $DIR/uninhabited_enum_branching.rs:27:21: 27:24 | |||
// + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [68], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [1], len: Size { raw: 1 } }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) } | |||
// + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [68], relocations: Relocations(SortedMap { data: [] }), init_mask: InitMask { blocks: [1], len: Size::from_bytes(1) }, align: Align::from_bytes(1), mutability: Not, extra: () }, start: 0, end: 1 }) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow this looks terrible... I think we are better off just not printing all those details.^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In mir dumps, definitely, I'd be wary about the regular debug impls tho, as we want all that info in case we print it in tracing statements I'd think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's why in my last commit I changed MIR dumps, not the debug impls.
2810fc4
to
1bb0f50
Compare
This comment has been minimized.
This comment has been minimized.
All the usages I saw were redundantly listing the type name, when the field it was printed for was already obvious. Maybe just print |
r? @oli-obk |
Hm, I feel like debug output should be reasonably self-descriptive... I'll see how |
I find |
☔ The latest upstream changes (presumably #94775) made this pull request unmergeable. Please resolve the merge conflicts. |
Yeah I think it should say the type. I updated the PR accordingly. |
@bors r+ |
📌 Commit d455752 has been approved by |
make Size and Align debug-printing a bit more compact In particular in `{:#?}`-mode, these take up a lot of space, so I think this is the better alternative (even though it is a bit longer in `{:?}` mode, I think it is still more readable). We could make it even smaller by deviating further from what the actual code looks like, e.g. via something like `Size(4 bytes)`. Not sure what people would think about that? Cc `@oli-obk`
make Size and Align debug-printing a bit more compact In particular in `{:#?}`-mode, these take up a lot of space, so I think this is the better alternative (even though it is a bit longer in `{:?}` mode, I think it is still more readable). We could make it even smaller by deviating further from what the actual code looks like, e.g. via something like `Size(4 bytes)`. Not sure what people would think about that? Cc ``@oli-obk``
make Size and Align debug-printing a bit more compact In particular in `{:#?}`-mode, these take up a lot of space, so I think this is the better alternative (even though it is a bit longer in `{:?}` mode, I think it is still more readable). We could make it even smaller by deviating further from what the actual code looks like, e.g. via something like `Size(4 bytes)`. Not sure what people would think about that? Cc ```@oli-obk```
make Size and Align debug-printing a bit more compact In particular in `{:#?}`-mode, these take up a lot of space, so I think this is the better alternative (even though it is a bit longer in `{:?}` mode, I think it is still more readable). We could make it even smaller by deviating further from what the actual code looks like, e.g. via something like `Size(4 bytes)`. Not sure what people would think about that? Cc ````@oli-obk````
…laumeGomez Rollup of 7 pull requests Successful merges: - rust-lang#96581 (make Size and Align debug-printing a bit more compact) - rust-lang#96636 (Fix jump to def regression) - rust-lang#96760 (diagnostics: port more diagnostics to derive + add support for `Vec` fields) - rust-lang#96788 (Improve validator around field projections and checked bin ops) - rust-lang#96805 (Change eslint rules from configuration comments to configuration file) - rust-lang#96807 (update Miri) - rust-lang#96811 (Fix a minor typo in the description of Formatter) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
In particular in
{:#?}
-mode, these take up a lot of space, so I think this is the better alternative (even though it is a bit longer in{:?}
mode, I think it is still more readable).We could make it even smaller by deviating further from what the actual code looks like, e.g. via something like
Size(4 bytes)
. Not sure what people would think about that?Cc @oli-obk