@@ -1595,7 +1595,12 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
1595
1595
let inner = match self . kind {
1596
1596
ty:: AssociatedKind :: Const => {
1597
1597
let ty = cx. tcx . type_of ( self . def_id ) ;
1598
- AssociatedConstItem ( ty. clean ( cx) , None )
1598
+ let default = if self . defaultness . has_value ( ) {
1599
+ Some ( inline:: print_inlined_const ( cx, self . def_id ) )
1600
+ } else {
1601
+ None
1602
+ } ;
1603
+ AssociatedConstItem ( ty. clean ( cx) , default)
1599
1604
}
1600
1605
ty:: AssociatedKind :: Method => {
1601
1606
let generics = ( cx. tcx . generics_of ( self . def_id ) ,
@@ -1626,18 +1631,21 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
1626
1631
}
1627
1632
1628
1633
let provided = match self . container {
1629
- ty:: ImplContainer ( _) => false ,
1634
+ ty:: ImplContainer ( _) => true ,
1630
1635
ty:: TraitContainer ( _) => self . defaultness . has_value ( )
1631
1636
} ;
1632
1637
if provided {
1638
+ let constness = if cx. tcx . is_const_fn ( self . def_id ) {
1639
+ hir:: Constness :: Const
1640
+ } else {
1641
+ hir:: Constness :: NotConst
1642
+ } ;
1633
1643
MethodItem ( Method {
1634
1644
unsafety : sig. unsafety ( ) ,
1635
1645
generics,
1636
1646
decl,
1637
1647
abi : sig. abi ( ) ,
1638
-
1639
- // trait methods cannot (currently, at least) be const
1640
- constness : hir:: Constness :: NotConst ,
1648
+ constness,
1641
1649
} )
1642
1650
} else {
1643
1651
TyMethodItem ( TyMethod {
@@ -1651,14 +1659,14 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
1651
1659
ty:: AssociatedKind :: Type => {
1652
1660
let my_name = self . name . clean ( cx) ;
1653
1661
1654
- let mut bounds = if let ty:: TraitContainer ( did) = self . container {
1662
+ if let ty:: TraitContainer ( did) = self . container {
1655
1663
// When loading a cross-crate associated type, the bounds for this type
1656
1664
// are actually located on the trait/impl itself, so we need to load
1657
1665
// all of the generics from there and then look for bounds that are
1658
1666
// applied to this associated type in question.
1659
1667
let predicates = cx. tcx . predicates_of ( did) ;
1660
1668
let generics = ( cx. tcx . generics_of ( did) , & predicates) . clean ( cx) ;
1661
- generics. where_predicates . iter ( ) . filter_map ( |pred| {
1669
+ let mut bounds = generics. where_predicates . iter ( ) . filter_map ( |pred| {
1662
1670
let ( name, self_type, trait_, bounds) = match * pred {
1663
1671
WherePredicate :: BoundPredicate {
1664
1672
ty : QPath { ref name, ref self_type, ref trait_ } ,
@@ -1676,34 +1684,45 @@ impl<'tcx> Clean<Item> for ty::AssociatedItem {
1676
1684
_ => return None ,
1677
1685
}
1678
1686
Some ( bounds)
1679
- } ) . flat_map ( |i| i. iter ( ) . cloned ( ) ) . collect :: < Vec < _ > > ( )
1680
- } else {
1681
- vec ! [ ]
1682
- } ;
1687
+ } ) . flat_map ( |i| i. iter ( ) . cloned ( ) ) . collect :: < Vec < _ > > ( ) ;
1688
+ // Our Sized/?Sized bound didn't get handled when creating the generics
1689
+ // because we didn't actually get our whole set of bounds until just now
1690
+ // (some of them may have come from the trait). If we do have a sized
1691
+ // bound, we remove it, and if we don't then we add the `?Sized` bound
1692
+ // at the end.
1693
+ match bounds. iter ( ) . position ( |b| b. is_sized_bound ( cx) ) {
1694
+ Some ( i) => { bounds. remove ( i) ; }
1695
+ None => bounds. push ( TyParamBound :: maybe_sized ( cx) ) ,
1696
+ }
1683
1697
1684
- // Our Sized/?Sized bound didn't get handled when creating the generics
1685
- // because we didn't actually get our whole set of bounds until just now
1686
- // (some of them may have come from the trait). If we do have a sized
1687
- // bound, we remove it, and if we don't then we add the `?Sized` bound
1688
- // at the end.
1689
- match bounds. iter ( ) . position ( |b| b. is_sized_bound ( cx) ) {
1690
- Some ( i) => { bounds. remove ( i) ; }
1691
- None => bounds. push ( TyParamBound :: maybe_sized ( cx) ) ,
1692
- }
1698
+ let ty = if self . defaultness . has_value ( ) {
1699
+ Some ( cx. tcx . type_of ( self . def_id ) )
1700
+ } else {
1701
+ None
1702
+ } ;
1693
1703
1694
- let ty = if self . defaultness . has_value ( ) {
1695
- Some ( cx. tcx . type_of ( self . def_id ) )
1704
+ AssociatedTypeItem ( bounds, ty. clean ( cx) )
1696
1705
} else {
1697
- None
1698
- } ;
1699
-
1700
- AssociatedTypeItem ( bounds, ty. clean ( cx) )
1706
+ TypedefItem ( Typedef {
1707
+ type_ : cx. tcx . type_of ( self . def_id ) . clean ( cx) ,
1708
+ generics : Generics {
1709
+ lifetimes : Vec :: new ( ) ,
1710
+ type_params : Vec :: new ( ) ,
1711
+ where_predicates : Vec :: new ( ) ,
1712
+ } ,
1713
+ } , true )
1714
+ }
1701
1715
}
1702
1716
} ;
1703
1717
1718
+ let visibility = match self . container {
1719
+ ty:: ImplContainer ( _) => self . vis . clean ( cx) ,
1720
+ ty:: TraitContainer ( _) => None ,
1721
+ } ;
1722
+
1704
1723
Item {
1705
1724
name : Some ( self . name . clean ( cx) ) ,
1706
- visibility : Some ( Inherited ) ,
1725
+ visibility,
1707
1726
stability : get_stability ( cx, self . def_id ) ,
1708
1727
deprecation : get_deprecation ( cx, self . def_id ) ,
1709
1728
def_id : self . def_id ,
0 commit comments