Skip to content

Commit 10f4023

Browse files
committed
Allow unused tuple struct fields in Miri tests
Otherwise the newly-detected dead code causes new output
1 parent 93f5530 commit 10f4023

21 files changed

+23
-23
lines changed

src/tools/miri/tests/fail/both_borrows/newtype_pair_retagging.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
//@[stack]error-in-other-file: which is strongly protected
55
//@[tree]error-in-other-file: /deallocation through .* is forbidden/
6-
struct Newtype<'a>(&'a mut i32, i32);
6+
struct Newtype<'a>(#[allow(dead_code)] &'a mut i32, #[allow(dead_code)] i32);
77

88
fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) {
99
dealloc();

src/tools/miri/tests/fail/both_borrows/newtype_retagging.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//@[stack]error-in-other-file: which is strongly protected
55
//@[tree]error-in-other-file: /deallocation through .* is forbidden/
66

7-
struct Newtype<'a>(&'a mut i32);
7+
struct Newtype<'a>(#[allow(dead_code)] &'a mut i32);
88

99
fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) {
1010
dealloc();

src/tools/miri/tests/fail/concurrency/read_only_atomic_load_large.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use std::sync::atomic::{AtomicI64, Ordering};
77

88
#[repr(align(8))]
9-
struct AlignedI64(i64);
9+
struct AlignedI64(#[allow(dead_code)] i64);
1010

1111
fn main() {
1212
static X: AlignedI64 = AlignedI64(0);

src/tools/miri/tests/fail/dangling_pointers/dyn_size.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// should find the bug even without retagging
22
//@compile-flags: -Zmiri-disable-stacked-borrows
33

4-
struct SliceWithHead(u8, [u8]);
4+
struct SliceWithHead(#[allow(dead_code)] u8, #[allow(dead_code)] [u8]);
55

66
fn main() {
77
let buf = [0u32; 1];

src/tools/miri/tests/fail/function_pointers/abi_mismatch_array_vs_struct.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Some targets treat arrays and structs very differently. We would probably catch that on those
44
// targets since we check the `PassMode`; here we ensure that we catch it on *all* targets
55
// (in particular, on x86-64 the pass mode is `Indirect` for both of these).
6-
struct S(i32, i32, i32, i32);
6+
struct S(#[allow(dead_code)] i32, #[allow(dead_code)] i32, #[allow(dead_code)] i32, #[allow(dead_code)] i32);
77
type A = [i32; 4];
88

99
fn main() {

src/tools/miri/tests/fail/issue-miri-1112.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
trait Empty {}
22

33
#[repr(transparent)]
4-
pub struct FunnyPointer(dyn Empty);
4+
pub struct FunnyPointer(#[allow(dead_code)] dyn Empty);
55

66
#[repr(C)]
77
pub struct Meta {

src/tools/miri/tests/fail/unaligned_pointers/drop_in_place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@compile-flags: -Cdebug-assertions=no
22

33
#[repr(transparent)]
4-
struct HasDrop(u8);
4+
struct HasDrop(#[allow(dead_code)] u8);
55

66
impl Drop for HasDrop {
77
fn drop(&mut self) {}

src/tools/miri/tests/fail/unaligned_pointers/promise_alignment.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ mod utils;
77

88
#[repr(align(8))]
99
#[derive(Copy, Clone)]
10-
struct Align8(u64);
10+
struct Align8(#[allow(dead_code)] u64);
1111

1212
fn main() {
1313
let buffer = [0u32; 128]; // get some 4-aligned memory
@@ -35,7 +35,7 @@ fn main() {
3535
if cfg!(read_unaligned_ptr) {
3636
#[repr(align(16))]
3737
#[derive(Copy, Clone)]
38-
struct Align16(u128);
38+
struct Align16(#[allow(dead_code)] u128);
3939

4040
let align16 = if align8.addr() % 16 == 0 { align8 } else { align8.wrapping_add(2) };
4141
assert!(align16.addr() % 16 == 0);

src/tools/miri/tests/pass/align_offset_symbolic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn test_align_to() {
4646
{
4747
#[repr(align(8))]
4848
#[derive(Copy, Clone)]
49-
struct Align8(u64);
49+
struct Align8(#[allow(dead_code)] u64);
5050

5151
let (_l, m, _r) = unsafe { s.align_to::<Align8>() };
5252
assert!(m.len() > 0);
@@ -97,7 +97,7 @@ fn huge_align() {
9797
const SIZE: usize = 1 << 30;
9898
#[cfg(target_pointer_width = "16")]
9999
const SIZE: usize = 1 << 13;
100-
struct HugeSize([u8; SIZE - 1]);
100+
struct HugeSize(#[allow(dead_code)] [u8; SIZE - 1]);
101101
let _ = std::ptr::invalid::<HugeSize>(SIZE).align_offset(SIZE);
102102
}
103103

src/tools/miri/tests/pass/box-custom-alloc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn test1() {
5757
}
5858

5959
// Make the allocator itself so big that the Box is not even a ScalarPair any more.
60-
struct OnceAllocRef<'s, 'a>(&'s OnceAlloc<'a>, u64);
60+
struct OnceAllocRef<'s, 'a>(&'s OnceAlloc<'a>, #[allow(dead_code)] u64);
6161

6262
unsafe impl<'shared, 'a: 'shared> Allocator for OnceAllocRef<'shared, 'a> {
6363
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {

src/tools/miri/tests/pass/box.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ fn boxed_pair_to_vec() {
4646
}
4747

4848
#[derive(Debug)]
49-
struct Foo(u64);
49+
struct Foo(#[allow(dead_code)] u64);
5050
fn reinterstruct(box_pair: Box<PairFoo>) -> Vec<Foo> {
5151
let ref_pair = Box::leak(box_pair) as *mut PairFoo;
5252
let ptr_foo = unsafe { std::ptr::addr_of_mut!((*ref_pair).fst) };

src/tools/miri/tests/pass/fat_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// test that ordinary fat pointer operations work.
22

3-
struct Wrapper<T: ?Sized>(u32, T);
3+
struct Wrapper<T: ?Sized>(#[allow(dead_code)] u32, T);
44

55
struct FatPtrContainer<'a> {
66
ptr: &'a [u8],

src/tools/miri/tests/pass/issues/issue-3200-packed2-field-offset.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use std::mem;
33

44
#[repr(packed(4))]
5-
struct Slice([u32]);
5+
struct Slice(#[allow(dead_code)] [u32]);
66

77
#[repr(packed(2), C)]
88
struct PackedSized {

src/tools/miri/tests/pass/issues/issue-34571.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[repr(u8)]
22
enum Foo {
3-
Foo(u8),
3+
Foo(#[allow(dead_code)] u8),
44
}
55

66
fn main() {

src/tools/miri/tests/pass/issues/issue-36278-prefix-nesting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use std::mem;
55

66
const SZ: usize = 100;
7-
struct P<T: ?Sized>([u8; SZ], T);
7+
struct P<T: ?Sized>(#[allow(dead_code)] [u8; SZ], T);
88

99
type Ack<T> = P<P<T>>;
1010

src/tools/miri/tests/pass/packed_struct.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn test_inner_packed() {
102102
struct Inner(u32);
103103

104104
#[derive(Clone, Copy)]
105-
struct Outer(u8, Inner);
105+
struct Outer(#[allow(dead_code)] u8, Inner);
106106

107107
let o = Outer(0, Inner(42));
108108
let _x = o.1;

src/tools/miri/tests/pass/stacked-borrows/no_field_retagging.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@compile-flags: -Zmiri-retag-fields=none
22

3-
struct Newtype<'a>(&'a mut i32);
3+
struct Newtype<'a>(#[allow(dead_code)] &'a mut i32);
44

55
fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) {
66
dealloc();

src/tools/miri/tests/pass/stacked-borrows/non_scalar_field_retagging.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@compile-flags: -Zmiri-retag-fields=scalar
22

3-
struct Newtype<'a>(&'a mut i32, i32, i32);
3+
struct Newtype<'a>(#[allow(dead_code)] &'a mut i32, #[allow(dead_code)] i32, #[allow(dead_code)] i32);
44

55
fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) {
66
dealloc();

src/tools/miri/tests/pass/stacked-borrows/stacked-borrows.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ fn not_unpin_not_protected() {
226226
// the self-referential-coroutine situation, it does not seem worth the potential trouble.)
227227
use std::marker::PhantomPinned;
228228

229-
pub struct NotUnpin(i32, PhantomPinned);
229+
pub struct NotUnpin(#[allow(dead_code)] i32, PhantomPinned);
230230

231231
fn inner(x: &mut NotUnpin, f: fn(&mut NotUnpin)) {
232232
// `f` may mutate, but it may not deallocate!

src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ fn not_unpin_not_protected() {
318318
// the self-referential-coroutine situation, it does not seem worth the potential trouble.)
319319
use std::marker::PhantomPinned;
320320

321-
pub struct NotUnpin(i32, PhantomPinned);
321+
pub struct NotUnpin(#[allow(dead_code)] i32, PhantomPinned);
322322

323323
fn inner(x: &mut NotUnpin, f: fn(&mut NotUnpin)) {
324324
// `f` may mutate, but it may not deallocate!

src/tools/miri/tests/pass/zst_variant_drop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ impl Drop for Foo {
1010
static mut FOO: bool = false;
1111

1212
enum Bar {
13-
A(Box<i32>),
13+
A(#[allow(dead_code)] Box<i32>),
1414
B(Foo),
1515
}
1616

0 commit comments

Comments
 (0)