Rollup merge of #149592 - oli-obk:no_is_const_default_method_fn, r=fee1-dead

`is_const_default_method` is completely handled by the `constness` query

After  rust-lang/rust#149444 this function became obsolete

r? `@fee1-dead`
This commit is contained in:
Jacob Pratt 2025-12-05 23:26:37 -05:00 committed by GitHub
commit e5f552a02b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 6 additions and 12 deletions

View file

@ -95,8 +95,10 @@ pub fn rustc_allow_const_fn_unstable(
/// unstable features, not even recursively), and those that are not.
pub fn is_fn_or_trait_safe_to_expose_on_stable(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
// A default body in a `const trait` is const-stable when the trait is const-stable.
if tcx.is_const_default_method(def_id) {
return is_fn_or_trait_safe_to_expose_on_stable(tcx, tcx.parent(def_id));
if let Some(trait_id) = tcx.trait_of_assoc(def_id)
&& tcx.is_const_trait(trait_id)
{
return is_fn_or_trait_safe_to_expose_on_stable(tcx, trait_id);
}
match tcx.lookup_const_stability(def_id) {

View file

@ -1132,8 +1132,7 @@ fn should_encode_mir(
&& (generics.requires_monomorphization(tcx)
|| tcx.cross_crate_inlinable(def_id)));
// The function has a `const` modifier or is in a `const trait`.
let is_const_fn = tcx.is_const_fn(def_id.to_def_id())
|| tcx.is_const_default_method(def_id.to_def_id());
let is_const_fn = tcx.is_const_fn(def_id.to_def_id());
(is_const_fn, opt)
}
// The others don't have MIR.

View file

@ -321,7 +321,6 @@ impl<'tcx> TyCtxt<'tcx> {
BodyOwnerKind::Fn | BodyOwnerKind::Closure if self.is_const_fn(def_id) => {
ConstContext::ConstFn
}
BodyOwnerKind::Fn if self.is_const_default_method(def_id) => ConstContext::ConstFn,
BodyOwnerKind::Fn | BodyOwnerKind::Closure | BodyOwnerKind::GlobalAsm => return None,
};

View file

@ -2224,11 +2224,6 @@ impl<'tcx> TyCtxt<'tcx> {
self.trait_def(def_id).constness == hir::Constness::Const
}
#[inline]
pub fn is_const_default_method(self, def_id: DefId) -> bool {
matches!(self.trait_of_assoc(def_id), Some(trait_id) if self.is_const_trait(trait_id))
}
pub fn impl_method_has_trait_impl_trait_tys(self, def_id: DefId) -> bool {
if self.def_kind(def_id) != DefKind::AssocFn {
return false;

View file

@ -429,8 +429,7 @@ fn mir_promoted(
let const_qualifs = match tcx.def_kind(def) {
DefKind::Fn | DefKind::AssocFn | DefKind::Closure
if tcx.constness(def) == hir::Constness::Const
|| tcx.is_const_default_method(def.to_def_id()) =>
if tcx.constness(def) == hir::Constness::Const =>
{
tcx.mir_const_qualif(def)
}