Skip to content

Commit

Permalink
Ignore unexpected_cfgs lint for tests
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 3429326 commit dfb37ae
Show file tree
Hide file tree
Showing 2 changed files with 3 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 @@ -132,6 +132,7 @@ Note: The MSRV when these features are enabled depends on the MSRV of these crat
)]
// docs.rs only (cfg is enabled by docs.rs, not build script)
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(test, allow(unexpected_cfgs))] // https://github.com/rust-lang/rust/issues/124735

#[cfg(test)]
#[path = "gen/assert_impl.rs"]
Expand Down
3 changes: 2 additions & 1 deletion tools/codegen/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ 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.
// 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 dfb37ae

Please sign in to comment.