@@ -861,6 +861,7 @@ fn render_assoc_item(
861861 link : AssocItemLink < ' _ > ,
862862 parent : ItemType ,
863863 cx : & Context < ' _ > ,
864+ render_mode : RenderMode ,
864865) {
865866 fn method (
866867 w : & mut Buffer ,
@@ -871,6 +872,7 @@ fn render_assoc_item(
871872 link : AssocItemLink < ' _ > ,
872873 parent : ItemType ,
873874 cx : & Context < ' _ > ,
875+ render_mode : RenderMode ,
874876 ) {
875877 let name = meth. name . as_ref ( ) . unwrap ( ) ;
876878 let href = match link {
@@ -893,8 +895,14 @@ fn render_assoc_item(
893895 }
894896 } ;
895897 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+ } ;
898906 let asyncness = header. asyncness . print_with_space ( ) ;
899907 let unsafety = header. unsafety . print_with_space ( ) ;
900908 let defaultness = print_default_space ( meth. is_default ( ) ) ;
@@ -945,10 +953,10 @@ fn render_assoc_item(
945953 match * item. kind {
946954 clean:: StrippedItem ( ..) => { }
947955 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 )
949957 }
950958 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 )
952960 }
953961 clean:: AssocConstItem ( ref ty, ref default) => assoc_const (
954962 w,
@@ -1415,7 +1423,7 @@ fn render_impl(
14151423 "<div id=\" {}\" class=\" {}{} has-srclink\" >" ,
14161424 id, item_type, in_trait_class,
14171425 ) ;
1418- render_rightside ( w, cx, item, containing_item) ;
1426+ render_rightside ( w, cx, item, containing_item, render_mode ) ;
14191427 write ! ( w, "<a href=\" #{}\" class=\" anchor\" ></a>" , id) ;
14201428 w. write_str ( "<h4 class=\" code-header\" >" ) ;
14211429 render_assoc_item (
@@ -1424,6 +1432,7 @@ fn render_impl(
14241432 link. anchor ( source_id. as_ref ( ) . unwrap_or ( & id) ) ,
14251433 ItemType :: Impl ,
14261434 cx,
1435+ render_mode,
14271436 ) ;
14281437 w. write_str ( "</h4>" ) ;
14291438 w. write_str ( "</div>" ) ;
@@ -1459,7 +1468,7 @@ fn render_impl(
14591468 "<div id=\" {}\" class=\" {}{} has-srclink\" >" ,
14601469 id, item_type, in_trait_class
14611470 ) ;
1462- render_rightside ( w, cx, item, containing_item) ;
1471+ render_rightside ( w, cx, item, containing_item, render_mode ) ;
14631472 write ! ( w, "<a href=\" #{}\" class=\" anchor\" ></a>" , id) ;
14641473 w. write_str ( "<h4 class=\" code-header\" >" ) ;
14651474 assoc_const (
@@ -1638,16 +1647,28 @@ fn render_rightside(
16381647 cx : & Context < ' _ > ,
16391648 item : & clean:: Item ,
16401649 containing_item : & clean:: Item ,
1650+ render_mode : RenderMode ,
16411651) {
16421652 let tcx = cx. tcx ( ) ;
16431653
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+
16441665 write ! ( w, "<div class=\" rightside\" >" ) ;
16451666 render_stability_since_raw (
16461667 w,
16471668 item. stable_since ( tcx) . as_deref ( ) ,
1648- item . const_stability ( tcx ) ,
1669+ const_stability,
16491670 containing_item. stable_since ( tcx) . as_deref ( ) ,
1650- containing_item . const_stable_since ( tcx ) . as_deref ( ) ,
1671+ const_stable_since,
16511672 ) ;
16521673
16531674 write_srclink ( cx, item, w) ;
@@ -1683,7 +1704,7 @@ pub(crate) fn render_impl_summary(
16831704 format ! ( " data-aliases=\" {}\" " , aliases. join( "," ) )
16841705 } ;
16851706 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 ) ;
16871708 write ! ( w, "<a href=\" #{}\" class=\" anchor\" ></a>" , id) ;
16881709 write ! ( w, "<h3 class=\" code-header in-band\" >" ) ;
16891710
0 commit comments