Skip to content

Commit fc8b13c

Browse files
committed
Adapt rustc_data_structures tests to run in strict miri
Some tests took too long and owning_ref is fundamentally flawed, so don't run these tests or run them with a shorter N. This makes miri with `-Zmiri-strict-provenance` usable to find UB.
1 parent 44e9516 commit fc8b13c

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

compiler/rustc_data_structures/src/base_n/tests.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ fn test_encode() {
1515
test(u64::MAX as u128, base);
1616
test(u128::MAX, base);
1717

18-
for i in 0..1_000 {
18+
const N: u128 = if cfg!(miri) { 10 } else { 1000 };
19+
20+
for i in 0..N {
1921
test(i * 983, base);
2022
}
2123
}

compiler/rustc_data_structures/src/graph/scc/tests.rs

+3
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ fn test_deep_linear() {
156156
v
157157
158158
*/
159+
#[cfg(not(miri))]
159160
const NR_NODES: usize = 1 << 14;
161+
#[cfg(miri)]
162+
const NR_NODES: usize = 1 << 3;
160163
let mut nodes = vec![];
161164
for i in 1..NR_NODES {
162165
nodes.push((i - 1, i));

compiler/rustc_data_structures/src/owning_ref/tests.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// FIXME: owning_ref is not sound under stacked borrows. Preferably, get rid of it.
2+
#[cfg(not(miri))]
13
mod owning_ref {
24
use super::super::OwningRef;
35
use super::super::{BoxRef, Erased, ErasedBoxRef, RcRef};
@@ -361,6 +363,8 @@ mod owning_handle {
361363
}
362364
}
363365

366+
// FIXME: owning_ref is not sound under stacked borrows. Preferably, get rid of it.
367+
#[cfg(not(miri))]
364368
mod owning_ref_mut {
365369
use super::super::BoxRef;
366370
use super::super::{BoxRefMut, Erased, ErasedBoxRefMut, OwningRefMut};

0 commit comments

Comments
 (0)