Skip to content

Commit 02e1f11

Browse files
committed
Fix ui pattern_types test for big-endian platforms
The newly added pattern types validity tests fail on s390x and presumably other big-endian systems, due to print of raw values with padding bytes. To fix the tests remove the raw output values in the error note by `normalize-stderr`.
1 parent ae8ab87 commit 02e1f11

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

Diff for: tests/ui/type/pattern_types/validity.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
//! Check that pattern types have their validity checked
2+
// Strip out raw byte dumps to make tests platform-independent:
3+
//@ normalize-stderr: "([[:xdigit:]]{2}\s){4,8}\s+│\s.{4,8}" -> "HEX_DUMP"
24

35
#![feature(pattern_types, const_trait_impl, pattern_type_range_trait)]
46
#![feature(pattern_type_macro)]

Diff for: tests/ui/type/pattern_types/validity.stderr

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
error[E0080]: it is undefined behavior to use this value
2-
--> $DIR/validity.rs:8:1
2+
--> $DIR/validity.rs:10:1
33
|
44
LL | const BAD: pattern_type!(u32 is 1..) = unsafe { std::mem::transmute(0) };
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0, but expected something greater or equal to 1
66
|
77
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
88
= note: the raw bytes of the constant (size: 4, align: 4) {
9-
00 00 00 00 │ ....
9+
HEX_DUMP
1010
}
1111

1212
error[E0080]: evaluation of constant value failed
13-
--> $DIR/validity.rs:11:1
13+
--> $DIR/validity.rs:13:1
1414
|
1515
LL | const BAD_UNINIT: pattern_type!(u32 is 1..) =
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
1717

1818
error[E0080]: evaluation of constant value failed
19-
--> $DIR/validity.rs:15:1
19+
--> $DIR/validity.rs:17:1
2020
|
2121
LL | const BAD_PTR: pattern_type!(usize is 1..) = unsafe { std::mem::transmute(&42) };
2222
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer
@@ -25,53 +25,53 @@ LL | const BAD_PTR: pattern_type!(usize is 1..) = unsafe { std::mem::transmute(&
2525
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
2626

2727
error[E0080]: it is undefined behavior to use this value
28-
--> $DIR/validity.rs:18:1
28+
--> $DIR/validity.rs:20:1
2929
|
3030
LL | const BAD_AGGREGATE: (pattern_type!(u32 is 1..), u32) = (unsafe { std::mem::transmute(0) }, 0);
3131
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered 0, but expected something greater or equal to 1
3232
|
3333
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
3434
= note: the raw bytes of the constant (size: 8, align: 4) {
35-
00 00 00 00 00 00 00 00 │ ........
35+
HEX_DUMP
3636
}
3737

3838
error[E0080]: it is undefined behavior to use this value
39-
--> $DIR/validity.rs:24:1
39+
--> $DIR/validity.rs:26:1
4040
|
4141
LL | const BAD_FOO: Foo = Foo(Bar(unsafe { std::mem::transmute(0) }));
4242
| ^^^^^^^^^^^^^^^^^^ constructing invalid value at .0.0: encountered 0, but expected something greater or equal to 1
4343
|
4444
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
4545
= note: the raw bytes of the constant (size: 4, align: 4) {
46-
00 00 00 00 │ ....
46+
HEX_DUMP
4747
}
4848

4949
error[E0080]: evaluation of constant value failed
50-
--> $DIR/validity.rs:27:1
50+
--> $DIR/validity.rs:29:1
5151
|
5252
LL | const CHAR_UNINIT: pattern_type!(char is 'A'..'Z') =
5353
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
5454

5555
error[E0080]: it is undefined behavior to use this value
56-
--> $DIR/validity.rs:31:1
56+
--> $DIR/validity.rs:33:1
5757
|
5858
LL | const CHAR_OOB_PAT: pattern_type!(char is 'A'..'Z') = unsafe { std::mem::transmute('a') };
5959
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 97, but expected something in the range 65..=89
6060
|
6161
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
6262
= note: the raw bytes of the constant (size: 4, align: 4) {
63-
61 00 00 00 │ a...
63+
HEX_DUMP
6464
}
6565

6666
error[E0080]: it is undefined behavior to use this value
67-
--> $DIR/validity.rs:34:1
67+
--> $DIR/validity.rs:36:1
6868
|
6969
LL | const CHAR_OOB: pattern_type!(char is 'A'..'Z') = unsafe { std::mem::transmute(u32::MAX) };
7070
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0xffffffff, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)
7171
|
7272
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
7373
= note: the raw bytes of the constant (size: 4, align: 4) {
74-
ff ff ff ff │ ....
74+
HEX_DUMP
7575
}
7676

7777
error: aborting due to 8 previous errors

0 commit comments

Comments
 (0)