Skip to content

Commit

Permalink
Ignore dead_code warnings for tuple structs
Browse files Browse the repository at this point in the history
```
error: field `0` is never read
   --> src/lib.rs:756:23
    |
756 |     pub struct Align1(u8);
    |                ------ ^^
    |                |
    |                field in this struct
    |
    = note: `-D dead-code` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(dead_code)]`
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
756 |     pub struct Align1(());
    |                       ~~

error: field `0` is never read
   --> src/lib.rs:758:23
    |
758 |     pub struct Align2(u16);
    |                ------ ^^^
    |                |
    |                field in this struct
    |
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
758 |     pub struct Align2(());
    |                       ~~

error: field `0` is never read
   --> src/lib.rs:760:23
    |
760 |     pub struct Align4(u32);
    |                ------ ^^^
    |                |
    |                field in this struct
    |
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
760 |     pub struct Align4(());
    |                       ~~

error: field `0` is never read
   --> src/lib.rs:762:23
    |
762 |     pub struct Align8(u64);
    |                ------ ^^^
    |                |
    |                field in this struct
    |
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
762 |     pub struct Align8(());
    |                       ~~

error: field `0` is never read
   --> src/lib.rs:764:24
    |
764 |     pub struct Align16(u128);
    |                ------- ^^^^
    |                |
    |                field in this struct
    |
help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
    |
764 |     pub struct Align16(());
    |                        ~~
```
  • Loading branch information
taiki-e committed Jan 6, 2024
1 parent 75630d0 commit 2b9b7f9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,15 +752,15 @@ mod private {
}

#[repr(align(1))]
pub struct Align1(u8);
pub struct Align1(#[allow(dead_code)] u8);
#[repr(align(2))]
pub struct Align2(u16);
pub struct Align2(#[allow(dead_code)] u16);
#[repr(align(4))]
pub struct Align4(u32);
pub struct Align4(#[allow(dead_code)] u32);
#[repr(align(8))]
pub struct Align8(u64);
pub struct Align8(#[allow(dead_code)] u64);
#[repr(align(16))]
pub struct Align16(u128);
pub struct Align16(#[allow(dead_code)] u128);
#[cfg(target_pointer_width = "16")]
pub(crate) type AlignPtr = Align2;
#[cfg(target_pointer_width = "32")]
Expand Down

0 comments on commit 2b9b7f9

Please sign in to comment.