File tree Expand file tree Collapse file tree 5 files changed +4
-12
lines changed
rustc_const_eval/src/check_consts Expand file tree Collapse file tree 5 files changed +4
-12
lines changed Original file line number Diff line number Diff line change @@ -95,8 +95,8 @@ pub fn rustc_allow_const_fn_unstable(
9595/// unstable features, not even recursively), and those that are not.
9696pub fn is_fn_or_trait_safe_to_expose_on_stable ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> bool {
9797 // A default body in a `const trait` is const-stable when the trait is const-stable.
98- if tcx. is_const_default_method ( def_id) {
99- return is_fn_or_trait_safe_to_expose_on_stable ( tcx, tcx . parent ( def_id ) ) ;
98+ if let Some ( trait_id ) = tcx. trait_of_assoc ( def_id) && tcx . is_const_trait ( trait_id ) {
99+ return is_fn_or_trait_safe_to_expose_on_stable ( tcx, trait_id ) ;
100100 }
101101
102102 match tcx. lookup_const_stability ( def_id) {
Original file line number Diff line number Diff line change @@ -1132,8 +1132,7 @@ fn should_encode_mir(
11321132 && ( generics. requires_monomorphization ( tcx)
11331133 || tcx. cross_crate_inlinable ( def_id) ) ) ;
11341134 // The function has a `const` modifier or is in a `const trait`.
1135- let is_const_fn = tcx. is_const_fn ( def_id. to_def_id ( ) )
1136- || tcx. is_const_default_method ( def_id. to_def_id ( ) ) ;
1135+ let is_const_fn = tcx. is_const_fn ( def_id. to_def_id ( ) ) ;
11371136 ( is_const_fn, opt)
11381137 }
11391138 // The others don't have MIR.
Original file line number Diff line number Diff line change @@ -321,7 +321,6 @@ impl<'tcx> TyCtxt<'tcx> {
321321 BodyOwnerKind :: Fn | BodyOwnerKind :: Closure if self . is_const_fn ( def_id) => {
322322 ConstContext :: ConstFn
323323 }
324- BodyOwnerKind :: Fn if self . is_const_default_method ( def_id) => ConstContext :: ConstFn ,
325324 BodyOwnerKind :: Fn | BodyOwnerKind :: Closure | BodyOwnerKind :: GlobalAsm => return None ,
326325 } ;
327326
Original file line number Diff line number Diff line change @@ -2224,11 +2224,6 @@ impl<'tcx> TyCtxt<'tcx> {
22242224 self . trait_def ( def_id) . constness == hir:: Constness :: Const
22252225 }
22262226
2227- #[ inline]
2228- pub fn is_const_default_method ( self , def_id : DefId ) -> bool {
2229- matches ! ( self . trait_of_assoc( def_id) , Some ( trait_id) if self . is_const_trait( trait_id) )
2230- }
2231-
22322227 pub fn impl_method_has_trait_impl_trait_tys ( self , def_id : DefId ) -> bool {
22332228 if self . def_kind ( def_id) != DefKind :: AssocFn {
22342229 return false ;
Original file line number Diff line number Diff line change @@ -429,8 +429,7 @@ fn mir_promoted(
429429
430430 let const_qualifs = match tcx. def_kind ( def) {
431431 DefKind :: Fn | DefKind :: AssocFn | DefKind :: Closure
432- if tcx. constness ( def) == hir:: Constness :: Const
433- || tcx. is_const_default_method ( def. to_def_id ( ) ) =>
432+ if tcx. constness ( def) == hir:: Constness :: Const =>
434433 {
435434 tcx. mir_const_qualif ( def)
436435 }
You can’t perform that action at this time.
0 commit comments