Adjust library tests for unused_tuple_struct_fields -> dead_code

This commit is contained in:
Jake Goulding 2023-12-27 18:03:23 -05:00
parent 9fcf9c1410
commit 5772818dc8
14 changed files with 39 additions and 38 deletions

View File

@ -24,6 +24,7 @@
//! Creating a recursive data structure:
//!
//! ```
//! ##[allow(dead_code)]
//! #[derive(Debug)]
//! enum List<T> {
//! Cons(T, Box<List<T>>),

View File

@ -171,7 +171,7 @@ struct WithHeader<H>(NonNull<u8>, PhantomData<H>);
/// An opaque representation of `WithHeader<H>` to avoid the
/// projection invariance of `<T as Pointee>::Metadata`.
#[repr(transparent)]
#[allow(unused_tuple_struct_fields)] // Field only used through `WithHeader` type above.
#[allow(dead_code)] // Field only used through `WithHeader` type above.
struct WithOpaqueHeader(NonNull<u8>);
impl WithOpaqueHeader {

View File

@ -524,7 +524,7 @@ fn test_extend_ref() {
#[test]
fn test_recovery() {
#[derive(Debug)]
struct Foo(&'static str, i32);
struct Foo(&'static str, #[allow(dead_code)] i32);
impl PartialEq for Foo {
fn eq(&self, other: &Self) -> bool {

View File

@ -1085,7 +1085,7 @@ fn test_clone_from() {
fn test_vec_deque_truncate_drop() {
static mut DROPS: u32 = 0;
#[derive(Clone)]
struct Elem(i32);
struct Elem(#[allow(dead_code)] i32);
impl Drop for Elem {
fn drop(&mut self) {
unsafe {

View File

@ -1,7 +1,7 @@
fn require_sync<T: Sync>(_: T) {}
fn require_send_sync<T: Send + Sync>(_: T) {}
struct NotSend(*const ());
struct NotSend(#[allow(dead_code)] *const ());
unsafe impl Sync for NotSend {}
#[test]

View File

@ -547,7 +547,7 @@ fn test_cmp() {
#[test]
fn test_vec_truncate_drop() {
static mut DROPS: u32 = 0;
struct Elem(i32);
struct Elem(#[allow(dead_code)] i32);
impl Drop for Elem {
fn drop(&mut self) {
unsafe {
@ -1089,7 +1089,7 @@ fn test_into_iter_advance_by() {
#[test]
fn test_into_iter_drop_allocator() {
struct ReferenceCountedAllocator<'a>(DropCounter<'a>);
struct ReferenceCountedAllocator<'a>(#[allow(dead_code)] DropCounter<'a>);
unsafe impl Allocator for ReferenceCountedAllocator<'_> {
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, core::alloc::AllocError> {
@ -2407,7 +2407,7 @@ fn test_vec_dedup_multiple_ident() {
#[test]
fn test_vec_dedup_partialeq() {
#[derive(Debug)]
struct Foo(i32, i32);
struct Foo(i32, #[allow(dead_code)] i32);
impl PartialEq for Foo {
fn eq(&self, other: &Foo) -> bool {

View File

@ -91,7 +91,7 @@ fn binary_search_l3_worst_case(b: &mut Bencher) {
}
#[derive(Clone)]
struct Rgb(u8, u8, u8);
struct Rgb(#[allow(dead_code)] u8, #[allow(dead_code)] u8, #[allow(dead_code)] u8);
impl Rgb {
fn gen(i: usize) -> Self {
@ -154,7 +154,7 @@ swap_with_slice!(swap_with_slice_5x_usize_3000, 3000, |i| [i; 5]);
#[bench]
fn fill_byte_sized(b: &mut Bencher) {
#[derive(Copy, Clone)]
struct NewType(u8);
struct NewType(#[allow(dead_code)] u8);
let mut ary = [NewType(0); 1024];

View File

@ -122,7 +122,7 @@ fn any_unsized() {
fn distinct_type_names() {
// https://github.com/rust-lang/rust/issues/84666
struct Velocity(f32, f32);
struct Velocity(#[allow(dead_code)] f32, #[allow(dead_code)] f32);
fn type_name_of_val<T>(_: T) -> &'static str {
type_name::<T>()

View File

@ -262,7 +262,7 @@ fn array_default_impl_avoids_leaks_on_panic() {
use core::sync::atomic::{AtomicUsize, Ordering::Relaxed};
static COUNTER: AtomicUsize = AtomicUsize::new(0);
#[derive(Debug)]
struct Bomb(usize);
struct Bomb(#[allow(dead_code)] usize);
impl Default for Bomb {
fn default() -> Bomb {

View File

@ -188,7 +188,7 @@ fn ptr_bitops() {
#[cfg(any(not(target_arch = "arm"), target_os = "linux"))] // Missing intrinsic in compiler-builtins
fn ptr_bitops_tagging() {
#[repr(align(16))]
struct Tagme(u128);
struct Tagme(#[allow(dead_code)] u128);
let tagme = Tagme(1000);
let ptr = &tagme as *const Tagme as *mut Tagme;

View File

@ -4,7 +4,7 @@ use core::intrinsics::assume;
#[test]
fn test_typeid_sized_types() {
struct X;
struct Y(u32);
struct Y(#[allow(dead_code)] u32);
assert_eq!(TypeId::of::<X>(), TypeId::of::<X>());
assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>());
@ -14,8 +14,8 @@ fn test_typeid_sized_types() {
#[test]
fn test_typeid_unsized_types() {
trait Z {}
struct X(str);
struct Y(dyn Z + 'static);
struct X(#[allow(dead_code)] str);
struct Y(#[allow(dead_code)] dyn Z + 'static);
assert_eq!(TypeId::of::<X>(), TypeId::of::<X>());
assert_eq!(TypeId::of::<Y>(), TypeId::of::<Y>());

View File

@ -451,34 +451,34 @@ fn align_offset_various_strides() {
for ptr in 1usize..4 * align {
unsafe {
#[repr(packed)]
struct A3(u16, u8);
struct A3(#[allow(dead_code)] u16, #[allow(dead_code)] u8);
x |= test_stride::<A3>(ptr::invalid::<A3>(ptr), align);
struct A4(u32);
struct A4(#[allow(dead_code)] u32);
x |= test_stride::<A4>(ptr::invalid::<A4>(ptr), align);
#[repr(packed)]
struct A5(u32, u8);
struct A5(#[allow(dead_code)] u32, #[allow(dead_code)] u8);
x |= test_stride::<A5>(ptr::invalid::<A5>(ptr), align);
#[repr(packed)]
struct A6(u32, u16);
struct A6(#[allow(dead_code)] u32, #[allow(dead_code)] u16);
x |= test_stride::<A6>(ptr::invalid::<A6>(ptr), align);
#[repr(packed)]
struct A7(u32, u16, u8);
struct A7(#[allow(dead_code)] u32, #[allow(dead_code)] u16, #[allow(dead_code)] u8);
x |= test_stride::<A7>(ptr::invalid::<A7>(ptr), align);
#[repr(packed)]
struct A8(u32, u32);
struct A8(#[allow(dead_code)] u32, #[allow(dead_code)] u32);
x |= test_stride::<A8>(ptr::invalid::<A8>(ptr), align);
#[repr(packed)]
struct A9(u32, u32, u8);
struct A9(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u8);
x |= test_stride::<A9>(ptr::invalid::<A9>(ptr), align);
#[repr(packed)]
struct A10(u32, u32, u16);
struct A10(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u16);
x |= test_stride::<A10>(ptr::invalid::<A10>(ptr), align);
x |= test_stride::<u32>(ptr::invalid::<u32>(ptr), align);
@ -517,34 +517,34 @@ fn align_offset_various_strides_const() {
while ptr < 4 * align {
unsafe {
#[repr(packed)]
struct A3(u16, u8);
struct A3(#[allow(dead_code)] u16, #[allow(dead_code)] u8);
test_stride::<A3>(ptr::invalid::<A3>(ptr), ptr, align);
struct A4(u32);
struct A4(#[allow(dead_code)] u32);
test_stride::<A4>(ptr::invalid::<A4>(ptr), ptr, align);
#[repr(packed)]
struct A5(u32, u8);
struct A5(#[allow(dead_code)] u32, #[allow(dead_code)] u8);
test_stride::<A5>(ptr::invalid::<A5>(ptr), ptr, align);
#[repr(packed)]
struct A6(u32, u16);
struct A6(#[allow(dead_code)] u32, #[allow(dead_code)] u16);
test_stride::<A6>(ptr::invalid::<A6>(ptr), ptr, align);
#[repr(packed)]
struct A7(u32, u16, u8);
struct A7(#[allow(dead_code)] u32, #[allow(dead_code)] u16, #[allow(dead_code)] u8);
test_stride::<A7>(ptr::invalid::<A7>(ptr), ptr, align);
#[repr(packed)]
struct A8(u32, u32);
struct A8(#[allow(dead_code)] u32, #[allow(dead_code)] u32);
test_stride::<A8>(ptr::invalid::<A8>(ptr), ptr, align);
#[repr(packed)]
struct A9(u32, u32, u8);
struct A9(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u8);
test_stride::<A9>(ptr::invalid::<A9>(ptr), ptr, align);
#[repr(packed)]
struct A10(u32, u32, u16);
struct A10(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u16);
test_stride::<A10>(ptr::invalid::<A10>(ptr), ptr, align);
test_stride::<u32>(ptr::invalid::<u32>(ptr), ptr, align);
@ -672,7 +672,7 @@ fn align_offset_issue_103361() {
const SIZE: usize = 1 << 30;
#[cfg(target_pointer_width = "16")]
const SIZE: usize = 1 << 13;
struct HugeSize([u8; SIZE - 1]);
struct HugeSize(#[allow(dead_code)] [u8; SIZE - 1]);
let _ = ptr::invalid::<HugeSize>(SIZE).align_offset(SIZE);
}
@ -684,7 +684,7 @@ fn align_offset_issue_103361_const() {
const SIZE: usize = 1 << 30;
#[cfg(target_pointer_width = "16")]
const SIZE: usize = 1 << 13;
struct HugeSize([u8; SIZE - 1]);
struct HugeSize(#[allow(dead_code)] [u8; SIZE - 1]);
const {
assert!(ptr::invalid::<HugeSize>(SIZE - 1).align_offset(SIZE) == SIZE - 1);
@ -834,7 +834,7 @@ fn ptr_metadata_bounds() {
fn dyn_metadata() {
#[derive(Debug)]
#[repr(align(32))]
struct Something([u8; 47]);
struct Something(#[allow(dead_code)] [u8; 47]);
let value = Something([0; 47]);
let trait_object: &dyn Debug = &value;

View File

@ -2109,9 +2109,9 @@ fn test_align_to_zst() {
#[test]
fn test_align_to_non_trivial() {
#[repr(align(8))]
struct U64(u64, u64);
struct U64(#[allow(dead_code)] u64, #[allow(dead_code)] u64);
#[repr(align(8))]
struct U64U64U32(u64, u64, u32);
struct U64U64U32(#[allow(dead_code)] u64, #[allow(dead_code)] u64, #[allow(dead_code)] u32);
let data = [
U64(1, 2),
U64(3, 4),
@ -2196,7 +2196,7 @@ fn test_slice_partition_dedup_multiple_ident() {
#[test]
fn test_slice_partition_dedup_partialeq() {
#[derive(Debug)]
struct Foo(i32, i32);
struct Foo(i32, #[allow(dead_code)] i32);
impl PartialEq for Foo {
fn eq(&self, other: &Foo) -> bool {

View File

@ -352,7 +352,7 @@ fn test_replace() {
use crate::hash;
#[derive(Debug)]
struct Foo(&'static str, i32);
struct Foo(&'static str, #[allow(dead_code)] i32);
impl PartialEq for Foo {
fn eq(&self, other: &Self) -> bool {