Skip to content

Commit 9b11acc

Browse files
Rollup merge of #156716 - heinwol:fix-ui-tests-alloc-id-parallel-frontend, r=petrochenkov
tests: fix: parallel frontend test failures: different alloc ids Removed the `//@ ignore-parallel-frontend different alloc ids` directive from all the ui tests applicable and replaced it with `//@ normalize-stderr` so that all alloc ids mentions are converted into a single placeholder. Thus the tests are passed Part of [#154314](#154314) r? @petrochenkov
2 parents 35c2fcf + c7a0991 commit 9b11acc

104 files changed

Lines changed: 563 additions & 530 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/tools/compiletest/src/runtest.rs

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,31 +2580,52 @@ impl<'test> TestCx<'test> {
25802580
// that actually appear in the output.
25812581
// We use uppercase ALLOC to distinguish from the non-normalized version.
25822582
{
2583-
let mut seen_allocs = indexmap::IndexSet::new();
2584-
2585-
// The alloc-id appears in pretty-printed allocations.
2586-
normalized = static_regex!(
2587-
r"╾─*a(lloc)?([0-9]+)(\+0x[0-9a-f]+)?(<imm>)?( \([0-9]+ ptr bytes\))?─*╼"
2588-
)
2589-
.replace_all(&normalized, |caps: &Captures<'_>| {
2590-
// Renumber the captured index.
2591-
let index = caps.get(2).unwrap().as_str().to_string();
2592-
let (index, _) = seen_allocs.insert_full(index);
2593-
let offset = caps.get(3).map_or("", |c| c.as_str());
2594-
let imm = caps.get(4).map_or("", |c| c.as_str());
2595-
// Do not bother keeping it pretty, just make it deterministic.
2596-
format!("╾ALLOC{index}{offset}{imm}╼")
2597-
})
2598-
.into_owned();
2583+
match self.config.mode {
2584+
// Unfortunately, due to parallel frontend assigning alloc-ids
2585+
// nondeterministically we resort to dropping ids altogether for now
2586+
// in ui tests
2587+
TestMode::Ui => {
2588+
// The alloc-id appears in pretty-printed allocations.
2589+
normalized = static_regex!(
2590+
r"╾─*(a(lloc)?|A(LLOC)?)\d+(\+0x[0-9a-f]+)?(<imm>)?( ?\(\d+ ptr bytes\))?─*╼"
2591+
)
2592+
.replace_all(&normalized, |_: &Captures<'_>| "╾ALLOC$ID╼".to_string())
2593+
.into_owned();
25992594

2600-
// The alloc-id appears in a sentence.
2601-
normalized = static_regex!(r"\balloc([0-9]+)\b")
2602-
.replace_all(&normalized, |caps: &Captures<'_>| {
2603-
let index = caps.get(1).unwrap().as_str().to_string();
2604-
let (index, _) = seen_allocs.insert_full(index);
2605-
format!("ALLOC{index}")
2606-
})
2607-
.into_owned();
2595+
// The alloc-id appears in a sentence.
2596+
normalized = static_regex!(r"\b(alloc|ALLOC)\d+\b")
2597+
.replace_all(&normalized, |_: &Captures<'_>| "ALLOC$ID".to_string())
2598+
.into_owned();
2599+
}
2600+
// use consistent `AllocId`s in other test modes, where parallel frontend
2601+
// should not (theoretically) be an issue
2602+
_ => {
2603+
let mut seen_allocs = indexmap::IndexSet::new();
2604+
// The alloc-id appears in pretty-printed allocations.
2605+
normalized = static_regex!(
2606+
r"╾─*a(lloc)?([0-9]+)(\+0x[0-9a-f]+)?(<imm>)?( \([0-9]+ ptr bytes\))?─*╼"
2607+
)
2608+
.replace_all(&normalized, |caps: &Captures<'_>| {
2609+
// Renumber the captured index.
2610+
let index = caps.get(2).unwrap().as_str().to_string();
2611+
let (index, _) = seen_allocs.insert_full(index);
2612+
let offset = caps.get(3).map_or("", |c| c.as_str());
2613+
let imm = caps.get(4).map_or("", |c| c.as_str());
2614+
// Do not bother keeping it pretty, just make it deterministic.
2615+
format!("╾ALLOC{index}{offset}{imm}╼")
2616+
})
2617+
.into_owned();
2618+
2619+
// The alloc-id appears in a sentence.
2620+
normalized = static_regex!(r"\balloc([0-9]+)\b")
2621+
.replace_all(&normalized, |caps: &Captures<'_>| {
2622+
let index = caps.get(1).unwrap().as_str().to_string();
2623+
let (index, _) = seen_allocs.insert_full(index);
2624+
format!("ALLOC{index}")
2625+
})
2626+
.into_owned();
2627+
}
2628+
}
26082629
}
26092630

26102631
// Custom normalization rules

tests/ui/const-generics/issues/issue-100313.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ dont-require-annotations: NOTE
2-
//@ ignore-parallel-frontend different alloc ids
2+
33
#![allow(incomplete_features)]
44
#![feature(adt_const_params, unsized_const_params)]
55

@@ -15,7 +15,7 @@ impl<const B: &'static bool> T<B> {
1515

1616
const _: () = {
1717
let x = T::<{ &true }>;
18-
x.set_false(); //~ ERROR writing to ALLOC0 which is read-only
18+
x.set_false(); //~ ERROR writing to ALLOC$ID which is read-only
1919
};
2020

2121
fn main() {}

tests/ui/const-generics/issues/issue-100313.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0080]: writing to ALLOC0 which is read-only
1+
error[E0080]: writing to ALLOC$ID which is read-only
22
--> $DIR/issue-100313.rs:18:5
33
|
44
LL | x.set_false();

tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ note: expected because of the type of the const parameter
4646
LL | fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> {
4747
| ^^^^^^^^^^^^^^^^^^^^^
4848

49-
error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
49+
error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
5050
--> $DIR/invalid-patterns.rs:40:32
5151
|
5252
LL | get_flag::<false, { unsafe { char_raw.character } }>();
@@ -78,7 +78,7 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character
7878
42 │ B
7979
}
8080

81-
error[E0080]: reading memory at ALLOC1[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
81+
error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
8282
--> $DIR/invalid-patterns.rs:44:58
8383
|
8484
LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();

tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ note: expected because of the type of the const parameter
4646
LL | fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> {
4747
| ^^^^^^^^^^^^^^^^^^^^^
4848

49-
error[E0080]: reading memory at ALLOC0[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
49+
error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
5050
--> $DIR/invalid-patterns.rs:40:32
5151
|
5252
LL | get_flag::<false, { unsafe { char_raw.character } }>();
@@ -78,7 +78,7 @@ LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character
7878
42 │ B
7979
}
8080

81-
error[E0080]: reading memory at ALLOC1[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
81+
error[E0080]: reading memory at ALLOC$ID[0x0..0x4], but memory is uninitialized at [0x1..0x4], and this operation requires initialized memory
8282
--> $DIR/invalid-patterns.rs:44:58
8383
|
8484
LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();

tests/ui/const-generics/min_const_generics/invalid-patterns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ stderr-per-bitwidth
22
//@ dont-require-annotations: NOTE
3-
//@ ignore-parallel-frontend different alloc ids
3+
44
use std::mem::transmute;
55

66
fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> {

tests/ui/const-ptr/forbidden_slices.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Strip out raw byte dumps to make comparison platform-independent:
22
//@ normalize-stderr: "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)"
33
//@ normalize-stderr: "([0-9a-f][0-9a-f] |╾─*A(LLOC)?[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP"
4-
//@ ignore-parallel-frontend different alloc ids
4+
55
#![feature(
66
slice_from_ptr_range,
77
const_slice_from_ptr_range,

tests/ui/const-ptr/forbidden_slices.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) };
2828
|
2929
= 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.
3030
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
31-
HEX_DUMP
31+
╾ALLOC$ID╼ HEX_DUMP
3232
}
3333

3434
error[E0080]: constructing invalid value of type &[u8]: at .<deref>[0], encountered uninitialized memory, but expected an integer
@@ -39,7 +39,7 @@ LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }
3939
|
4040
= 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.
4141
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
42-
HEX_DUMP
42+
╾ALLOC$ID╼ HEX_DUMP
4343
}
4444

4545
error[E0080]: constructing invalid value of type &[u8]: at .<deref>[0], encountered a pointer, but expected an integer
@@ -52,7 +52,7 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size
5252
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
5353
= 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.
5454
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
55-
HEX_DUMP
55+
╾ALLOC$ID╼ HEX_DUMP
5656
}
5757

5858
error[E0080]: constructing invalid value of type &[bool]: at .<deref>[0], encountered 0x11, but expected a boolean
@@ -63,7 +63,7 @@ LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4)
6363
|
6464
= 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.
6565
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
66-
HEX_DUMP
66+
╾ALLOC$ID╼ HEX_DUMP
6767
}
6868

6969
error[E0080]: constructing invalid value of type &[u16]: at .<deref>[1], encountered uninitialized memory, but expected an integer
@@ -74,7 +74,7 @@ LL | pub static S7: &[u16] = unsafe {
7474
|
7575
= 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.
7676
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
77-
HEX_DUMP
77+
╾ALLOC$ID╼ HEX_DUMP
7878
}
7979

8080
error[E0080]: constructing invalid value of type &[u64]: encountered a dangling reference (going beyond the bounds of its allocation)
@@ -85,7 +85,7 @@ LL | pub static S8: &[u64] = unsafe {
8585
|
8686
= 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.
8787
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
88-
HEX_DUMP
88+
╾ALLOC$ID╼ HEX_DUMP
8989
}
9090

9191
error[E0080]: constructing invalid value of type &[u32]: encountered a null reference
@@ -105,7 +105,7 @@ error[E0080]: evaluation panicked: assertion failed: 0 < pointee_size && pointee
105105
LL | pub static R1: &[()] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; // errors inside libcore
106106
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `R1` failed here
107107

108-
error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC10 which is only 4 bytes from the end of the allocation
108+
error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC$ID which is only 4 bytes from the end of the allocation
109109
--> $DIR/forbidden_slices.rs:54:25
110110
|
111111
LL | from_ptr_range(ptr..ptr.add(2)) // errors inside libcore
@@ -119,7 +119,7 @@ LL | pub static R4: &[u8] = unsafe {
119119
|
120120
= 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.
121121
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
122-
HEX_DUMP
122+
╾ALLOC$ID╼ HEX_DUMP
123123
}
124124

125125
error[E0080]: constructing invalid value of type &[u8]: at .<deref>[0], encountered a pointer, but expected an integer
@@ -132,7 +132,7 @@ LL | pub static R5: &[u8] = unsafe {
132132
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
133133
= 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.
134134
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
135-
HEX_DUMP
135+
╾ALLOC$ID╼ HEX_DUMP
136136
}
137137

138138
error[E0080]: constructing invalid value of type &[bool]: at .<deref>[0], encountered 0x11, but expected a boolean
@@ -143,7 +143,7 @@ LL | pub static R6: &[bool] = unsafe {
143143
|
144144
= 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.
145145
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
146-
HEX_DUMP
146+
╾ALLOC$ID╼ HEX_DUMP
147147
}
148148

149149
error[E0080]: constructing invalid value of type &[u16]: encountered an unaligned reference (required 2 byte alignment but found 1)
@@ -154,10 +154,10 @@ LL | pub static R7: &[u16] = unsafe {
154154
|
155155
= 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.
156156
= note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {
157-
HEX_DUMP
157+
╾ALLOC$ID╼ HEX_DUMP
158158
}
159159

160-
error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC11+0x1 which is only 7 bytes from the end of the allocation
160+
error[E0080]: in-bounds pointer arithmetic failed: attempting to offset pointer by 8 bytes, but got ALLOC$ID+0x1 which is only 7 bytes from the end of the allocation
161161
--> $DIR/forbidden_slices.rs:79:25
162162
|
163163
LL | from_ptr_range(ptr..ptr.add(1))

tests/ui/const-ptr/out_of_bounds_read.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fn main() {
22
use std::ptr;
3-
//@ ignore-parallel-frontend different alloc ids
3+
44
const DATA: [u32; 1] = [42];
55

66
const PAST_END_PTR: *const u32 = unsafe { DATA.as_ptr().add(1) };

tests/ui/const-ptr/out_of_bounds_read.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
1+
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes
22
--> $DIR/out_of_bounds_read.rs:8:33
33
|
44
LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
55
| ^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::_READ` failed here
66

7-
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
7+
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes
88
--> $DIR/out_of_bounds_read.rs:10:39
99
|
1010
LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
1111
| ^^^^^^^^^^^^^^^^^^^ evaluation of `main::_CONST_READ` failed here
1212

13-
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC0+0x4 which is at or beyond the end of the allocation of size 4 bytes
13+
error[E0080]: memory access failed: attempting to access 4 bytes, but got ALLOC$ID+0x4 which is at or beyond the end of the allocation of size 4 bytes
1414
--> $DIR/out_of_bounds_read.rs:12:37
1515
|
1616
LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };

0 commit comments

Comments
 (0)