@@ -48,7 +48,7 @@ use std::str;
4848use std:: string:: ToString ;
4949
5050use askama:: Template ;
51- use rustc_attr:: { ConstStability , Deprecation , StabilityLevel } ;
51+ use rustc_attr:: { rust_version_symbol , ConstStability , Deprecation , Since , StabilityLevel } ;
5252use rustc_data_structures:: captures:: Captures ;
5353use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
5454use rustc_hir:: def_id:: { DefId , DefIdSet } ;
@@ -911,13 +911,17 @@ fn assoc_method(
911911/// consequence of the above rules.
912912fn render_stability_since_raw_with_extra (
913913 w : & mut Buffer ,
914- ver : Option < Symbol > ,
914+ ver : Option < Since > ,
915915 const_stability : Option < ConstStability > ,
916- containing_ver : Option < Symbol > ,
917- containing_const_ver : Option < Symbol > ,
916+ containing_ver : Option < Since > ,
917+ containing_const_ver : Option < Since > ,
918918 extra_class : & str ,
919919) -> bool {
920- let stable_version = ver. filter ( |inner| !inner. is_empty ( ) && Some ( * inner) != containing_ver) ;
920+ let stable_version = if ver != containing_ver && let Some ( ver) = & ver {
921+ since_to_string ( ver)
922+ } else {
923+ None
924+ } ;
921925
922926 let mut title = String :: new ( ) ;
923927 let mut stability = String :: new ( ) ;
@@ -931,7 +935,8 @@ fn render_stability_since_raw_with_extra(
931935 Some ( ConstStability { level : StabilityLevel :: Stable { since, .. } , .. } )
932936 if Some ( since) != containing_const_ver =>
933937 {
934- Some ( ( format ! ( "const since {since}" ) , format ! ( "const: {since}" ) ) )
938+ since_to_string ( & since)
939+ . map ( |since| ( format ! ( "const since {since}" ) , format ! ( "const: {since}" ) ) )
935940 }
936941 Some ( ConstStability { level : StabilityLevel :: Unstable { issue, .. } , feature, .. } ) => {
937942 let unstable = if let Some ( n) = issue {
@@ -971,13 +976,21 @@ fn render_stability_since_raw_with_extra(
971976 !stability. is_empty ( )
972977}
973978
979+ fn since_to_string ( since : & Since ) -> Option < String > {
980+ match since {
981+ Since :: Version ( since) => Some ( since. to_string ( ) ) ,
982+ Since :: Current => Some ( rust_version_symbol ( ) . to_string ( ) ) ,
983+ Since :: Err => None ,
984+ }
985+ }
986+
974987#[ inline]
975988fn render_stability_since_raw (
976989 w : & mut Buffer ,
977- ver : Option < Symbol > ,
990+ ver : Option < Since > ,
978991 const_stability : Option < ConstStability > ,
979- containing_ver : Option < Symbol > ,
980- containing_const_ver : Option < Symbol > ,
992+ containing_ver : Option < Since > ,
993+ containing_const_ver : Option < Since > ,
981994) -> bool {
982995 render_stability_since_raw_with_extra (
983996 w,
0 commit comments