Skip to content

Commit

Permalink
reorder fields in Laout debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jul 31, 2022
1 parent 98e52c2 commit abd80d9
Show file tree
Hide file tree
Showing 7 changed files with 927 additions and 926 deletions.
13 changes: 7 additions & 6 deletions compiler/rustc_target/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1279,13 +1279,14 @@ impl<'a> fmt::Debug for LayoutS<'a> {
// This is how `Layout` used to print before it become
// `Interned<LayoutS>`. We print it like this to avoid having to update
// expected output in a lot of tests.
let LayoutS { size, align, abi, fields, largest_niche, variants } = self;
f.debug_struct("Layout")
.field("fields", &self.fields)
.field("variants", &self.variants)
.field("abi", &self.abi)
.field("largest_niche", &self.largest_niche)
.field("align", &self.align)
.field("size", &self.size)
.field("size", size)
.field("align", align)
.field("abi", abi)
.field("fields", fields)
.field("largest_niche", largest_niche)
.field("variants", variants)
.finish()
}
}
Expand Down
242 changes: 121 additions & 121 deletions src/test/ui/layout/debug.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
error: layout_of(E) = Layout {
size: Size(12 bytes),
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: $PREF_ALIGN,
},
abi: Aggregate {
sized: true,
},
fields: Arbitrary {
offsets: [
Size(0 bytes),
Expand All @@ -7,6 +15,16 @@ error: layout_of(E) = Layout {
0,
],
},
largest_niche: Some(
Niche {
offset: Size(0 bytes),
value: Int(
I32,
false,
),
valid_range: 0..=0,
},
),
variants: Multiple {
tag: Initialized {
value: Int(
Expand All @@ -19,24 +37,30 @@ error: layout_of(E) = Layout {
tag_field: 0,
variants: [
Layout {
size: Size(4 bytes),
align: AbiAndPrefAlign {
abi: Align(1 bytes),
pref: $PREF_ALIGN,
},
abi: Aggregate {
sized: true,
},
fields: Arbitrary {
offsets: [],
memory_index: [],
},
largest_niche: None,
variants: Single {
index: 0,
},
abi: Aggregate {
sized: true,
},
largest_niche: None,
},
Layout {
size: Size(12 bytes),
align: AbiAndPrefAlign {
abi: Align(1 bytes),
abi: Align(4 bytes),
pref: $PREF_ALIGN,
},
size: Size(4 bytes),
},
Layout {
abi: Uninhabited,
fields: Arbitrary {
offsets: [
Size(4 bytes),
Expand All @@ -49,58 +73,24 @@ error: layout_of(E) = Layout {
2,
],
},
largest_niche: None,
variants: Single {
index: 1,
},
abi: Uninhabited,
largest_niche: None,
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: $PREF_ALIGN,
},
size: Size(12 bytes),
},
],
},
abi: Aggregate {
sized: true,
},
largest_niche: Some(
Niche {
offset: Size(0 bytes),
value: Int(
I32,
false,
),
valid_range: 0..=0,
},
),
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: $PREF_ALIGN,
},
size: Size(12 bytes),
}
--> $DIR/debug.rs:6:1
|
LL | enum E { Foo, Bar(!, i32, i32) }
| ^^^^^^

error: layout_of(S) = Layout {
fields: Arbitrary {
offsets: [
Size(0 bytes),
Size(0 bytes),
Size(4 bytes),
],
memory_index: [
1,
0,
2,
],
},
variants: Single {
index: 0,
size: Size(8 bytes),
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: $PREF_ALIGN,
},
abi: ScalarPair(
Initialized {
Expand All @@ -118,41 +108,72 @@ error: layout_of(S) = Layout {
valid_range: 0..=4294967295,
},
),
fields: Arbitrary {
offsets: [
Size(0 bytes),
Size(0 bytes),
Size(4 bytes),
],
memory_index: [
1,
0,
2,
],
},
largest_niche: None,
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: $PREF_ALIGN,
variants: Single {
index: 0,
},
size: Size(8 bytes),
}
--> $DIR/debug.rs:9:1
|
LL | struct S { f1: i32, f2: (), f3: i32 }
| ^^^^^^^^

error: layout_of(U) = Layout {
fields: Union(
2,
),
variants: Single {
index: 0,
size: Size(8 bytes),
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: $PREF_ALIGN,
},
abi: Aggregate {
sized: true,
},
fields: Union(
2,
),
largest_niche: None,
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: $PREF_ALIGN,
variants: Single {
index: 0,
},
size: Size(8 bytes),
}
--> $DIR/debug.rs:12:1
|
LL | union U { f1: (i32, i32), f3: i32 }
| ^^^^^^^

error: layout_of(std::result::Result<i32, i32>) = Layout {
size: Size(8 bytes),
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: $PREF_ALIGN,
},
abi: ScalarPair(
Initialized {
value: Int(
I32,
false,
),
valid_range: 0..=1,
},
Initialized {
value: Int(
I32,
true,
),
valid_range: 0..=4294967295,
},
),
fields: Arbitrary {
offsets: [
Size(0 bytes),
Expand All @@ -161,6 +182,16 @@ error: layout_of(std::result::Result<i32, i32>) = Layout {
0,
],
},
largest_niche: Some(
Niche {
offset: Size(0 bytes),
value: Int(
I32,
false,
),
valid_range: 0..=1,
},
),
variants: Multiple {
tag: Initialized {
value: Int(
Expand All @@ -173,16 +204,10 @@ error: layout_of(std::result::Result<i32, i32>) = Layout {
tag_field: 0,
variants: [
Layout {
fields: Arbitrary {
offsets: [
Size(4 bytes),
],
memory_index: [
0,
],
},
variants: Single {
index: 0,
size: Size(8 bytes),
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: $PREF_ALIGN,
},
abi: ScalarPair(
Initialized {
Expand All @@ -200,14 +225,6 @@ error: layout_of(std::result::Result<i32, i32>) = Layout {
valid_range: 0..=4294967295,
},
),
largest_niche: None,
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: $PREF_ALIGN,
},
size: Size(8 bytes),
},
Layout {
fields: Arbitrary {
offsets: [
Size(4 bytes),
Expand All @@ -216,8 +233,16 @@ error: layout_of(std::result::Result<i32, i32>) = Layout {
0,
],
},
largest_niche: None,
variants: Single {
index: 1,
index: 0,
},
},
Layout {
size: Size(8 bytes),
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: $PREF_ALIGN,
},
abi: ScalarPair(
Initialized {
Expand All @@ -235,56 +260,32 @@ error: layout_of(std::result::Result<i32, i32>) = Layout {
valid_range: 0..=4294967295,
},
),
fields: Arbitrary {
offsets: [
Size(4 bytes),
],
memory_index: [
0,
],
},
largest_niche: None,
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: $PREF_ALIGN,
variants: Single {
index: 1,
},
size: Size(8 bytes),
},
],
},
abi: ScalarPair(
Initialized {
value: Int(
I32,
false,
),
valid_range: 0..=1,
},
Initialized {
value: Int(
I32,
true,
),
valid_range: 0..=4294967295,
},
),
largest_niche: Some(
Niche {
offset: Size(0 bytes),
value: Int(
I32,
false,
),
valid_range: 0..=1,
},
),
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: $PREF_ALIGN,
},
size: Size(8 bytes),
}
--> $DIR/debug.rs:15:1
|
LL | type Test = Result<i32, i32>;
| ^^^^^^^^^

error: layout_of(i32) = Layout {
fields: Primitive,
variants: Single {
index: 0,
size: Size(4 bytes),
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: $PREF_ALIGN,
},
abi: Scalar(
Initialized {
Expand All @@ -295,12 +296,11 @@ error: layout_of(i32) = Layout {
valid_range: 0..=4294967295,
},
),
fields: Primitive,
largest_niche: None,
align: AbiAndPrefAlign {
abi: Align(4 bytes),
pref: $PREF_ALIGN,
variants: Single {
index: 0,
},
size: Size(4 bytes),
}
--> $DIR/debug.rs:18:1
|
Expand Down
Loading

0 comments on commit abd80d9

Please sign in to comment.