From 92f405d4c81c067cf7688d0549a9938b412ee803 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 5 Jan 2024 18:52:32 -0800 Subject: Work around new dead_code warnings 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), | -- ^^^^^ ^^^^^^^^^^^^^^ | | | 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), | --- ^^^^^^^^^^^^ | | | 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), | --- ^^^^^^^^^^^^ | | | 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>(()); | ~~ --- src/lib.rs | 2 +- syntax/cfg.rs | 3 +++ syntax/mod.rs | 1 + tests/ffi/lib.rs | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d2c7cf39..34a88592 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -548,4 +548,4 @@ chars! { } #[repr(transparent)] -struct void(core::ffi::c_void); +struct void(#[allow(dead_code)] core::ffi::c_void); diff --git a/syntax/cfg.rs b/syntax/cfg.rs index 83511d73..070813ee 100644 --- a/syntax/cfg.rs +++ b/syntax/cfg.rs @@ -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), All(Vec), + #[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro Any(Vec), + #[allow(dead_code)] // only used by cxx-build, not cxxbridge-macro Not(Box), } diff --git a/syntax/mod.rs b/syntax/mod.rs index 5ff343b4..eacba554 100644 --- a/syntax/mod.rs +++ b/syntax/mod.rs @@ -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), diff --git a/tests/ffi/lib.rs b/tests/ffi/lib.rs index ef8d5b37..f3a8310f 100644 --- a/tests/ffi/lib.rs +++ b/tests/ffi/lib.rs @@ -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 { -- cgit v1.2.3