Skip to content

Commit 7ea3985

Browse files
committed
Ignore unexpected_cfgs lint for generated code
``` error: unexpected `cfg` condition name: `rustfmt` --> src/gen/is_none.rs:6:13 | 6 | #![cfg_attr(rustfmt, rustfmt::skip)] | ^^^^^^^ | = help: expected names are: `clippy`, `debug_assertions`, `doc`, `docsrs`, `doctest`, `feature`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `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`, `windows` = 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 = note: `-D unexpected-cfgs` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(unexpected_cfgs)]` error: unexpected `cfg` condition name: `rustfmt` --> src/gen/de.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 0d6e194 commit 7ea3985

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
@@ -50,6 +50,7 @@ See also the [`get` example](https://github.com/taiki-e/cargo-config2/blob/HEAD/
5050
clippy::std_instead_of_core,
5151
)]
5252
#![allow(clippy::must_use_candidate)]
53+
#![allow(unexpected_cfgs)] // https://github.com/rust-lang/rust/issues/124735
5354

5455
// Refs:
5556
// - https://doc.rust-lang.org/nightly/cargo/reference/config.html

tools/codegen/src/file.rs

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

0 commit comments

Comments
 (0)