@@ -287,23 +287,21 @@ fn clean_lifetime<'tcx>(lifetime: &hir::Lifetime, cx: &mut DocContext<'tcx>) ->
287
287
pub ( crate ) fn clean_const < ' tcx > (
288
288
constant : & hir:: ConstArg < ' tcx > ,
289
289
_cx : & mut DocContext < ' tcx > ,
290
- ) -> Constant {
290
+ ) -> ConstantKind {
291
291
match & constant. kind {
292
292
hir:: ConstArgKind :: Path ( qpath) => {
293
- Constant { kind : ConstantKind :: Path { path : qpath_to_string ( & qpath) . into ( ) } }
294
- }
295
- hir:: ConstArgKind :: Anon ( anon) => {
296
- Constant { kind : ConstantKind :: Anonymous { body : anon. body } }
293
+ ConstantKind :: Path { path : qpath_to_string ( & qpath) . into ( ) }
297
294
}
295
+ hir:: ConstArgKind :: Anon ( anon) => ConstantKind :: Anonymous { body : anon. body } ,
298
296
}
299
297
}
300
298
301
299
pub ( crate ) fn clean_middle_const < ' tcx > (
302
300
constant : ty:: Binder < ' tcx , ty:: Const < ' tcx > > ,
303
301
_cx : & mut DocContext < ' tcx > ,
304
- ) -> Constant {
302
+ ) -> ConstantKind {
305
303
// FIXME: instead of storing the stringified expression, store `self` directly instead.
306
- Constant { kind : ConstantKind :: TyConst { expr : constant. skip_binder ( ) . to_string ( ) . into ( ) } }
304
+ ConstantKind :: TyConst { expr : constant. skip_binder ( ) . to_string ( ) . into ( ) }
307
305
}
308
306
309
307
pub ( crate ) fn clean_middle_region < ' tcx > ( region : ty:: Region < ' tcx > ) -> Option < Lifetime > {
@@ -1230,14 +1228,11 @@ fn clean_trait_item<'tcx>(trait_item: &hir::TraitItem<'tcx>, cx: &mut DocContext
1230
1228
let local_did = trait_item. owner_id . to_def_id ( ) ;
1231
1229
cx. with_param_env ( local_did, |cx| {
1232
1230
let inner = match trait_item. kind {
1233
- hir:: TraitItemKind :: Const ( ty, Some ( default) ) => {
1234
- let generics = enter_impl_trait ( cx, |cx| clean_generics ( trait_item. generics , cx) ) ;
1235
- AssocConstItem (
1236
- generics,
1237
- Box :: new ( clean_ty ( ty, cx) ) ,
1238
- ConstantKind :: Local { def_id : local_did, body : default } ,
1239
- )
1240
- }
1231
+ hir:: TraitItemKind :: Const ( ty, Some ( default) ) => AssocConstItem ( Box :: new ( Constant {
1232
+ generics : enter_impl_trait ( cx, |cx| clean_generics ( trait_item. generics , cx) ) ,
1233
+ kind : ConstantKind :: Local { def_id : local_did, body : default } ,
1234
+ type_ : clean_ty ( ty, cx) ,
1235
+ } ) ) ,
1241
1236
hir:: TraitItemKind :: Const ( ty, None ) => {
1242
1237
let generics = enter_impl_trait ( cx, |cx| clean_generics ( trait_item. generics , cx) ) ;
1243
1238
TyAssocConstItem ( generics, Box :: new ( clean_ty ( ty, cx) ) )
@@ -1282,11 +1277,11 @@ pub(crate) fn clean_impl_item<'tcx>(
1282
1277
let local_did = impl_. owner_id . to_def_id ( ) ;
1283
1278
cx. with_param_env ( local_did, |cx| {
1284
1279
let inner = match impl_. kind {
1285
- hir:: ImplItemKind :: Const ( ty, expr) => {
1286
- let generics = clean_generics ( impl_. generics , cx) ;
1287
- let default = ConstantKind :: Local { def_id : local_did, body : expr } ;
1288
- AssocConstItem ( generics , Box :: new ( clean_ty ( ty, cx) ) , default )
1289
- }
1280
+ hir:: ImplItemKind :: Const ( ty, expr) => AssocConstItem ( Box :: new ( Constant {
1281
+ generics : clean_generics ( impl_. generics , cx) ,
1282
+ kind : ConstantKind :: Local { def_id : local_did, body : expr } ,
1283
+ type_ : clean_ty ( ty, cx) ,
1284
+ } ) ) ,
1290
1285
hir:: ImplItemKind :: Fn ( ref sig, body) => {
1291
1286
let m = clean_function ( cx, sig, impl_. generics , FunctionArgs :: Body ( body) ) ;
1292
1287
let defaultness = cx. tcx . defaultness ( impl_. owner_id ) ;
@@ -1320,12 +1315,12 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
1320
1315
let tcx = cx. tcx ;
1321
1316
let kind = match assoc_item. kind {
1322
1317
ty:: AssocKind :: Const => {
1323
- let ty = Box :: new ( clean_middle_ty (
1318
+ let ty = clean_middle_ty (
1324
1319
ty:: Binder :: dummy ( tcx. type_of ( assoc_item. def_id ) . instantiate_identity ( ) ) ,
1325
1320
cx,
1326
1321
Some ( assoc_item. def_id ) ,
1327
1322
None ,
1328
- ) ) ;
1323
+ ) ;
1329
1324
1330
1325
let mut generics = clean_ty_generics (
1331
1326
cx,
@@ -1339,9 +1334,13 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
1339
1334
ty:: TraitContainer => tcx. defaultness ( assoc_item. def_id ) . has_value ( ) ,
1340
1335
} ;
1341
1336
if provided {
1342
- AssocConstItem ( generics, ty, ConstantKind :: Extern { def_id : assoc_item. def_id } )
1337
+ AssocConstItem ( Box :: new ( Constant {
1338
+ generics,
1339
+ kind : ConstantKind :: Extern { def_id : assoc_item. def_id } ,
1340
+ type_ : ty,
1341
+ } ) )
1343
1342
} else {
1344
- TyAssocConstItem ( generics, ty )
1343
+ TyAssocConstItem ( generics, Box :: new ( ty ) )
1345
1344
}
1346
1345
}
1347
1346
ty:: AssocKind :: Fn => {
@@ -1397,7 +1396,7 @@ pub(crate) fn clean_middle_assoc_item<'tcx>(
1397
1396
{
1398
1397
true
1399
1398
}
1400
- ( GenericParamDefKind :: Const { .. } , GenericArg :: Const ( c) ) => match & c . kind {
1399
+ ( GenericParamDefKind :: Const { .. } , GenericArg :: Const ( c) ) => match & * * c {
1401
1400
ConstantKind :: TyConst { expr } => * * expr == * param. name . as_str ( ) ,
1402
1401
_ => false ,
1403
1402
} ,
@@ -2744,14 +2743,16 @@ fn clean_maybe_renamed_item<'tcx>(
2744
2743
let mut name = renamed. unwrap_or_else ( || cx. tcx . hir ( ) . name ( item. hir_id ( ) ) ) ;
2745
2744
cx. with_param_env ( def_id, |cx| {
2746
2745
let kind = match item. kind {
2747
- ItemKind :: Static ( ty, mutability, body_id) => {
2748
- StaticItem ( Static { type_ : clean_ty ( ty, cx) , mutability, expr : Some ( body_id) } )
2749
- }
2750
- ItemKind :: Const ( ty, generics, body_id) => ConstantItem (
2751
- clean_generics ( generics, cx) ,
2752
- Box :: new ( clean_ty ( ty, cx) ) ,
2753
- Constant { kind : ConstantKind :: Local { body : body_id, def_id } } ,
2754
- ) ,
2746
+ ItemKind :: Static ( ty, mutability, body_id) => StaticItem ( Static {
2747
+ type_ : Box :: new ( clean_ty ( ty, cx) ) ,
2748
+ mutability,
2749
+ expr : Some ( body_id) ,
2750
+ } ) ,
2751
+ ItemKind :: Const ( ty, generics, body_id) => ConstantItem ( Box :: new ( Constant {
2752
+ generics : clean_generics ( generics, cx) ,
2753
+ type_ : clean_ty ( ty, cx) ,
2754
+ kind : ConstantKind :: Local { body : body_id, def_id } ,
2755
+ } ) ) ,
2755
2756
ItemKind :: OpaqueTy ( ref ty) => OpaqueTyItem ( OpaqueTy {
2756
2757
bounds : ty. bounds . iter ( ) . filter_map ( |x| clean_generic_bound ( x, cx) ) . collect ( ) ,
2757
2758
generics : clean_generics ( ty. generics , cx) ,
@@ -3109,7 +3110,7 @@ fn clean_maybe_renamed_foreign_item<'tcx>(
3109
3110
ForeignFunctionItem ( Box :: new ( Function { decl, generics } ) , safety)
3110
3111
}
3111
3112
hir:: ForeignItemKind :: Static ( ty, mutability, safety) => ForeignStaticItem (
3112
- Static { type_ : clean_ty ( ty, cx) , mutability, expr : None } ,
3113
+ Static { type_ : Box :: new ( clean_ty ( ty, cx) ) , mutability, expr : None } ,
3113
3114
safety,
3114
3115
) ,
3115
3116
hir:: ForeignItemKind :: Type => ForeignTypeItem ,
0 commit comments