Skip to content

Commit 04bd895

Browse files
committed
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.
1 parent 6d53b8e commit 04bd895

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

crates/std_detect/src/detect/macros.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ macro_rules! detect_feature {
99
$(cfg!(target_feature = $target_feature_lit) ||)*
1010
$crate::detect::__is_feature_detected::$feature()
1111
};
12+
($feature:tt, $feature_lit:tt, without cfg check: true) => {
13+
$crate::detect::__is_feature_detected::$feature()
14+
};
1215
}
1316

1417
#[allow(unused)]
@@ -21,6 +24,7 @@ macro_rules! features {
2124
$(@BIND_FEATURE_NAME: $bind_feature:tt; $feature_impl:tt; $(#[$deprecate_attr:meta];)?)*
2225
$(@NO_RUNTIME_DETECTION: $nort_feature:tt; )*
2326
$(@FEATURE: #[$stability_attr:meta] $feature:ident: $feature_lit:tt;
27+
$(without cfg check: $feature_cfg_check:literal;)?
2428
$(implied by target_features: [$($target_feature_lit:tt),*];)?
2529
$(#[$feature_comment:meta])*)*
2630
) => {
@@ -32,7 +36,7 @@ macro_rules! features {
3236
macro_rules! $macro_name {
3337
$(
3438
($feature_lit) => {
35-
$crate::detect_feature!($feature, $feature_lit $(: $($target_feature_lit),*)?)
39+
$crate::detect_feature!($feature, $feature_lit $(, without cfg check: $feature_cfg_check)? $(: $($target_feature_lit),*)?)
3640
};
3741
)*
3842
$(

0 commit comments

Comments
 (0)