Skip to content

Commit 4a75883

Browse files
committed
also print rustc_layout on impl trait type aliases
1 parent 7b657d3 commit 4a75883

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

src/librustc_passes/layout_test.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ impl ItemLikeVisitor<'tcx> for LayoutTest<'tcx> {
2727
ItemKind::TyAlias(..)
2828
| ItemKind::Enum(..)
2929
| ItemKind::Struct(..)
30-
| ItemKind::Union(..) => {
30+
| ItemKind::Union(..)
31+
| ItemKind::OpaqueTy(..) => {
3132
for attr in self.tcx.get_attrs(item_def_id).iter() {
3233
if attr.check_name(sym::rustc_layout) {
3334
self.dump_layout_of(item_def_id, item, attr);

src/test/ui/layout/debug.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// normalize-stderr-test "pref: Align \{\n *pow2: [1-3],\n *\}" -> "pref: $$PREF_ALIGN"
2-
#![feature(never_type, rustc_attrs)]
2+
#![feature(never_type, rustc_attrs, type_alias_impl_trait)]
33
#![crate_type = "lib"]
44

55
#[rustc_layout(debug)]
@@ -13,3 +13,10 @@ union U { f1: (i32, i32), f3: i32 } //~ ERROR: layout debugging
1313

1414
#[rustc_layout(debug)]
1515
type Test = Result<i32, i32>; //~ ERROR: layout debugging
16+
17+
#[rustc_layout(debug)]
18+
type T = impl std::fmt::Debug; //~ ERROR: layout debugging
19+
20+
fn f() -> T {
21+
0i32
22+
}

src/test/ui/layout/debug.stderr

+33-1
Original file line numberDiff line numberDiff line change
@@ -315,5 +315,37 @@ error: layout debugging: Layout {
315315
LL | type Test = Result<i32, i32>;
316316
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
317317

318-
error: aborting due to 4 previous errors
318+
error: layout debugging: Layout {
319+
fields: Union(
320+
0,
321+
),
322+
variants: Single {
323+
index: 0,
324+
},
325+
abi: Scalar(
326+
Scalar {
327+
value: Int(
328+
I32,
329+
true,
330+
),
331+
valid_range: 0..=4294967295,
332+
},
333+
),
334+
largest_niche: None,
335+
align: AbiAndPrefAlign {
336+
abi: Align {
337+
pow2: 2,
338+
},
339+
pref: $PREF_ALIGN,
340+
},
341+
size: Size {
342+
raw: 4,
343+
},
344+
}
345+
--> $DIR/debug.rs:18:1
346+
|
347+
LL | type T = impl std::fmt::Debug;
348+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
349+
350+
error: aborting due to 5 previous errors
319351

0 commit comments

Comments
 (0)