about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/abi/debug.rs23
-rw-r--r--tests/ui/abi/debug.stderr260
-rw-r--r--tests/ui/layout/debug.rs2
-rw-r--r--tests/ui/layout/debug.stderr36
4 files changed, 302 insertions, 19 deletions
diff --git a/tests/ui/abi/debug.rs b/tests/ui/abi/debug.rs
new file mode 100644
index 00000000000..13464be275e
--- /dev/null
+++ b/tests/ui/abi/debug.rs
@@ -0,0 +1,23 @@
+// normalize-stderr-test "(abi|pref|unadjusted_abi_align): Align\([1-8] bytes\)" -> "$1: $$SOME_ALIGN"
+// normalize-stderr-test "(size): Size\([48] bytes\)" -> "$1: $$SOME_SIZE"
+// normalize-stderr-test "(can_unwind): (true|false)" -> "$1: $$SOME_BOOL"
+// normalize-stderr-test "(valid_range): 0\.\.=(4294967295|18446744073709551615)" -> "$1: $$FULL"
+// This pattern is prepared for when we account for alignment in the niche.
+// normalize-stderr-test "(valid_range): [1-9]\.\.=(429496729[0-9]|1844674407370955161[0-9])" -> "$1: $$NON_NULL"
+// Some attributes are only computed for release builds:
+// compile-flags: -O
+#![feature(rustc_attrs)]
+#![crate_type = "lib"]
+
+#[rustc_abi(debug)]
+fn test(_x: u8) -> bool { true } //~ ERROR: fn_abi
+
+
+#[rustc_abi(debug)]
+fn test_generic<T>(_x: *const T) { } //~ ERROR: fn_abi
+
+struct S(u16);
+impl S {
+    #[rustc_abi(debug)]
+    fn assoc_test(&self) { } //~ ERROR: fn_abi
+}
diff --git a/tests/ui/abi/debug.stderr b/tests/ui/abi/debug.stderr
new file mode 100644
index 00000000000..4f4ee3de4b8
--- /dev/null
+++ b/tests/ui/abi/debug.stderr
@@ -0,0 +1,260 @@
+error: fn_abi_of_instance(test) = FnAbi {
+           args: [
+               ArgAbi {
+                   layout: TyAndLayout {
+                       ty: u8,
+                       layout: Layout {
+                           size: Size(1 bytes),
+                           align: AbiAndPrefAlign {
+                               abi: $SOME_ALIGN,
+                               pref: $SOME_ALIGN,
+                           },
+                           abi: Scalar(
+                               Initialized {
+                                   value: Int(
+                                       I8,
+                                       false,
+                                   ),
+                                   valid_range: 0..=255,
+                               },
+                           ),
+                           fields: Primitive,
+                           largest_niche: None,
+                           variants: Single {
+                               index: 0,
+                           },
+                           max_repr_align: None,
+                           unadjusted_abi_align: $SOME_ALIGN,
+                       },
+                   },
+                   mode: Direct(
+                       ArgAttributes {
+                           regular: NoUndef,
+                           arg_ext: None,
+                           pointee_size: Size(0 bytes),
+                           pointee_align: None,
+                       },
+                   ),
+               },
+           ],
+           ret: ArgAbi {
+               layout: TyAndLayout {
+                   ty: bool,
+                   layout: Layout {
+                       size: Size(1 bytes),
+                       align: AbiAndPrefAlign {
+                           abi: $SOME_ALIGN,
+                           pref: $SOME_ALIGN,
+                       },
+                       abi: Scalar(
+                           Initialized {
+                               value: Int(
+                                   I8,
+                                   false,
+                               ),
+                               valid_range: 0..=1,
+                           },
+                       ),
+                       fields: Primitive,
+                       largest_niche: Some(
+                           Niche {
+                               offset: Size(0 bytes),
+                               value: Int(
+                                   I8,
+                                   false,
+                               ),
+                               valid_range: 0..=1,
+                           },
+                       ),
+                       variants: Single {
+                           index: 0,
+                       },
+                       max_repr_align: None,
+                       unadjusted_abi_align: $SOME_ALIGN,
+                   },
+               },
+               mode: Direct(
+                   ArgAttributes {
+                       regular: NoUndef,
+                       arg_ext: Zext,
+                       pointee_size: Size(0 bytes),
+                       pointee_align: None,
+                   },
+               ),
+           },
+           c_variadic: false,
+           fixed_count: 1,
+           conv: Rust,
+           can_unwind: $SOME_BOOL,
+       }
+  --> $DIR/debug.rs:13:1
+   |
+LL | fn test(_x: u8) -> bool { true }
+   | ^^^^^^^^^^^^^^^^^^^^^^^
+
+error: fn_abi_of_instance(test_generic) = FnAbi {
+           args: [
+               ArgAbi {
+                   layout: TyAndLayout {
+                       ty: *const T,
+                       layout: Layout {
+                           size: $SOME_SIZE,
+                           align: AbiAndPrefAlign {
+                               abi: $SOME_ALIGN,
+                               pref: $SOME_ALIGN,
+                           },
+                           abi: Scalar(
+                               Initialized {
+                                   value: Pointer(
+                                       AddressSpace(
+                                           0,
+                                       ),
+                                   ),
+                                   valid_range: $FULL,
+                               },
+                           ),
+                           fields: Primitive,
+                           largest_niche: None,
+                           variants: Single {
+                               index: 0,
+                           },
+                           max_repr_align: None,
+                           unadjusted_abi_align: $SOME_ALIGN,
+                       },
+                   },
+                   mode: Direct(
+                       ArgAttributes {
+                           regular: NoUndef,
+                           arg_ext: None,
+                           pointee_size: Size(0 bytes),
+                           pointee_align: None,
+                       },
+                   ),
+               },
+           ],
+           ret: ArgAbi {
+               layout: TyAndLayout {
+                   ty: (),
+                   layout: Layout {
+                       size: Size(0 bytes),
+                       align: AbiAndPrefAlign {
+                           abi: $SOME_ALIGN,
+                           pref: $SOME_ALIGN,
+                       },
+                       abi: Aggregate {
+                           sized: true,
+                       },
+                       fields: Arbitrary {
+                           offsets: [],
+                           memory_index: [],
+                       },
+                       largest_niche: None,
+                       variants: Single {
+                           index: 0,
+                       },
+                       max_repr_align: None,
+                       unadjusted_abi_align: $SOME_ALIGN,
+                   },
+               },
+               mode: Ignore,
+           },
+           c_variadic: false,
+           fixed_count: 1,
+           conv: Rust,
+           can_unwind: $SOME_BOOL,
+       }
+  --> $DIR/debug.rs:17:1
+   |
+LL | fn test_generic<T>(_x: *const T) { }
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: fn_abi_of_instance(assoc_test) = FnAbi {
+           args: [
+               ArgAbi {
+                   layout: TyAndLayout {
+                       ty: &S,
+                       layout: Layout {
+                           size: $SOME_SIZE,
+                           align: AbiAndPrefAlign {
+                               abi: $SOME_ALIGN,
+                               pref: $SOME_ALIGN,
+                           },
+                           abi: Scalar(
+                               Initialized {
+                                   value: Pointer(
+                                       AddressSpace(
+                                           0,
+                                       ),
+                                   ),
+                                   valid_range: $NON_NULL,
+                               },
+                           ),
+                           fields: Primitive,
+                           largest_niche: Some(
+                               Niche {
+                                   offset: Size(0 bytes),
+                                   value: Pointer(
+                                       AddressSpace(
+                                           0,
+                                       ),
+                                   ),
+                                   valid_range: $NON_NULL,
+                               },
+                           ),
+                           variants: Single {
+                               index: 0,
+                           },
+                           max_repr_align: None,
+                           unadjusted_abi_align: $SOME_ALIGN,
+                       },
+                   },
+                   mode: Direct(
+                       ArgAttributes {
+                           regular: NoAlias | NonNull | ReadOnly | NoUndef,
+                           arg_ext: None,
+                           pointee_size: Size(2 bytes),
+                           pointee_align: Some(
+                               Align(2 bytes),
+                           ),
+                       },
+                   ),
+               },
+           ],
+           ret: ArgAbi {
+               layout: TyAndLayout {
+                   ty: (),
+                   layout: Layout {
+                       size: Size(0 bytes),
+                       align: AbiAndPrefAlign {
+                           abi: $SOME_ALIGN,
+                           pref: $SOME_ALIGN,
+                       },
+                       abi: Aggregate {
+                           sized: true,
+                       },
+                       fields: Arbitrary {
+                           offsets: [],
+                           memory_index: [],
+                       },
+                       largest_niche: None,
+                       variants: Single {
+                           index: 0,
+                       },
+                       max_repr_align: None,
+                       unadjusted_abi_align: $SOME_ALIGN,
+                   },
+               },
+               mode: Ignore,
+           },
+           c_variadic: false,
+           fixed_count: 1,
+           conv: Rust,
+           can_unwind: $SOME_BOOL,
+       }
+  --> $DIR/debug.rs:22:5
+   |
+LL |     fn assoc_test(&self) { }
+   |     ^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
+
diff --git a/tests/ui/layout/debug.rs b/tests/ui/layout/debug.rs
index 46171880a6f..b74a8d3b917 100644
--- a/tests/ui/layout/debug.rs
+++ b/tests/ui/layout/debug.rs
@@ -1,4 +1,4 @@
-// normalize-stderr-test "pref: Align\([1-8] bytes\)" -> "pref: $$PREF_ALIGN"
+// normalize-stderr-test "pref: Align\([1-8] bytes\)" -> "pref: $$SOME_ALIGN"
 #![feature(never_type, rustc_attrs, type_alias_impl_trait, repr_simd)]
 #![crate_type = "lib"]
 
diff --git a/tests/ui/layout/debug.stderr b/tests/ui/layout/debug.stderr
index eeffb3c5f64..ea5e1ad9dce 100644
--- a/tests/ui/layout/debug.stderr
+++ b/tests/ui/layout/debug.stderr
@@ -2,7 +2,7 @@ error: layout_of(E) = Layout {
            size: Size(12 bytes),
            align: AbiAndPrefAlign {
                abi: Align(4 bytes),
-               pref: $PREF_ALIGN,
+               pref: $SOME_ALIGN,
            },
            abi: Aggregate {
                sized: true,
@@ -40,7 +40,7 @@ error: layout_of(E) = Layout {
                        size: Size(4 bytes),
                        align: AbiAndPrefAlign {
                            abi: Align(1 bytes),
-                           pref: $PREF_ALIGN,
+                           pref: $SOME_ALIGN,
                        },
                        abi: Aggregate {
                            sized: true,
@@ -60,7 +60,7 @@ error: layout_of(E) = Layout {
                        size: Size(12 bytes),
                        align: AbiAndPrefAlign {
                            abi: Align(4 bytes),
-                           pref: $PREF_ALIGN,
+                           pref: $SOME_ALIGN,
                        },
                        abi: Uninhabited,
                        fields: Arbitrary {
@@ -96,7 +96,7 @@ error: layout_of(S) = Layout {
            size: Size(8 bytes),
            align: AbiAndPrefAlign {
                abi: Align(4 bytes),
-               pref: $PREF_ALIGN,
+               pref: $SOME_ALIGN,
            },
            abi: ScalarPair(
                Initialized {
@@ -142,7 +142,7 @@ error: layout_of(U) = Layout {
            size: Size(8 bytes),
            align: AbiAndPrefAlign {
                abi: Align(4 bytes),
-               pref: $PREF_ALIGN,
+               pref: $SOME_ALIGN,
            },
            abi: Aggregate {
                sized: true,
@@ -166,7 +166,7 @@ error: layout_of(std::result::Result<i32, i32>) = Layout {
            size: Size(8 bytes),
            align: AbiAndPrefAlign {
                abi: Align(4 bytes),
-               pref: $PREF_ALIGN,
+               pref: $SOME_ALIGN,
            },
            abi: ScalarPair(
                Initialized {
@@ -217,7 +217,7 @@ error: layout_of(std::result::Result<i32, i32>) = Layout {
                        size: Size(8 bytes),
                        align: AbiAndPrefAlign {
                            abi: Align(4 bytes),
-                           pref: $PREF_ALIGN,
+                           pref: $SOME_ALIGN,
                        },
                        abi: ScalarPair(
                            Initialized {
@@ -254,7 +254,7 @@ error: layout_of(std::result::Result<i32, i32>) = Layout {
                        size: Size(8 bytes),
                        align: AbiAndPrefAlign {
                            abi: Align(4 bytes),
-                           pref: $PREF_ALIGN,
+                           pref: $SOME_ALIGN,
                        },
                        abi: ScalarPair(
                            Initialized {
@@ -301,7 +301,7 @@ error: layout_of(i32) = Layout {
            size: Size(4 bytes),
            align: AbiAndPrefAlign {
                abi: Align(4 bytes),
-               pref: $PREF_ALIGN,
+               pref: $SOME_ALIGN,
            },
            abi: Scalar(
                Initialized {
@@ -329,7 +329,7 @@ error: layout_of(V) = Layout {
            size: Size(2 bytes),
            align: AbiAndPrefAlign {
                abi: Align(2 bytes),
-               pref: $PREF_ALIGN,
+               pref: $SOME_ALIGN,
            },
            abi: Aggregate {
                sized: true,
@@ -353,7 +353,7 @@ error: layout_of(W) = Layout {
            size: Size(2 bytes),
            align: AbiAndPrefAlign {
                abi: Align(2 bytes),
-               pref: $PREF_ALIGN,
+               pref: $SOME_ALIGN,
            },
            abi: Aggregate {
                sized: true,
@@ -377,7 +377,7 @@ error: layout_of(Y) = Layout {
            size: Size(0 bytes),
            align: AbiAndPrefAlign {
                abi: Align(2 bytes),
-               pref: $PREF_ALIGN,
+               pref: $SOME_ALIGN,
            },
            abi: Aggregate {
                sized: true,
@@ -401,7 +401,7 @@ error: layout_of(P1) = Layout {
            size: Size(4 bytes),
            align: AbiAndPrefAlign {
                abi: Align(1 bytes),
-               pref: $PREF_ALIGN,
+               pref: $SOME_ALIGN,
            },
            abi: Aggregate {
                sized: true,
@@ -425,7 +425,7 @@ error: layout_of(P2) = Layout {
            size: Size(8 bytes),
            align: AbiAndPrefAlign {
                abi: Align(1 bytes),
-               pref: $PREF_ALIGN,
+               pref: $SOME_ALIGN,
            },
            abi: Aggregate {
                sized: true,
@@ -449,7 +449,7 @@ error: layout_of(P3) = Layout {
            size: Size(16 bytes),
            align: AbiAndPrefAlign {
                abi: Align(1 bytes),
-               pref: $PREF_ALIGN,
+               pref: $SOME_ALIGN,
            },
            abi: Aggregate {
                sized: true,
@@ -473,7 +473,7 @@ error: layout_of(P4) = Layout {
            size: Size(12 bytes),
            align: AbiAndPrefAlign {
                abi: Align(1 bytes),
-               pref: $PREF_ALIGN,
+               pref: $SOME_ALIGN,
            },
            abi: Aggregate {
                sized: true,
@@ -497,7 +497,7 @@ error: layout_of(P5) = Layout {
            size: Size(1 bytes),
            align: AbiAndPrefAlign {
                abi: Align(1 bytes),
-               pref: $PREF_ALIGN,
+               pref: $SOME_ALIGN,
            },
            abi: Scalar(
                Union {
@@ -526,7 +526,7 @@ error: layout_of(std::mem::MaybeUninit<u8>) = Layout {
            size: Size(1 bytes),
            align: AbiAndPrefAlign {
                abi: Align(1 bytes),
-               pref: $PREF_ALIGN,
+               pref: $SOME_ALIGN,
            },
            abi: Scalar(
                Union {