@@ -804,17 +804,17 @@ fn assoc_type(
804
804
805
805
fn render_stability_since_raw (
806
806
w : & mut Buffer ,
807
- ver : Option < & str > ,
808
- const_stability : Option < & ConstStability > ,
809
- containing_ver : Option < & str > ,
810
- containing_const_ver : Option < & str > ,
807
+ ver : Option < Symbol > ,
808
+ const_stability : Option < ConstStability > ,
809
+ containing_ver : Option < Symbol > ,
810
+ containing_const_ver : Option < Symbol > ,
811
811
) {
812
812
let ver = ver. filter ( |inner| !inner. is_empty ( ) ) ;
813
813
814
814
match ( ver, const_stability) {
815
815
// stable and const stable
816
816
( Some ( v) , Some ( ConstStability { level : StabilityLevel :: Stable { since } , .. } ) )
817
- if Some ( since. as_str ( ) ) . as_deref ( ) != containing_const_ver =>
817
+ if Some ( since) != containing_const_ver =>
818
818
{
819
819
write ! (
820
820
w,
@@ -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,
@@ -1422,7 +1430,7 @@ fn render_impl(
1422
1430
"<div id=\" {}\" class=\" {}{} has-srclink\" >" ,
1423
1431
id, item_type, in_trait_class,
1424
1432
) ;
1425
- render_rightside ( w, cx, item, containing_item) ;
1433
+ render_rightside ( w, cx, item, containing_item, render_mode ) ;
1426
1434
write ! ( w, "<a href=\" #{}\" class=\" anchor\" ></a>" , id) ;
1427
1435
w. write_str ( "<h4 class=\" code-header\" >" ) ;
1428
1436
render_assoc_item (
@@ -1431,6 +1439,7 @@ fn render_impl(
1431
1439
link. anchor ( source_id. as_ref ( ) . unwrap_or ( & id) ) ,
1432
1440
ItemType :: Impl ,
1433
1441
cx,
1442
+ render_mode,
1434
1443
) ;
1435
1444
w. write_str ( "</h4>" ) ;
1436
1445
w. write_str ( "</div>" ) ;
@@ -1466,7 +1475,7 @@ fn render_impl(
1466
1475
"<div id=\" {}\" class=\" {}{} has-srclink\" >" ,
1467
1476
id, item_type, in_trait_class
1468
1477
) ;
1469
- render_rightside ( w, cx, item, containing_item) ;
1478
+ render_rightside ( w, cx, item, containing_item, render_mode ) ;
1470
1479
write ! ( w, "<a href=\" #{}\" class=\" anchor\" ></a>" , id) ;
1471
1480
w. write_str ( "<h4 class=\" code-header\" >" ) ;
1472
1481
assoc_const (
@@ -1645,16 +1654,24 @@ fn render_rightside(
1645
1654
cx : & Context < ' _ > ,
1646
1655
item : & clean:: Item ,
1647
1656
containing_item : & clean:: Item ,
1657
+ render_mode : RenderMode ,
1648
1658
) {
1649
1659
let tcx = cx. tcx ( ) ;
1650
1660
1661
+ // FIXME: Once https://github.com/rust-lang/rust/issues/67792 is implemented, we can remove
1662
+ // this condition.
1663
+ let ( const_stability, const_stable_since) = match render_mode {
1664
+ RenderMode :: Normal => ( item. const_stability ( tcx) , containing_item. const_stable_since ( tcx) ) ,
1665
+ RenderMode :: ForDeref { .. } => ( None , None ) ,
1666
+ } ;
1667
+
1651
1668
write ! ( w, "<div class=\" rightside\" >" ) ;
1652
1669
render_stability_since_raw (
1653
1670
w,
1654
- item. stable_since ( tcx) . as_deref ( ) ,
1655
- item . const_stability ( tcx ) ,
1656
- containing_item. stable_since ( tcx) . as_deref ( ) ,
1657
- containing_item . const_stable_since ( tcx ) . as_deref ( ) ,
1671
+ item. stable_since ( tcx) ,
1672
+ const_stability,
1673
+ containing_item. stable_since ( tcx) ,
1674
+ const_stable_since,
1658
1675
) ;
1659
1676
1660
1677
write_srclink ( cx, item, w) ;
@@ -1690,7 +1707,7 @@ pub(crate) fn render_impl_summary(
1690
1707
format ! ( " data-aliases=\" {}\" " , aliases. join( "," ) )
1691
1708
} ;
1692
1709
write ! ( w, "<div id=\" {}\" class=\" impl has-srclink\" {}>" , id, aliases) ;
1693
- render_rightside ( w, cx, & i. impl_item , containing_item) ;
1710
+ render_rightside ( w, cx, & i. impl_item , containing_item, RenderMode :: Normal ) ;
1694
1711
write ! ( w, "<a href=\" #{}\" class=\" anchor\" ></a>" , id) ;
1695
1712
write ! ( w, "<h3 class=\" code-header in-band\" >" ) ;
1696
1713
0 commit comments