]> git.lizzy.rs Git - rust.git/commitdiff
also print rustc_layout on impl trait type aliases
authorRalf Jung <post@ralfj.de>
Sun, 5 Apr 2020 15:07:06 +0000 (17:07 +0200)
committerRalf Jung <post@ralfj.de>
Sun, 5 Apr 2020 15:07:06 +0000 (17:07 +0200)
src/librustc_passes/layout_test.rs
src/test/ui/layout/debug.rs
src/test/ui/layout/debug.stderr

index da8ab727ed3aa3e82d868c51e7588eaf0b0dc21f..867cec38a8b8f4448347fe899891719691d2a453 100644 (file)
@@ -27,7 +27,8 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
             ItemKind::TyAlias(..)
             | ItemKind::Enum(..)
             | ItemKind::Struct(..)
-            | ItemKind::Union(..) => {
+            | ItemKind::Union(..)
+            | ItemKind::OpaqueTy(..) => {
                 for attr in self.tcx.get_attrs(item_def_id).iter() {
                     if attr.check_name(sym::rustc_layout) {
                         self.dump_layout_of(item_def_id, item, attr);
index 70ae200e3e5aa936003e77e2b30a1352d898a198..034ed3190c13f84449de382643f90dffe032dc3c 100644 (file)
@@ -1,5 +1,5 @@
 // normalize-stderr-test "pref: Align \{\n *pow2: [1-3],\n *\}" -> "pref: $$PREF_ALIGN"
-#![feature(never_type, rustc_attrs)]
+#![feature(never_type, rustc_attrs, type_alias_impl_trait)]
 #![crate_type = "lib"]
 
 #[rustc_layout(debug)]
@@ -13,3 +13,10 @@ union U { f1: (i32, i32), f3: i32 } //~ ERROR: layout debugging
 
 #[rustc_layout(debug)]
 type Test = Result<i32, i32>; //~ ERROR: layout debugging
+
+#[rustc_layout(debug)]
+type T = impl std::fmt::Debug; //~ ERROR: layout debugging
+
+fn f() -> T {
+    0i32
+}
index ef88cf1e4c13ac5328cbf31c1e4a4acaffe1a332..3d4076537559742ecf0469a4260b004f8e8317ba 100644 (file)
@@ -315,5 +315,37 @@ error: layout debugging: Layout {
 LL | type Test = Result<i32, i32>;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error: aborting due to 4 previous errors
+error: layout debugging: Layout {
+    fields: Union(
+        0,
+    ),
+    variants: Single {
+        index: 0,
+    },
+    abi: Scalar(
+        Scalar {
+            value: Int(
+                I32,
+                true,
+            ),
+            valid_range: 0..=4294967295,
+        },
+    ),
+    largest_niche: None,
+    align: AbiAndPrefAlign {
+        abi: Align {
+            pow2: 2,
+        },
+        pref: $PREF_ALIGN,
+    },
+    size: Size {
+        raw: 4,
+    },
+}
+  --> $DIR/debug.rs:18:1
+   |
+LL | type T = impl std::fmt::Debug;
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 5 previous errors