@@ -12,7 +12,6 @@ crate mod utils;
12
12
13
13
use rustc_ast as ast;
14
14
use rustc_attr as attr;
15
- use rustc_const_eval:: const_eval:: is_unstable_const_fn;
16
15
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
17
16
use rustc_hir as hir;
18
17
use rustc_hir:: def:: { CtorKind , DefKind , Res } ;
@@ -26,8 +25,6 @@ use rustc_middle::{bug, span_bug};
26
25
use rustc_span:: hygiene:: { AstPass , MacroKind } ;
27
26
use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
28
27
use rustc_span:: { self , ExpnKind } ;
29
- use rustc_target:: spec:: abi:: Abi ;
30
- use rustc_typeck:: check:: intrinsic:: intrinsic_operation_unsafety;
31
28
use rustc_typeck:: hir_ty_to_ty;
32
29
33
30
use std:: assert_matches:: assert_matches;
@@ -813,13 +810,6 @@ fn clean_fn_or_proc_macro(
813
810
}
814
811
None => {
815
812
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
- } ;
823
813
clean_fn_decl_legacy_const_generics ( & mut func, attrs) ;
824
814
FunctionItem ( func)
825
815
}
@@ -869,7 +859,7 @@ fn clean_function(
869
859
let decl = clean_fn_decl_with_args ( cx, sig. decl , args) ;
870
860
( generics, decl)
871
861
} ) ;
872
- Function { decl, generics, header : sig . header }
862
+ Function { decl, generics }
873
863
}
874
864
875
865
fn clean_args_from_types_and_names (
@@ -998,12 +988,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
998
988
AssocConstItem ( ty. clean ( cx) , default)
999
989
}
1000
990
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) ;
1007
992
MethodItem ( m, None )
1008
993
}
1009
994
hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Required ( names) ) => {
@@ -1014,13 +999,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
1014
999
let decl = clean_fn_decl_with_args ( cx, sig. decl , args) ;
1015
1000
( generics, decl)
1016
1001
} ) ;
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 } )
1024
1003
}
1025
1004
hir:: TraitItemKind :: Type ( bounds, ref default) => {
1026
1005
let generics = enter_impl_trait ( cx, |cx| self . generics . clean ( cx) ) ;
@@ -1047,12 +1026,7 @@ impl Clean<Item> for hir::ImplItem<'_> {
1047
1026
AssocConstItem ( ty. clean ( cx) , default)
1048
1027
}
1049
1028
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) ;
1056
1030
let defaultness = cx. tcx . associated_item ( self . def_id ) . defaultness ;
1057
1031
MethodItem ( m, Some ( defaultness) )
1058
1032
}
@@ -1127,40 +1101,13 @@ impl Clean<Item> for ty::AssocItem {
1127
1101
ty:: TraitContainer ( _) => self . defaultness . has_value ( ) ,
1128
1102
} ;
1129
1103
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 ) ;
1136
1104
let defaultness = match self . container {
1137
1105
ty:: ImplContainer ( _) => Some ( self . defaultness ) ,
1138
1106
ty:: TraitContainer ( _) => None ,
1139
1107
} ;
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)
1153
1109
} 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 } )
1164
1111
}
1165
1112
}
1166
1113
ty:: AssocKind :: Type => {
@@ -2192,28 +2139,14 @@ fn clean_maybe_renamed_foreign_item(
2192
2139
cx. with_param_env ( def_id, |cx| {
2193
2140
let kind = match item. kind {
2194
2141
hir:: ForeignItemKind :: Fn ( decl, names, ref generics) => {
2195
- let abi = cx. tcx . hir ( ) . get_foreign_abi ( item. hir_id ( ) ) ;
2196
2142
let ( generics, decl) = enter_impl_trait ( cx, |cx| {
2197
2143
// NOTE: generics must be cleaned before args
2198
2144
let generics = generics. clean ( cx) ;
2199
2145
let args = clean_args_from_types_and_names ( cx, decl. inputs , names) ;
2200
2146
let decl = clean_fn_decl_with_args ( cx, decl, args) ;
2201
2147
( generics, decl)
2202
2148
} ) ;
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 } )
2217
2150
}
2218
2151
hir:: ForeignItemKind :: Static ( ref ty, mutability) => {
2219
2152
ForeignStaticItem ( Static { type_ : ty. clean ( cx) , mutability, expr : None } )
0 commit comments