From a6a49cfd9013acdbe55b92cdd9f886bc3c29e4ca Mon Sep 17 00:00:00 2001 From: Urgau Date: Tue, 5 Nov 2024 20:31:40 +0100 Subject: Add ability to declare a feature without cfg checking This is necessary to avoid `unexpected_cfgs` warnings for unexpected/ missing target features, in user code. --- library/stdarch/crates/std_detect/src/detect/macros.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'library/stdarch/crates/std_detect/src') diff --git a/library/stdarch/crates/std_detect/src/detect/macros.rs b/library/stdarch/crates/std_detect/src/detect/macros.rs index 5321ef2252e..f2cc711812a 100644 --- a/library/stdarch/crates/std_detect/src/detect/macros.rs +++ b/library/stdarch/crates/std_detect/src/detect/macros.rs @@ -9,6 +9,9 @@ macro_rules! detect_feature { $(cfg!(target_feature = $target_feature_lit) ||)* $crate::detect::__is_feature_detected::$feature() }; + ($feature:tt, $feature_lit:tt, without cfg check: true) => { + $crate::detect::__is_feature_detected::$feature() + }; } #[allow(unused)] @@ -21,6 +24,7 @@ macro_rules! features { $(@BIND_FEATURE_NAME: $bind_feature:tt; $feature_impl:tt; $(#[$deprecate_attr:meta];)?)* $(@NO_RUNTIME_DETECTION: $nort_feature:tt; )* $(@FEATURE: #[$stability_attr:meta] $feature:ident: $feature_lit:tt; + $(without cfg check: $feature_cfg_check:literal;)? $(implied by target_features: [$($target_feature_lit:tt),*];)? $(#[$feature_comment:meta])*)* ) => { @@ -32,7 +36,7 @@ macro_rules! features { macro_rules! $macro_name { $( ($feature_lit) => { - $crate::detect_feature!($feature, $feature_lit $(: $($target_feature_lit),*)?) + $crate::detect_feature!($feature, $feature_lit $(, without cfg check: $feature_cfg_check)? $(: $($target_feature_lit),*)?) }; )* $( -- cgit 1.4.1-3-g733a5