Skip to content

Commit 6f011f1

Browse files
committed
format layout_of({ty}) without Debug
1 parent ea96099 commit 6f011f1

File tree

7 files changed

+35
-33
lines changed

7 files changed

+35
-33
lines changed

compiler/rustc_passes/src/layout_test.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,15 @@ fn dump_layout_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId, attr: &Attribute) {
6969
}
7070

7171
sym::debug => {
72-
let normalized_ty = format!(
73-
"{:?}",
74-
tcx.normalize_erasing_regions(
75-
param_env.with_reveal_all_normalized(tcx),
76-
ty,
77-
)
78-
);
72+
let normalized_ty =
73+
rustc_middle::ty::print::with_no_trimmed_paths!(format!(
74+
"{}",
75+
tcx.normalize_erasing_regions(
76+
param_env.with_reveal_all_normalized(tcx),
77+
ty,
78+
)
79+
));
80+
7981
let ty_layout = format!("{:#?}", *ty_layout);
8082
tcx.sess.emit_err(LayoutOf {
8183
span: tcx.def_span(item_def_id.to_def_id()),

tests/ui/layout/debug.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: layout_of(Adt(E, [])) = Layout {
1+
error: layout_of(E) = Layout {
22
size: Size(12 bytes),
33
align: AbiAndPrefAlign {
44
abi: Align(4 bytes),
@@ -86,7 +86,7 @@ error: layout_of(Adt(E, [])) = Layout {
8686
LL | enum E { Foo, Bar(!, i32, i32) }
8787
| ^^^^^^
8888

89-
error: layout_of(Adt(S, [])) = Layout {
89+
error: layout_of(S) = Layout {
9090
size: Size(8 bytes),
9191
align: AbiAndPrefAlign {
9292
abi: Align(4 bytes),
@@ -130,7 +130,7 @@ error: layout_of(Adt(S, [])) = Layout {
130130
LL | struct S { f1: i32, f2: (), f3: i32 }
131131
| ^^^^^^^^
132132

133-
error: layout_of(Adt(U, [])) = Layout {
133+
error: layout_of(U) = Layout {
134134
size: Size(8 bytes),
135135
align: AbiAndPrefAlign {
136136
abi: Align(4 bytes),
@@ -152,7 +152,7 @@ error: layout_of(Adt(U, [])) = Layout {
152152
LL | union U { f1: (i32, i32), f3: i32 }
153153
| ^^^^^^^
154154

155-
error: layout_of(Adt(std::result::Result, [Int(I32), Int(I32)])) = Layout {
155+
error: layout_of(std::result::Result<i32, i32>) = Layout {
156156
size: Size(8 bytes),
157157
align: AbiAndPrefAlign {
158158
abi: Align(4 bytes),
@@ -281,7 +281,7 @@ error: layout_of(Adt(std::result::Result, [Int(I32), Int(I32)])) = Layout {
281281
LL | type Test = Result<i32, i32>;
282282
| ^^^^^^^^^
283283

284-
error: layout_of(Int(I32)) = Layout {
284+
error: layout_of(i32) = Layout {
285285
size: Size(4 bytes),
286286
align: AbiAndPrefAlign {
287287
abi: Align(4 bytes),

tests/ui/layout/hexagon-enum.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: layout_of(Adt(A, [])) = Layout {
1+
error: layout_of(A) = Layout {
22
size: Size(1 bytes),
33
align: AbiAndPrefAlign {
44
abi: Align(1 bytes),
@@ -68,7 +68,7 @@ error: layout_of(Adt(A, [])) = Layout {
6868
LL | enum A { Apple }
6969
| ^^^^^^
7070

71-
error: layout_of(Adt(B, [])) = Layout {
71+
error: layout_of(B) = Layout {
7272
size: Size(1 bytes),
7373
align: AbiAndPrefAlign {
7474
abi: Align(1 bytes),
@@ -138,7 +138,7 @@ error: layout_of(Adt(B, [])) = Layout {
138138
LL | enum B { Banana = 255, }
139139
| ^^^^^^
140140

141-
error: layout_of(Adt(C, [])) = Layout {
141+
error: layout_of(C) = Layout {
142142
size: Size(2 bytes),
143143
align: AbiAndPrefAlign {
144144
abi: Align(2 bytes),
@@ -208,7 +208,7 @@ error: layout_of(Adt(C, [])) = Layout {
208208
LL | enum C { Chaenomeles = 256, }
209209
| ^^^^^^
210210

211-
error: layout_of(Adt(P, [])) = Layout {
211+
error: layout_of(P) = Layout {
212212
size: Size(4 bytes),
213213
align: AbiAndPrefAlign {
214214
abi: Align(4 bytes),
@@ -278,7 +278,7 @@ error: layout_of(Adt(P, [])) = Layout {
278278
LL | enum P { Peach = 0x1000_0000isize, }
279279
| ^^^^^^
280280

281-
error: layout_of(Adt(T, [])) = Layout {
281+
error: layout_of(T) = Layout {
282282
size: Size(4 bytes),
283283
align: AbiAndPrefAlign {
284284
abi: Align(4 bytes),

tests/ui/layout/issue-96158-scalarpair-payload-might-be-uninit.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: layout_of(Adt(MissingPayloadField, [])) = Layout {
1+
error: layout_of(MissingPayloadField) = Layout {
22
size: Size(2 bytes),
33
align: AbiAndPrefAlign {
44
abi: Align(1 bytes),
@@ -108,7 +108,7 @@ error: layout_of(Adt(MissingPayloadField, [])) = Layout {
108108
LL | pub enum MissingPayloadField {
109109
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
110110

111-
error: layout_of(Adt(CommonPayloadField, [])) = Layout {
111+
error: layout_of(CommonPayloadField) = Layout {
112112
size: Size(2 bytes),
113113
align: AbiAndPrefAlign {
114114
abi: Align(1 bytes),
@@ -237,7 +237,7 @@ error: layout_of(Adt(CommonPayloadField, [])) = Layout {
237237
LL | pub enum CommonPayloadField {
238238
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
239239

240-
error: layout_of(Adt(CommonPayloadFieldIsMaybeUninit, [])) = Layout {
240+
error: layout_of(CommonPayloadFieldIsMaybeUninit) = Layout {
241241
size: Size(2 bytes),
242242
align: AbiAndPrefAlign {
243243
abi: Align(1 bytes),
@@ -363,7 +363,7 @@ error: layout_of(Adt(CommonPayloadFieldIsMaybeUninit, [])) = Layout {
363363
LL | pub enum CommonPayloadFieldIsMaybeUninit {
364364
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
365365

366-
error: layout_of(Adt(NicheFirst, [])) = Layout {
366+
error: layout_of(NicheFirst) = Layout {
367367
size: Size(2 bytes),
368368
align: AbiAndPrefAlign {
369369
abi: Align(1 bytes),
@@ -507,7 +507,7 @@ error: layout_of(Adt(NicheFirst, [])) = Layout {
507507
LL | pub enum NicheFirst {
508508
| ^^^^^^^^^^^^^^^^^^^
509509

510-
error: layout_of(Adt(NicheSecond, [])) = Layout {
510+
error: layout_of(NicheSecond) = Layout {
511511
size: Size(2 bytes),
512512
align: AbiAndPrefAlign {
513513
abi: Align(1 bytes),

tests/ui/layout/issue-96185-overaligned-enum.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: layout_of(Adt(Aligned1, [])) = Layout {
1+
error: layout_of(Aligned1) = Layout {
22
size: Size(8 bytes),
33
align: AbiAndPrefAlign {
44
abi: Align(8 bytes),
@@ -80,7 +80,7 @@ error: layout_of(Adt(Aligned1, [])) = Layout {
8080
LL | pub enum Aligned1 {
8181
| ^^^^^^^^^^^^^^^^^
8282

83-
error: layout_of(Adt(Aligned2, [])) = Layout {
83+
error: layout_of(Aligned2) = Layout {
8484
size: Size(1 bytes),
8585
align: AbiAndPrefAlign {
8686
abi: Align(1 bytes),

tests/ui/layout/thumb-enum.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: layout_of(Adt(A, [])) = Layout {
1+
error: layout_of(A) = Layout {
22
size: Size(1 bytes),
33
align: AbiAndPrefAlign {
44
abi: Align(1 bytes),
@@ -68,7 +68,7 @@ error: layout_of(Adt(A, [])) = Layout {
6868
LL | enum A { Apple }
6969
| ^^^^^^
7070

71-
error: layout_of(Adt(B, [])) = Layout {
71+
error: layout_of(B) = Layout {
7272
size: Size(1 bytes),
7373
align: AbiAndPrefAlign {
7474
abi: Align(1 bytes),
@@ -138,7 +138,7 @@ error: layout_of(Adt(B, [])) = Layout {
138138
LL | enum B { Banana = 255, }
139139
| ^^^^^^
140140

141-
error: layout_of(Adt(C, [])) = Layout {
141+
error: layout_of(C) = Layout {
142142
size: Size(2 bytes),
143143
align: AbiAndPrefAlign {
144144
abi: Align(2 bytes),
@@ -208,7 +208,7 @@ error: layout_of(Adt(C, [])) = Layout {
208208
LL | enum C { Chaenomeles = 256, }
209209
| ^^^^^^
210210

211-
error: layout_of(Adt(P, [])) = Layout {
211+
error: layout_of(P) = Layout {
212212
size: Size(4 bytes),
213213
align: AbiAndPrefAlign {
214214
abi: Align(4 bytes),
@@ -278,7 +278,7 @@ error: layout_of(Adt(P, [])) = Layout {
278278
LL | enum P { Peach = 0x1000_0000isize, }
279279
| ^^^^^^
280280

281-
error: layout_of(Adt(T, [])) = Layout {
281+
error: layout_of(T) = Layout {
282282
size: Size(4 bytes),
283283
align: AbiAndPrefAlign {
284284
abi: Align(4 bytes),

tests/ui/layout/zero-sized-array-enum-niche.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: layout_of(Adt(std::result::Result, [Array(Uint(U32), Const { ty: Uint(Usize), kind: Value(Leaf(...)) }), Bool])) = Layout {
1+
error: layout_of(std::result::Result<[u32; 0], bool>) = Layout {
22
size: Size(4 bytes),
33
align: AbiAndPrefAlign {
44
abi: Align(4 bytes),
@@ -97,7 +97,7 @@ error: layout_of(Adt(std::result::Result, [Array(Uint(U32), Const { ty: Uint(Usi
9797
LL | type AlignedResult = Result<[u32; 0], bool>;
9898
| ^^^^^^^^^^^^^^^^^^
9999

100-
error: layout_of(Adt(MultipleAlignments, [])) = Layout {
100+
error: layout_of(MultipleAlignments) = Layout {
101101
size: Size(4 bytes),
102102
align: AbiAndPrefAlign {
103103
abi: Align(4 bytes),
@@ -218,7 +218,7 @@ error: layout_of(Adt(MultipleAlignments, [])) = Layout {
218218
LL | enum MultipleAlignments {
219219
| ^^^^^^^^^^^^^^^^^^^^^^^
220220

221-
error: layout_of(Adt(std::result::Result, [Array(Uint(U32), Const { ty: Uint(Usize), kind: Value(Leaf(...)) }), Adt(Packed, [Adt(std::num::NonZeroU16, [])])])) = Layout {
221+
error: layout_of(std::result::Result<[u32; 0], Packed<std::num::NonZeroU16>>) = Layout {
222222
size: Size(4 bytes),
223223
align: AbiAndPrefAlign {
224224
abi: Align(4 bytes),
@@ -317,7 +317,7 @@ error: layout_of(Adt(std::result::Result, [Array(Uint(U32), Const { ty: Uint(Usi
317317
LL | type NicheLosesToTagged = Result<[u32; 0], Packed<std::num::NonZeroU16>>;
318318
| ^^^^^^^^^^^^^^^^^^^^^^^
319319

320-
error: layout_of(Adt(std::result::Result, [Array(Uint(U32), Const { ty: Uint(Usize), kind: Value(Leaf(...)) }), Adt(Packed, [Adt(U16IsZero, [])])])) = Layout {
320+
error: layout_of(std::result::Result<[u32; 0], Packed<U16IsZero>>) = Layout {
321321
size: Size(4 bytes),
322322
align: AbiAndPrefAlign {
323323
abi: Align(4 bytes),

0 commit comments

Comments
 (0)