Skip to content

Commit 5772818

Browse files
committed
Adjust library tests for unused_tuple_struct_fields -> dead_code
1 parent 9fcf9c1 commit 5772818

File tree

14 files changed

+39
-38
lines changed

14 files changed

+39
-38
lines changed

library/alloc/src/boxed.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
//! Creating a recursive data structure:
2525
//!
2626
//! ```
27+
//! ##[allow(dead_code)]
2728
//! #[derive(Debug)]
2829
//! enum List<T> {
2930
//! Cons(T, Box<List<T>>),

library/alloc/src/boxed/thin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ struct WithHeader<H>(NonNull<u8>, PhantomData<H>);
171171
/// An opaque representation of `WithHeader<H>` to avoid the
172172
/// projection invariance of `<T as Pointee>::Metadata`.
173173
#[repr(transparent)]
174-
#[allow(unused_tuple_struct_fields)] // Field only used through `WithHeader` type above.
174+
#[allow(dead_code)] // Field only used through `WithHeader` type above.
175175
struct WithOpaqueHeader(NonNull<u8>);
176176

177177
impl WithOpaqueHeader {

library/alloc/src/collections/btree/set/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ fn test_extend_ref() {
524524
#[test]
525525
fn test_recovery() {
526526
#[derive(Debug)]
527-
struct Foo(&'static str, i32);
527+
struct Foo(&'static str, #[allow(dead_code)] i32);
528528

529529
impl PartialEq for Foo {
530530
fn eq(&self, other: &Self) -> bool {

library/alloc/src/collections/vec_deque/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ fn test_clone_from() {
10851085
fn test_vec_deque_truncate_drop() {
10861086
static mut DROPS: u32 = 0;
10871087
#[derive(Clone)]
1088-
struct Elem(i32);
1088+
struct Elem(#[allow(dead_code)] i32);
10891089
impl Drop for Elem {
10901090
fn drop(&mut self) {
10911091
unsafe {

library/alloc/tests/autotraits.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
fn require_sync<T: Sync>(_: T) {}
22
fn require_send_sync<T: Send + Sync>(_: T) {}
33

4-
struct NotSend(*const ());
4+
struct NotSend(#[allow(dead_code)] *const ());
55
unsafe impl Sync for NotSend {}
66

77
#[test]

library/alloc/tests/vec.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ fn test_cmp() {
547547
#[test]
548548
fn test_vec_truncate_drop() {
549549
static mut DROPS: u32 = 0;
550-
struct Elem(i32);
550+
struct Elem(#[allow(dead_code)] i32);
551551
impl Drop for Elem {
552552
fn drop(&mut self) {
553553
unsafe {
@@ -1089,7 +1089,7 @@ fn test_into_iter_advance_by() {
10891089

10901090
#[test]
10911091
fn test_into_iter_drop_allocator() {
1092-
struct ReferenceCountedAllocator<'a>(DropCounter<'a>);
1092+
struct ReferenceCountedAllocator<'a>(#[allow(dead_code)] DropCounter<'a>);
10931093

10941094
unsafe impl Allocator for ReferenceCountedAllocator<'_> {
10951095
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, core::alloc::AllocError> {
@@ -2407,7 +2407,7 @@ fn test_vec_dedup_multiple_ident() {
24072407
#[test]
24082408
fn test_vec_dedup_partialeq() {
24092409
#[derive(Debug)]
2410-
struct Foo(i32, i32);
2410+
struct Foo(i32, #[allow(dead_code)] i32);
24112411

24122412
impl PartialEq for Foo {
24132413
fn eq(&self, other: &Foo) -> bool {

library/core/benches/slice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn binary_search_l3_worst_case(b: &mut Bencher) {
9191
}
9292

9393
#[derive(Clone)]
94-
struct Rgb(u8, u8, u8);
94+
struct Rgb(#[allow(dead_code)] u8, #[allow(dead_code)] u8, #[allow(dead_code)] u8);
9595

9696
impl Rgb {
9797
fn gen(i: usize) -> Self {
@@ -154,7 +154,7 @@ swap_with_slice!(swap_with_slice_5x_usize_3000, 3000, |i| [i; 5]);
154154
#[bench]
155155
fn fill_byte_sized(b: &mut Bencher) {
156156
#[derive(Copy, Clone)]
157-
struct NewType(u8);
157+
struct NewType(#[allow(dead_code)] u8);
158158

159159
let mut ary = [NewType(0); 1024];
160160

library/core/tests/any.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn any_unsized() {
122122
fn distinct_type_names() {
123123
// https://github.com/rust-lang/rust/issues/84666
124124

125-
struct Velocity(f32, f32);
125+
struct Velocity(#[allow(dead_code)] f32, #[allow(dead_code)] f32);
126126

127127
fn type_name_of_val<T>(_: T) -> &'static str {
128128
type_name::<T>()

library/core/tests/array.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ fn array_default_impl_avoids_leaks_on_panic() {
262262
use core::sync::atomic::{AtomicUsize, Ordering::Relaxed};
263263
static COUNTER: AtomicUsize = AtomicUsize::new(0);
264264
#[derive(Debug)]
265-
struct Bomb(usize);
265+
struct Bomb(#[allow(dead_code)] usize);
266266

267267
impl Default for Bomb {
268268
fn default() -> Bomb {

library/core/tests/atomic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ fn ptr_bitops() {
188188
#[cfg(any(not(target_arch = "arm"), target_os = "linux"))] // Missing intrinsic in compiler-builtins
189189
fn ptr_bitops_tagging() {
190190
#[repr(align(16))]
191-
struct Tagme(u128);
191+
struct Tagme(#[allow(dead_code)] u128);
192192

193193
let tagme = Tagme(1000);
194194
let ptr = &tagme as *const Tagme as *mut Tagme;

library/core/tests/intrinsics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::intrinsics::assume;
44
#[test]
55
fn test_typeid_sized_types() {
66
struct X;
7-
struct Y(u32);
7+
struct Y(#[allow(dead_code)] u32);
88

99
assert_eq!(TypeId::of::<X>(), TypeId::of::<X>());
1010
assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>());
@@ -14,8 +14,8 @@ fn test_typeid_sized_types() {
1414
#[test]
1515
fn test_typeid_unsized_types() {
1616
trait Z {}
17-
struct X(str);
18-
struct Y(dyn Z + 'static);
17+
struct X(#[allow(dead_code)] str);
18+
struct Y(#[allow(dead_code)] dyn Z + 'static);
1919

2020
assert_eq!(TypeId::of::<X>(), TypeId::of::<X>());
2121
assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>());

library/core/tests/ptr.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -451,34 +451,34 @@ fn align_offset_various_strides() {
451451
for ptr in 1usize..4 * align {
452452
unsafe {
453453
#[repr(packed)]
454-
struct A3(u16, u8);
454+
struct A3(#[allow(dead_code)] u16, #[allow(dead_code)] u8);
455455
x |= test_stride::<A3>(ptr::invalid::<A3>(ptr), align);
456456

457-
struct A4(u32);
457+
struct A4(#[allow(dead_code)] u32);
458458
x |= test_stride::<A4>(ptr::invalid::<A4>(ptr), align);
459459

460460
#[repr(packed)]
461-
struct A5(u32, u8);
461+
struct A5(#[allow(dead_code)] u32, #[allow(dead_code)] u8);
462462
x |= test_stride::<A5>(ptr::invalid::<A5>(ptr), align);
463463

464464
#[repr(packed)]
465-
struct A6(u32, u16);
465+
struct A6(#[allow(dead_code)] u32, #[allow(dead_code)] u16);
466466
x |= test_stride::<A6>(ptr::invalid::<A6>(ptr), align);
467467

468468
#[repr(packed)]
469-
struct A7(u32, u16, u8);
469+
struct A7(#[allow(dead_code)] u32, #[allow(dead_code)] u16, #[allow(dead_code)] u8);
470470
x |= test_stride::<A7>(ptr::invalid::<A7>(ptr), align);
471471

472472
#[repr(packed)]
473-
struct A8(u32, u32);
473+
struct A8(#[allow(dead_code)] u32, #[allow(dead_code)] u32);
474474
x |= test_stride::<A8>(ptr::invalid::<A8>(ptr), align);
475475

476476
#[repr(packed)]
477-
struct A9(u32, u32, u8);
477+
struct A9(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u8);
478478
x |= test_stride::<A9>(ptr::invalid::<A9>(ptr), align);
479479

480480
#[repr(packed)]
481-
struct A10(u32, u32, u16);
481+
struct A10(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u16);
482482
x |= test_stride::<A10>(ptr::invalid::<A10>(ptr), align);
483483

484484
x |= test_stride::<u32>(ptr::invalid::<u32>(ptr), align);
@@ -517,34 +517,34 @@ fn align_offset_various_strides_const() {
517517
while ptr < 4 * align {
518518
unsafe {
519519
#[repr(packed)]
520-
struct A3(u16, u8);
520+
struct A3(#[allow(dead_code)] u16, #[allow(dead_code)] u8);
521521
test_stride::<A3>(ptr::invalid::<A3>(ptr), ptr, align);
522522

523-
struct A4(u32);
523+
struct A4(#[allow(dead_code)] u32);
524524
test_stride::<A4>(ptr::invalid::<A4>(ptr), ptr, align);
525525

526526
#[repr(packed)]
527-
struct A5(u32, u8);
527+
struct A5(#[allow(dead_code)] u32, #[allow(dead_code)] u8);
528528
test_stride::<A5>(ptr::invalid::<A5>(ptr), ptr, align);
529529

530530
#[repr(packed)]
531-
struct A6(u32, u16);
531+
struct A6(#[allow(dead_code)] u32, #[allow(dead_code)] u16);
532532
test_stride::<A6>(ptr::invalid::<A6>(ptr), ptr, align);
533533

534534
#[repr(packed)]
535-
struct A7(u32, u16, u8);
535+
struct A7(#[allow(dead_code)] u32, #[allow(dead_code)] u16, #[allow(dead_code)] u8);
536536
test_stride::<A7>(ptr::invalid::<A7>(ptr), ptr, align);
537537

538538
#[repr(packed)]
539-
struct A8(u32, u32);
539+
struct A8(#[allow(dead_code)] u32, #[allow(dead_code)] u32);
540540
test_stride::<A8>(ptr::invalid::<A8>(ptr), ptr, align);
541541

542542
#[repr(packed)]
543-
struct A9(u32, u32, u8);
543+
struct A9(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u8);
544544
test_stride::<A9>(ptr::invalid::<A9>(ptr), ptr, align);
545545

546546
#[repr(packed)]
547-
struct A10(u32, u32, u16);
547+
struct A10(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u16);
548548
test_stride::<A10>(ptr::invalid::<A10>(ptr), ptr, align);
549549

550550
test_stride::<u32>(ptr::invalid::<u32>(ptr), ptr, align);
@@ -672,7 +672,7 @@ fn align_offset_issue_103361() {
672672
const SIZE: usize = 1 << 30;
673673
#[cfg(target_pointer_width = "16")]
674674
const SIZE: usize = 1 << 13;
675-
struct HugeSize([u8; SIZE - 1]);
675+
struct HugeSize(#[allow(dead_code)] [u8; SIZE - 1]);
676676
let _ = ptr::invalid::<HugeSize>(SIZE).align_offset(SIZE);
677677
}
678678

@@ -684,7 +684,7 @@ fn align_offset_issue_103361_const() {
684684
const SIZE: usize = 1 << 30;
685685
#[cfg(target_pointer_width = "16")]
686686
const SIZE: usize = 1 << 13;
687-
struct HugeSize([u8; SIZE - 1]);
687+
struct HugeSize(#[allow(dead_code)] [u8; SIZE - 1]);
688688

689689
const {
690690
assert!(ptr::invalid::<HugeSize>(SIZE - 1).align_offset(SIZE) == SIZE - 1);
@@ -834,7 +834,7 @@ fn ptr_metadata_bounds() {
834834
fn dyn_metadata() {
835835
#[derive(Debug)]
836836
#[repr(align(32))]
837-
struct Something([u8; 47]);
837+
struct Something(#[allow(dead_code)] [u8; 47]);
838838

839839
let value = Something([0; 47]);
840840
let trait_object: &dyn Debug = &value;

library/core/tests/slice.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2109,9 +2109,9 @@ fn test_align_to_zst() {
21092109
#[test]
21102110
fn test_align_to_non_trivial() {
21112111
#[repr(align(8))]
2112-
struct U64(u64, u64);
2112+
struct U64(#[allow(dead_code)] u64, #[allow(dead_code)] u64);
21132113
#[repr(align(8))]
2114-
struct U64U64U32(u64, u64, u32);
2114+
struct U64U64U32(#[allow(dead_code)] u64, #[allow(dead_code)] u64, #[allow(dead_code)] u32);
21152115
let data = [
21162116
U64(1, 2),
21172117
U64(3, 4),
@@ -2196,7 +2196,7 @@ fn test_slice_partition_dedup_multiple_ident() {
21962196
#[test]
21972197
fn test_slice_partition_dedup_partialeq() {
21982198
#[derive(Debug)]
2199-
struct Foo(i32, i32);
2199+
struct Foo(i32, #[allow(dead_code)] i32);
22002200

22012201
impl PartialEq for Foo {
22022202
fn eq(&self, other: &Foo) -> bool {

library/std/src/collections/hash/set/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ fn test_replace() {
352352
use crate::hash;
353353

354354
#[derive(Debug)]
355-
struct Foo(&'static str, i32);
355+
struct Foo(&'static str, #[allow(dead_code)] i32);
356356

357357
impl PartialEq for Foo {
358358
fn eq(&self, other: &Self) -> bool {

0 commit comments

Comments
 (0)