-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#![allow(unexpected_cfgs)] does not work for modules #124735
Comments
``` 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.
``` 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.
I would also expect the However, I don't think you need the - #![cfg_attr(rustfmt, rustfmt::skip)]
+ #![rustfmt::skip] |
No. Custom inner attributes are unstable.
|
Oh, good point, but they can (stably) be applied directly to the #[rustfmt::skip]
mod a; |
Unfortunately, that is not an option available to me due to a rust-analyzer bug: rust-lang/rust-analyzer#10826 (comment) |
``` 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.
``` error: unexpected `cfg` condition name: `rustfmt` --> src/gen/display.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/from_str.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/assert_impl.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/display.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.
``` 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.
``` 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.
It looks like rustfmt will just always treat mod m {
#![cfg_attr(any(), rustfmt::skip)]
fn dont_format_me () { }
} |
``` 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.
``` 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.
``` 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.
``` 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.
``` 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.
Add `rustfmt` cfg to well known cfgs list This PR adds the `rustfmt` cfg to the well known cfgs list. Related to rust-lang#124735
Oh, no! >.< |
Add `rustfmt` cfg to well known cfgs list This PR adds the `rustfmt` cfg to the well known cfgs list. Related to rust-lang#124735
Add `rustfmt` cfg to well known cfgs list This PR adds the `rustfmt` cfg to the well known cfgs list. Related to rust-lang#124735
Add `rustfmt` cfg to well known cfgs list This PR adds the `rustfmt` cfg to the well known cfgs list. Related to rust-lang#124735
Rollup merge of rust-lang#124742 - Urgau:check-cfg-rustfmt, r=fmease Add `rustfmt` cfg to well known cfgs list This PR adds the `rustfmt` cfg to the well known cfgs list. Related to rust-lang#124735
The |
cc #82450 |
I tried this code:
I expected to see this happen: no warning
Instead, this happened:
#![allow(unexpected_cfgs)]
is ignored:Even if adding
#[allow(unexpected_cfgs)]
tomod a;
, the result is the same.cc @Urgau
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: