From 88e33bfae32df62978202fb89746da0f067da9cb Mon Sep 17 00:00:00 2001 From: dianne Date: Sat, 26 Oct 2024 15:56:45 -0700 Subject: [PATCH] clippy: update `is_stable_const_fn` helper for multiple const-stability attrs --- .../clippy/clippy_utils/src/qualify_min_const_fn.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs index 46739862de6b2..93df876de08fc 100644 --- a/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs +++ b/src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs @@ -380,7 +380,7 @@ fn check_terminator<'tcx>( fn is_stable_const_fn(tcx: TyCtxt<'_>, def_id: DefId, msrv: &Msrv) -> bool { tcx.is_const_fn(def_id) && tcx.lookup_const_stability(def_id).is_none_or(|const_stab| { - if let rustc_attr::StabilityLevel::Stable { since, .. } = const_stab.level { + if let rustc_attr::ConstStabilityLevel::Stable { since, .. } = const_stab.level { // Checking MSRV is manually necessary because `rustc` has no such concept. This entire // function could be removed if `rustc` provided a MSRV-aware version of `is_stable_const_fn`. // as a part of an unimplemented MSRV check https://github.com/rust-lang/rust/issues/65262. @@ -393,11 +393,11 @@ fn is_stable_const_fn(tcx: TyCtxt<'_>, def_id: DefId, msrv: &Msrv) -> bool { msrv.meets(const_stab_rust_version) } else { - // Unstable const fn, check if the feature is enabled. We need both the regular stability - // feature and (if set) the const stability feature to const-call this function. + // Unstable const fn, check if the features are enabled. We need both the regular stability + // features and (if set) the const stability features to const-call this function. let stab = tcx.lookup_stability(def_id); - let is_enabled = stab.is_some_and(|s| s.is_stable() || tcx.features().enabled(s.feature)) - && const_stab.feature.is_none_or(|f| tcx.features().enabled(f)); + let is_enabled = stab.is_some_and(|s| tcx.features().all_enabled(s.unstable_features())) + && tcx.features().all_enabled(const_stab.unstable_features()); is_enabled && msrv.current().is_none() } })