@@ -964,11 +964,11 @@ impl Clean<Item> for hir::TraitItem<'_> {
964
964
let local_did = self . def_id . to_def_id ( ) ;
965
965
cx. with_param_env ( local_did, |cx| {
966
966
let inner = match self . kind {
967
- hir:: TraitItemKind :: Const ( ref ty, default) => {
968
- let default =
969
- default . map ( |e| ConstantKind :: Local { def_id : local_did, body : e } ) ;
970
- AssocConstItem ( ty . clean ( cx ) , default )
971
- }
967
+ hir:: TraitItemKind :: Const ( ref ty, Some ( default) ) => AssocConstItem (
968
+ ty . clean ( cx ) ,
969
+ ConstantKind :: Local { def_id : local_did, body : default } ,
970
+ ) ,
971
+ hir :: TraitItemKind :: Const ( ref ty , None ) => TyAssocConstItem ( ty . clean ( cx ) ) ,
972
972
hir:: TraitItemKind :: Fn ( ref sig, hir:: TraitFn :: Provided ( body) ) => {
973
973
let m = clean_function ( cx, sig, & self . generics , body) ;
974
974
MethodItem ( m, None )
@@ -983,11 +983,19 @@ impl Clean<Item> for hir::TraitItem<'_> {
983
983
} ) ;
984
984
TyMethodItem ( Function { decl, generics } )
985
985
}
986
- hir:: TraitItemKind :: Type ( bounds, ref default) => {
986
+ hir:: TraitItemKind :: Type ( bounds, Some ( default) ) => {
987
+ let generics = enter_impl_trait ( cx, |cx| self . generics . clean ( cx) ) ;
988
+ let bounds = bounds. iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ;
989
+ let item_type = hir_ty_to_ty ( cx. tcx , default) . clean ( cx) ;
990
+ AssocTypeItem (
991
+ Typedef { type_ : default. clean ( cx) , generics, item_type : Some ( item_type) } ,
992
+ bounds,
993
+ )
994
+ }
995
+ hir:: TraitItemKind :: Type ( bounds, None ) => {
987
996
let generics = enter_impl_trait ( cx, |cx| self . generics . clean ( cx) ) ;
988
997
let bounds = bounds. iter ( ) . filter_map ( |x| x. clean ( cx) ) . collect ( ) ;
989
- let default = default. map ( |t| t. clean ( cx) ) ;
990
- AssocTypeItem ( Box :: new ( generics) , bounds, default)
998
+ TyAssocTypeItem ( Box :: new ( generics) , bounds)
991
999
}
992
1000
} ;
993
1001
let what_rustc_thinks =
@@ -1004,7 +1012,7 @@ impl Clean<Item> for hir::ImplItem<'_> {
1004
1012
cx. with_param_env ( local_did, |cx| {
1005
1013
let inner = match self . kind {
1006
1014
hir:: ImplItemKind :: Const ( ref ty, expr) => {
1007
- let default = Some ( ConstantKind :: Local { def_id : local_did, body : expr } ) ;
1015
+ let default = ConstantKind :: Local { def_id : local_did, body : expr } ;
1008
1016
AssocConstItem ( ty. clean ( cx) , default)
1009
1017
}
1010
1018
hir:: ImplItemKind :: Fn ( ref sig, body) => {
@@ -1016,7 +1024,10 @@ impl Clean<Item> for hir::ImplItem<'_> {
1016
1024
let type_ = hir_ty. clean ( cx) ;
1017
1025
let generics = self . generics . clean ( cx) ;
1018
1026
let item_type = hir_ty_to_ty ( cx. tcx , hir_ty) . clean ( cx) ;
1019
- TypedefItem ( Typedef { type_, generics, item_type : Some ( item_type) } , true )
1027
+ AssocTypeItem (
1028
+ Typedef { type_, generics, item_type : Some ( item_type) } ,
1029
+ Vec :: new ( ) ,
1030
+ )
1020
1031
}
1021
1032
} ;
1022
1033
@@ -1041,13 +1052,17 @@ impl Clean<Item> for ty::AssocItem {
1041
1052
let tcx = cx. tcx ;
1042
1053
let kind = match self . kind {
1043
1054
ty:: AssocKind :: Const => {
1044
- let ty = tcx. type_of ( self . def_id ) ;
1045
- let default = if self . defaultness . has_value ( ) {
1046
- Some ( ConstantKind :: Extern { def_id : self . def_id } )
1047
- } else {
1048
- None
1055
+ let ty = tcx. type_of ( self . def_id ) . clean ( cx ) ;
1056
+
1057
+ let provided = match self . container {
1058
+ ty :: ImplContainer ( _ ) => true ,
1059
+ ty :: TraitContainer ( _ ) => self . defaultness . has_value ( ) ,
1049
1060
} ;
1050
- AssocConstItem ( ty. clean ( cx) , default)
1061
+ if provided {
1062
+ AssocConstItem ( ty, ConstantKind :: Extern { def_id : self . def_id } )
1063
+ } else {
1064
+ TyAssocConstItem ( ty)
1065
+ }
1051
1066
}
1052
1067
ty:: AssocKind :: Fn => {
1053
1068
let generics = clean_ty_generics (
@@ -1181,23 +1196,28 @@ impl Clean<Item> for ty::AssocItem {
1181
1196
None => bounds. push ( GenericBound :: maybe_sized ( cx) ) ,
1182
1197
}
1183
1198
1184
- let ty = if self . defaultness . has_value ( ) {
1185
- Some ( tcx. type_of ( self . def_id ) )
1199
+ if self . defaultness . has_value ( ) {
1200
+ AssocTypeItem (
1201
+ Typedef {
1202
+ type_ : tcx. type_of ( self . def_id ) . clean ( cx) ,
1203
+ generics,
1204
+ // FIXME: should we obtain the Type from HIR and pass it on here?
1205
+ item_type : None ,
1206
+ } ,
1207
+ bounds,
1208
+ )
1186
1209
} else {
1187
- None
1188
- } ;
1189
-
1190
- AssocTypeItem ( Box :: new ( generics) , bounds, ty. map ( |t| t. clean ( cx) ) )
1210
+ TyAssocTypeItem ( Box :: new ( generics) , bounds)
1211
+ }
1191
1212
} else {
1192
1213
// FIXME: when could this happen? Associated items in inherent impls?
1193
- let type_ = tcx. type_of ( self . def_id ) . clean ( cx) ;
1194
- TypedefItem (
1214
+ AssocTypeItem (
1195
1215
Typedef {
1196
- type_,
1216
+ type_ : tcx . type_of ( self . def_id ) . clean ( cx ) ,
1197
1217
generics : Generics { params : Vec :: new ( ) , where_predicates : Vec :: new ( ) } ,
1198
1218
item_type : None ,
1199
1219
} ,
1200
- true ,
1220
+ Vec :: new ( ) ,
1201
1221
)
1202
1222
}
1203
1223
}
@@ -1837,14 +1857,11 @@ fn clean_maybe_renamed_item(
1837
1857
ItemKind :: TyAlias ( hir_ty, ref generics) => {
1838
1858
let rustdoc_ty = hir_ty. clean ( cx) ;
1839
1859
let ty = hir_ty_to_ty ( cx. tcx , hir_ty) . clean ( cx) ;
1840
- TypedefItem (
1841
- Typedef {
1842
- type_ : rustdoc_ty,
1843
- generics : generics. clean ( cx) ,
1844
- item_type : Some ( ty) ,
1845
- } ,
1846
- false ,
1847
- )
1860
+ TypedefItem ( Typedef {
1861
+ type_ : rustdoc_ty,
1862
+ generics : generics. clean ( cx) ,
1863
+ item_type : Some ( ty) ,
1864
+ } )
1848
1865
}
1849
1866
ItemKind :: Enum ( ref def, ref generics) => EnumItem ( Enum {
1850
1867
variants : def. variants . iter ( ) . map ( |v| v. clean ( cx) ) . collect ( ) ,
0 commit comments