Skip to content

Commit

Permalink
clippy: update is_stable_const_fn helper for multiple const-stabili…
Browse files Browse the repository at this point in the history
…ty attrs
  • Loading branch information
dianne committed Nov 11, 2024
1 parent b5d9ac6 commit 60bef9e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()
}
})
Expand Down

0 comments on commit 60bef9e

Please sign in to comment.