Skip to content

Commit

Permalink
Work around new dead_code warnings
Browse files Browse the repository at this point in the history
    warning: field `0` is never read
      --> macro/src/syntax/mod.rs:52:13
       |
    52 |     Include(Include),
       |     ------- ^^^^^^^
       |     |
       |     field in this variant
       |
       = note: `#[warn(dead_code)]` on by default
    help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
       |
    52 |     Include(()),
       |             ~~

    warning: fields `0` and `1` are never read
     --> macro/src/syntax/cfg.rs:9:8
      |
    9 |     Eq(Ident, Option<LitStr>),
      |     -- ^^^^^  ^^^^^^^^^^^^^^
      |     |
      |     fields in this variant
      |
    help: consider changing the fields to be of unit type to suppress this warning while preserving the field numbering, or remove the fields
      |
    9 |     Eq((), ()),
      |        ~~  ~~

    warning: field `0` is never read
      --> macro/src/syntax/cfg.rs:11:9
       |
    11 |     Any(Vec<CfgExpr>),
       |     --- ^^^^^^^^^^^^
       |     |
       |     field in this variant
       |
    help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
       |
    11 |     Any(()),
       |         ~~

    warning: field `0` is never read
      --> macro/src/syntax/cfg.rs:12:9
       |
    12 |     Not(Box<CfgExpr>),
       |     --- ^^^^^^^^^^^^
       |     |
       |     field in this variant
       |
    help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
       |
    12 |     Not(()),
       |         ~~

    warning: field `0` is never read
       --> src/lib.rs:551:13
        |
    551 | struct void(core::ffi::c_void);
        |        ---- ^^^^^^^^^^^^^^^^^
        |        |
        |        field in this struct
        |
        = note: `#[warn(dead_code)]` on by default
    help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
        |
    551 | struct void(());
        |             ~~

    warning: field `0` is never read
       --> tests/ffi/lib.rs:411:26
        |
    411 | pub struct Reference<'a>(&'a String);
        |            ---------     ^^^^^^^^^^
        |            |
        |            field in this struct
        |
        = note: `#[warn(dead_code)]` on by default
    help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field
        |
    411 | pub struct Reference<'a>(());
        |                          ~~
  • Loading branch information
dtolnay committed Jan 6, 2024
1 parent 2e0af3b commit 92f405d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,4 +548,4 @@ chars! {
}

#[repr(transparent)]
struct void(core::ffi::c_void);
struct void(#[allow(dead_code)] core::ffi::c_void);
3 changes: 3 additions & 0 deletions syntax/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ use syn::{parenthesized, token, Attribute, LitStr, Token};
#[derive(Clone)]
pub(crate) enum CfgExpr {
Unconditional,
#[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
Eq(Ident, Option<LitStr>),
All(Vec<CfgExpr>),
#[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
Any(Vec<CfgExpr>),
#[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
Not(Box<CfgExpr>),
}

Expand Down
1 change: 1 addition & 0 deletions syntax/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub(crate) use self::parse::parse_items;
pub(crate) use self::types::Types;

pub(crate) enum Api {
#[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro
Include(Include),
Struct(Struct),
Enum(Enum),
Expand Down
2 changes: 1 addition & 1 deletion tests/ffi/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ impl R {
}
}

pub struct Reference<'a>(&'a String);
pub struct Reference<'a>(pub &'a String);

impl ffi::Shared {
fn r_method_on_shared(&self) -> String {
Expand Down

0 comments on commit 92f405d

Please sign in to comment.