@@ -926,15 +926,24 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
926
926
927
927
// If the `const fn` we are trying to call is not const-stable, ensure that we have
928
928
// the proper feature gate enabled.
929
- if let Some ( gate) = is_unstable_const_fn ( tcx, callee) {
929
+ if let Some ( ( gate, implied_by ) ) = is_unstable_const_fn ( tcx, callee) {
930
930
trace ! ( ?gate, "calling unstable const fn" ) ;
931
931
if self . span . allows_unstable ( gate) {
932
932
return ;
933
933
}
934
+ if let Some ( implied_by_gate) = implied_by && self . span . allows_unstable ( implied_by_gate) {
935
+ return ;
936
+ }
934
937
935
938
// Calling an unstable function *always* requires that the corresponding gate
936
- // be enabled, even if the function has `#[rustc_allow_const_fn_unstable(the_gate)]`.
937
- if !tcx. features ( ) . declared_lib_features . iter ( ) . any ( |& ( sym, _) | sym == gate) {
939
+ // (or implied gate) be enabled, even if the function has
940
+ // `#[rustc_allow_const_fn_unstable(the_gate)]`.
941
+ let gate_declared = |gate| {
942
+ tcx. features ( ) . declared_lib_features . iter ( ) . any ( |& ( sym, _) | sym == gate)
943
+ } ;
944
+ let feature_gate_declared = gate_declared ( gate) ;
945
+ let implied_gate_declared = implied_by. map ( gate_declared) . unwrap_or ( false ) ;
946
+ if !feature_gate_declared && !implied_gate_declared {
938
947
self . check_op ( ops:: FnCallUnstable ( callee, Some ( gate) ) ) ;
939
948
return ;
940
949
}
@@ -947,7 +956,6 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
947
956
}
948
957
949
958
// Otherwise, we are something const-stable calling a const-unstable fn.
950
-
951
959
if super :: rustc_allow_const_fn_unstable ( tcx, caller, gate) {
952
960
trace ! ( "rustc_allow_const_fn_unstable gate active" ) ;
953
961
return ;
0 commit comments