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