@@ -12,7 +12,6 @@ crate mod utils;
1212
1313use rustc_ast as ast;
1414use rustc_attr as attr;
15- use rustc_const_eval:: const_eval:: is_unstable_const_fn;
1615use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
1716use rustc_hir as hir;
1817use rustc_hir:: def:: { CtorKind , DefKind , Res } ;
@@ -26,8 +25,6 @@ use rustc_middle::{bug, span_bug};
2625use rustc_span:: hygiene:: { AstPass , MacroKind } ;
2726use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
2827use rustc_span:: { self , ExpnKind } ;
29- use rustc_target:: spec:: abi:: Abi ;
30- use rustc_typeck:: check:: intrinsic:: intrinsic_operation_unsafety;
3128use rustc_typeck:: hir_ty_to_ty;
3229
3330use std:: assert_matches:: assert_matches;
@@ -813,13 +810,6 @@ fn clean_fn_or_proc_macro(
813810 }
814811 None => {
815812 let mut func = clean_function ( cx, sig, generics, body_id) ;
816- let def_id = item. def_id . to_def_id ( ) ;
817- func. header . constness =
818- if cx. tcx . is_const_fn ( def_id) && is_unstable_const_fn ( cx. tcx , def_id) . is_none ( ) {
819- hir:: Constness :: Const
820- } else {
821- hir:: Constness :: NotConst
822- } ;
823813 clean_fn_decl_legacy_const_generics ( & mut func, attrs) ;
824814 FunctionItem ( func)
825815 }
@@ -869,7 +859,7 @@ fn clean_function(
869859 let decl = clean_fn_decl_with_args ( cx, sig. decl , args) ;
870860 ( generics, decl)
871861 } ) ;
872- Function { decl, generics, header : sig . header }
862+ Function { decl, generics }
873863}
874864
875865fn clean_args_from_types_and_names (
@@ -998,12 +988,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
998988 AssocConstItem ( ty. clean ( cx) , default)
999989 }
1000990 hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Provided ( body) ) => {
1001- let mut m = clean_function ( cx, sig, & self . generics , body) ;
1002- if m. header . constness == hir:: Constness :: Const
1003- && is_unstable_const_fn ( cx. tcx , local_did) . is_some ( )
1004- {
1005- m. header . constness = hir:: Constness :: NotConst ;
1006- }
991+ let m = clean_function ( cx, sig, & self . generics , body) ;
1007992 MethodItem ( m, None )
1008993 }
1009994 hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Required ( names) ) => {
@@ -1014,13 +999,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
1014999 let decl = clean_fn_decl_with_args ( cx, sig. decl , args) ;
10151000 ( generics, decl)
10161001 } ) ;
1017- let mut t = Function { header : sig. header , decl, generics } ;
1018- if t. header . constness == hir:: Constness :: Const
1019- && is_unstable_const_fn ( cx. tcx , local_did) . is_some ( )
1020- {
1021- t. header . constness = hir:: Constness :: NotConst ;
1022- }
1023- TyMethodItem ( t)
1002+ TyMethodItem ( Function { decl, generics } )
10241003 }
10251004 hir:: TraitItemKind :: Type ( bounds, ref default) => {
10261005 let generics = enter_impl_trait ( cx, |cx| self . generics . clean ( cx) ) ;
@@ -1047,12 +1026,7 @@ impl Clean<Item> for hir::ImplItem<'_> {
10471026 AssocConstItem ( ty. clean ( cx) , default)
10481027 }
10491028 hir:: ImplItemKind :: Fn ( ref sig, body) => {
1050- let mut m = clean_function ( cx, sig, & self . generics , body) ;
1051- if m. header . constness == hir:: Constness :: Const
1052- && is_unstable_const_fn ( cx. tcx , local_did) . is_some ( )
1053- {
1054- m. header . constness = hir:: Constness :: NotConst ;
1055- }
1029+ let m = clean_function ( cx, sig, & self . generics , body) ;
10561030 let defaultness = cx. tcx . associated_item ( self . def_id ) . defaultness ;
10571031 MethodItem ( m, Some ( defaultness) )
10581032 }
@@ -1127,40 +1101,13 @@ impl Clean<Item> for ty::AssocItem {
11271101 ty:: TraitContainer ( _) => self . defaultness . has_value ( ) ,
11281102 } ;
11291103 if provided {
1130- let constness = if tcx. is_const_fn_raw ( self . def_id ) {
1131- hir:: Constness :: Const
1132- } else {
1133- hir:: Constness :: NotConst
1134- } ;
1135- let asyncness = tcx. asyncness ( self . def_id ) ;
11361104 let defaultness = match self . container {
11371105 ty:: ImplContainer ( _) => Some ( self . defaultness ) ,
11381106 ty:: TraitContainer ( _) => None ,
11391107 } ;
1140- MethodItem (
1141- Function {
1142- generics,
1143- decl,
1144- header : hir:: FnHeader {
1145- unsafety : sig. unsafety ( ) ,
1146- abi : sig. abi ( ) ,
1147- constness,
1148- asyncness,
1149- } ,
1150- } ,
1151- defaultness,
1152- )
1108+ MethodItem ( Function { generics, decl } , defaultness)
11531109 } else {
1154- TyMethodItem ( Function {
1155- generics,
1156- decl,
1157- header : hir:: FnHeader {
1158- unsafety : sig. unsafety ( ) ,
1159- abi : sig. abi ( ) ,
1160- constness : hir:: Constness :: NotConst ,
1161- asyncness : hir:: IsAsync :: NotAsync ,
1162- } ,
1163- } )
1110+ TyMethodItem ( Function { generics, decl } )
11641111 }
11651112 }
11661113 ty:: AssocKind :: Type => {
@@ -2192,28 +2139,14 @@ fn clean_maybe_renamed_foreign_item(
21922139 cx. with_param_env ( def_id, |cx| {
21932140 let kind = match item. kind {
21942141 hir:: ForeignItemKind :: Fn ( decl, names, ref generics) => {
2195- let abi = cx. tcx . hir ( ) . get_foreign_abi ( item. hir_id ( ) ) ;
21962142 let ( generics, decl) = enter_impl_trait ( cx, |cx| {
21972143 // NOTE: generics must be cleaned before args
21982144 let generics = generics. clean ( cx) ;
21992145 let args = clean_args_from_types_and_names ( cx, decl. inputs , names) ;
22002146 let decl = clean_fn_decl_with_args ( cx, decl, args) ;
22012147 ( generics, decl)
22022148 } ) ;
2203- ForeignFunctionItem ( Function {
2204- decl,
2205- generics,
2206- header : hir:: FnHeader {
2207- unsafety : if abi == Abi :: RustIntrinsic {
2208- intrinsic_operation_unsafety ( item. ident . name )
2209- } else {
2210- hir:: Unsafety :: Unsafe
2211- } ,
2212- abi,
2213- constness : hir:: Constness :: NotConst ,
2214- asyncness : hir:: IsAsync :: NotAsync ,
2215- } ,
2216- } )
2149+ ForeignFunctionItem ( Function { decl, generics } )
22172150 }
22182151 hir:: ForeignItemKind :: Static ( ref ty, mutability) => {
22192152 ForeignStaticItem ( Static { type_ : ty. clean ( cx) , mutability, expr : None } )
0 commit comments