Skip to content

Commit 1f9a9d4

Browse files
committed
Ignore unexpected_cfgs lint for generated code
``` error: unexpected `cfg` condition name: `rustfmt` --> src/gen/ast_struct.rs:6:13 | 6 | #![cfg_attr(rustfmt, rustfmt::skip)] | ^^^^^^^ | = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(rustfmt)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration error: unexpected `cfg` condition name: `rustfmt` --> src/gen/ast_enum.rs:6:13 | 6 | #![cfg_attr(rustfmt, rustfmt::skip)] | ^^^^^^^ | = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(rustfmt)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration error: unexpected `cfg` condition name: `rustfmt` --> src/gen/convert.rs:6:13 | 6 | #![cfg_attr(rustfmt, rustfmt::skip)] | ^^^^^^^ | = help: consider using a Cargo feature instead or adding `println!("cargo::rustc-check-cfg=cfg(rustfmt)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#rustc-check-cfg> for more information about checking conditional configuration ``` Due to rust-lang/rust#124735, we cannot disable this lint at module-level.
1 parent 851f165 commit 1f9a9d4

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ The data structures of syn-serde 0.3 is compatible with the data structures of
130130
)]
131131
// docs.rs only (cfg is enabled by docs.rs, not build script)
132132
#![cfg_attr(docsrs, feature(doc_cfg))]
133+
#![allow(unknown_lints, unexpected_cfgs)] // https://github.com/rust-lang/rust/issues/124735
133134

134135
#[macro_use]
135136
mod macros;

tools/codegen/src/file.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ pub(crate) fn workspace_root() -> PathBuf {
3131
#[track_caller]
3232
pub(crate) fn header(function_name: &str) -> String {
3333
// rust-analyzer does not respect outer attribute (#[rustfmt::skip]) on
34-
// a module without a body. So use inner attribute under cfg(rustfmt).
34+
// a module without a body and unstable ignore option in .rustfmt.toml.
35+
// https://github.com/rust-lang/rust-analyzer/issues/10826
36+
// So use inner attribute under cfg(rustfmt).
3537
format!(
3638
"// SPDX-License-Identifier: Apache-2.0 OR MIT
3739
// This file is @generated by {bin_name}

0 commit comments

Comments
 (0)