Repository: elastio/bon (language: rust)

Issue:
warning: unexpected `cfg` condition name: `rust_analyzer`
hello

cargo check on latest nightly:
```
warning: unexpected `cfg` condition name: `rust_analyzer`
   --> game/src/card/components/mod.rs:29:45
    |
29  |               #[derive(Default, Debug, Clone, bon::Builder, Reflect, Serialize, Deserialize)]
    |                                               ^^^^^^^^^^^^
...
101 | / define_components! {
102 | |     struct CardHealth { pub current: u32, pub max: u32 },
103 | |     struct TroopHealth { pub current: u32, pub max: u32 },
104 | |     struct Cost(pub u32),
...   |
114 | |     struct TileExpansion {},
115 | | }
    | |_- in this macro invocation
    |
    = help: expected names are: `clippy`, `debug_assertions`, `doc`, `docsrs`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows`
    = help: consider using a Cargo feature instead
    = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
             [lints.rust]
             unexpected_cfgs = { level = "warn", check-cfg = ['cfg(rust_analyzer)'] }
    = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(rust_analyzer)");` to the top of the `build.rs`
    = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration
    = note: `#[warn(unexpected_cfgs)]` on by default
    = note: this warning originates in the derive macro `bon::Builder` which comes from the expansion of the macro `define_components` (in Nightly builds, run with -Z macro-backtrace for more info)
```

i think its the flag `unexpected_cfgs` which is now enable by default

### A note for the community from the maintainers

Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to help the maintainers with prioritizing it. You may add a comment describing your real use case related to this issue for us to better understand the problem domain.



Discussion / hints:

Fix patch:
diff --git a/bon-macros/src/builder/builder_gen/mod.rs b/bon-macros/src/builder/builder_gen/mod.rs
index 08b13870..6aeb98b6 100644
--- a/bon-macros/src/builder/builder_gen/mod.rs
+++ b/bon-macros/src/builder/builder_gen/mod.rs
@@ -149,17 +149,20 @@ impl BuilderGenCtx {
             // compiled by `rustc`. Rust Analyzer should be able to use the syntax
             // provided inside of the block to figure out the semantic meaning of
             // the tokens passed to the attribute.
-            #[cfg(rust_analyzer)]
+            #[allow(unexpected_cfgs)]
             {
-                // Let IDEs know that these are type patterns like the ones that
-                // could be written in a type annotation for a variable. Note that
-                // we don't initialize the variable with any value because we don't
-                // have any meaningful value to assign to this variable, especially
-                // because its type may contain wildcard patterns like `_`. This is
-                // used only to signal the IDEs that these tokens are meant to be
-                // type patterns by placing them in the context where type patterns
-                // are expected.
-                let _: (#(#type_patterns,)*);
+                #[cfg(rust_analyzer)]
+                {
+                    // Let IDEs know that these are type patterns like the ones that
+                    // could be written in a type annotation for a variable. Note that
+                    // we don't initialize the variable with any value because we don't
+                    // have any meaningful value to assign to this variable, especially
+                    // because its type may contain wildcard patterns like `_`. This is
+                    // used only to signal the IDEs that these tokens are meant to be
+                    // type patterns by placing them in the context where type patterns
+                    // are expected.
+                    let _: (#(#type_patterns,)*);
+                }
             }
         }
     }
diff --git a/bon-macros/src/util/ide.rs b/bon-macros/src/util/ide.rs
index a393efc5..9abf9d3f 100644
--- a/bon-macros/src/util/ide.rs
+++ b/bon-macros/src/util/ide.rs
@@ -176,9 +176,12 @@ pub(crate) fn generate_completion_triggers(meta: Vec<Meta>) -> TokenStream {
         // The special `rust_analyzer` CFG is enabled only when Rust Analyzer is
         // running its code analysis. This allows us to provide code that is
         // useful only for Rust Analyzer for it to provide hints and completions.
-        #[cfg(rust_analyzer)]
+        #[allow(unexpected_cfgs)]
         const _: () = {
-            #completion_triggers
+            #[cfg(rust_analyzer)]
+            {
+                #completion_triggers
+            }
         };
     }
 }
diff --git a/bon-sandbox/src/docs_comparison/methods.rs b/bon-sandbox/src/docs_comparison/methods.rs
index 1c68c7af..cdb14cf7 100644
--- a/bon-sandbox/src/docs_comparison/methods.rs
+++ b/bon-sandbox/src/docs_comparison/methods.rs
@@ -30,6 +30,10 @@ pub mod bon {
 
 /// Example docs generated with `buildstructor`
 #[expect(elided_lifetimes_in_paths)]
+// `buildstructor` generates a `#[cfg_attr(feature = "cargo-clippy", ...)]`,
+// which is not known to rustc. This lint comes from `nightly` at the time
+// of this writing, so using `allow` for now instead of `expect`
+#[allow(unexpected_cfgs)]
 pub mod buildstructor {
 
     /// Doc comment on `Struct`
diff --git a/bon-sandbox/src/docs_comparison/structs.rs b/bon-sandbox/src/docs_comparison/structs.rs
index 342876f9..775d181a 100644
--- a/bon-sandbox/src/docs_comparison/structs.rs
+++ b/bon-sandbox/src/docs_comparison/structs.rs
@@ -20,6 +20,10 @@ pub mod bon {
 }
 
 /// Example docs generated with `buildstructor`
+// `buildstructor` generates a `#[cfg_attr(feature = "cargo-clippy", ...)]`,
+// which is not known to rustc. This lint comes from `nightly` at the time
+// of this writing, so using `allow` for now instead of `expect`
+#[allow(unexpected_cfgs)]
 pub mod buildstructor {
     /// Doc comment on `Struct`
     #[derive(buildstructor::Builder)]


Test patch: