Skip to content

Commit b81f9c3

Browse files
committed
Ignore unexpected_cfgs lint for generated code
``` error: unexpected `cfg` condition name: `rustfmt` --> src/gen/assert_impl.rs:6:13 | 6 | #![cfg_attr(rustfmt, rustfmt::skip)] | ^^^^^^^ ``` Due to rust-lang/rust#124735, we cannot disable this lint at module-level.
1 parent 8fee915 commit b81f9c3

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
@@ -82,6 +82,7 @@ fn foo(secs: u64, nanos: u32, instant: Instant) -> Option<Duration> {
8282
)]
8383
// docs.rs only (cfg is enabled by docs.rs, not build script)
8484
#![cfg_attr(docsrs, feature(doc_cfg))]
85+
#![cfg_attr(test, allow(unexpected_cfgs))] // https://github.com/rust-lang/rust/issues/124735
8586

8687
#[cfg(doc)]
8788
extern crate self as easytime;

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)