@@ -861,6 +861,7 @@ fn render_assoc_item(
861
861
link : AssocItemLink < ' _ > ,
862
862
parent : ItemType ,
863
863
cx : & Context < ' _ > ,
864
+ render_mode : RenderMode ,
864
865
) {
865
866
fn method (
866
867
w : & mut Buffer ,
@@ -871,6 +872,7 @@ fn render_assoc_item(
871
872
link : AssocItemLink < ' _ > ,
872
873
parent : ItemType ,
873
874
cx : & Context < ' _ > ,
875
+ render_mode : RenderMode ,
874
876
) {
875
877
let name = meth. name . as_ref ( ) . unwrap ( ) ;
876
878
let href = match link {
@@ -893,8 +895,14 @@ fn render_assoc_item(
893
895
}
894
896
} ;
895
897
let vis = meth. visibility . print_with_space ( meth. def_id , cx) . to_string ( ) ;
896
- let constness =
897
- print_constness_with_space ( & header. constness , meth. const_stability ( cx. tcx ( ) ) ) ;
898
+ // FIXME: Once https://github.com/rust-lang/rust/issues/67792 is implemented, we can remove
899
+ // this condition.
900
+ let constness = match render_mode {
901
+ RenderMode :: Normal => {
902
+ print_constness_with_space ( & header. constness , meth. const_stability ( cx. tcx ( ) ) )
903
+ }
904
+ RenderMode :: ForDeref { .. } => "" ,
905
+ } ;
898
906
let asyncness = header. asyncness . print_with_space ( ) ;
899
907
let unsafety = header. unsafety . print_with_space ( ) ;
900
908
let defaultness = print_default_space ( meth. is_default ( ) ) ;
@@ -945,10 +953,10 @@ fn render_assoc_item(
945
953
match * item. kind {
946
954
clean:: StrippedItem ( ..) => { }
947
955
clean:: TyMethodItem ( ref m) => {
948
- method ( w, item, m. header , & m. generics , & m. decl , link, parent, cx)
956
+ method ( w, item, m. header , & m. generics , & m. decl , link, parent, cx, render_mode )
949
957
}
950
958
clean:: MethodItem ( ref m, _) => {
951
- method ( w, item, m. header , & m. generics , & m. decl , link, parent, cx)
959
+ method ( w, item, m. header , & m. generics , & m. decl , link, parent, cx, render_mode )
952
960
}
953
961
clean:: AssocConstItem ( ref ty, ref default) => assoc_const (
954
962
w,
@@ -1415,7 +1423,7 @@ fn render_impl(
1415
1423
"<div id=\" {}\" class=\" {}{} has-srclink\" >" ,
1416
1424
id, item_type, in_trait_class,
1417
1425
) ;
1418
- render_rightside ( w, cx, item, containing_item) ;
1426
+ render_rightside ( w, cx, item, containing_item, render_mode ) ;
1419
1427
write ! ( w, "<a href=\" #{}\" class=\" anchor\" ></a>" , id) ;
1420
1428
w. write_str ( "<h4 class=\" code-header\" >" ) ;
1421
1429
render_assoc_item (
@@ -1424,6 +1432,7 @@ fn render_impl(
1424
1432
link. anchor ( source_id. as_ref ( ) . unwrap_or ( & id) ) ,
1425
1433
ItemType :: Impl ,
1426
1434
cx,
1435
+ render_mode,
1427
1436
) ;
1428
1437
w. write_str ( "</h4>" ) ;
1429
1438
w. write_str ( "</div>" ) ;
@@ -1459,7 +1468,7 @@ fn render_impl(
1459
1468
"<div id=\" {}\" class=\" {}{} has-srclink\" >" ,
1460
1469
id, item_type, in_trait_class
1461
1470
) ;
1462
- render_rightside ( w, cx, item, containing_item) ;
1471
+ render_rightside ( w, cx, item, containing_item, render_mode ) ;
1463
1472
write ! ( w, "<a href=\" #{}\" class=\" anchor\" ></a>" , id) ;
1464
1473
w. write_str ( "<h4 class=\" code-header\" >" ) ;
1465
1474
assoc_const (
@@ -1638,16 +1647,28 @@ fn render_rightside(
1638
1647
cx : & Context < ' _ > ,
1639
1648
item : & clean:: Item ,
1640
1649
containing_item : & clean:: Item ,
1650
+ render_mode : RenderMode ,
1641
1651
) {
1642
1652
let tcx = cx. tcx ( ) ;
1643
1653
1654
+ let const_stable_since;
1655
+ // FIXME: Once https://github.com/rust-lang/rust/issues/67792 is implemented, we can remove
1656
+ // this condition.
1657
+ let ( const_stability, const_stable_since) = match render_mode {
1658
+ RenderMode :: Normal => {
1659
+ const_stable_since = containing_item. const_stable_since ( tcx) ;
1660
+ ( item. const_stability ( tcx) , const_stable_since. as_deref ( ) )
1661
+ }
1662
+ RenderMode :: ForDeref { .. } => ( None , None ) ,
1663
+ } ;
1664
+
1644
1665
write ! ( w, "<div class=\" rightside\" >" ) ;
1645
1666
render_stability_since_raw (
1646
1667
w,
1647
1668
item. stable_since ( tcx) . as_deref ( ) ,
1648
- item . const_stability ( tcx ) ,
1669
+ const_stability,
1649
1670
containing_item. stable_since ( tcx) . as_deref ( ) ,
1650
- containing_item . const_stable_since ( tcx ) . as_deref ( ) ,
1671
+ const_stable_since,
1651
1672
) ;
1652
1673
1653
1674
write_srclink ( cx, item, w) ;
@@ -1683,7 +1704,7 @@ pub(crate) fn render_impl_summary(
1683
1704
format ! ( " data-aliases=\" {}\" " , aliases. join( "," ) )
1684
1705
} ;
1685
1706
write ! ( w, "<div id=\" {}\" class=\" impl has-srclink\" {}>" , id, aliases) ;
1686
- render_rightside ( w, cx, & i. impl_item , containing_item) ;
1707
+ render_rightside ( w, cx, & i. impl_item , containing_item, RenderMode :: Normal ) ;
1687
1708
write ! ( w, "<a href=\" #{}\" class=\" anchor\" ></a>" , id) ;
1688
1709
write ! ( w, "<h3 class=\" code-header in-band\" >" ) ;
1689
1710
0 commit comments