Skip to content

Commit

Permalink
Ignore unexpected_cfgs lint for generated code
Browse files Browse the repository at this point in the history
```
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.
  • Loading branch information
taiki-e committed May 5, 2024
1 parent 601ae0f commit a56a06b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ for multiple crate names and versions. For general purposes,
// clippy::std_instead_of_alloc,
clippy::std_instead_of_core,
)]
#![cfg_attr(test, allow(unexpected_cfgs))] // https://github.com/rust-lang/rust/issues/124735

#[cfg(test)]
#[path = "gen/assert_impl.rs"]
Expand Down
4 changes: 3 additions & 1 deletion tools/codegen/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ pub(crate) fn workspace_root() -> PathBuf {
#[track_caller]
pub(crate) fn header(function_name: &str) -> String {
// rust-analyzer does not respect outer attribute (#[rustfmt::skip]) on
// a module without a body. So use inner attribute under cfg(rustfmt).
// a module without a body and unstable ignore option in .rustfmt.toml.
// https://github.com/rust-lang/rust-analyzer/issues/10826
// So use inner attribute under cfg(rustfmt).
format!(
"// SPDX-License-Identifier: Apache-2.0 OR MIT
// This file is @generated by {bin_name}
Expand Down

0 comments on commit a56a06b

Please sign in to comment.