@@ -48,7 +48,7 @@ use std::str;
48
48
use std:: string:: ToString ;
49
49
50
50
use askama:: Template ;
51
- use rustc_attr:: { ConstStability , Deprecation , StabilityLevel } ;
51
+ use rustc_attr:: { rust_version_symbol , ConstStability , Deprecation , Since , StabilityLevel } ;
52
52
use rustc_data_structures:: captures:: Captures ;
53
53
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
54
54
use rustc_hir:: def_id:: { DefId , DefIdSet } ;
@@ -911,13 +911,17 @@ fn assoc_method(
911
911
/// consequence of the above rules.
912
912
fn render_stability_since_raw_with_extra (
913
913
w : & mut Buffer ,
914
- ver : Option < Symbol > ,
914
+ ver : Option < Since > ,
915
915
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 > ,
918
918
extra_class : & str ,
919
919
) -> 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
+ } ;
921
925
922
926
let mut title = String :: new ( ) ;
923
927
let mut stability = String :: new ( ) ;
@@ -931,7 +935,8 @@ fn render_stability_since_raw_with_extra(
931
935
Some ( ConstStability { level : StabilityLevel :: Stable { since, .. } , .. } )
932
936
if Some ( since) != containing_const_ver =>
933
937
{
934
- Some ( ( format ! ( "const since {since}" ) , format ! ( "const: {since}" ) ) )
938
+ since_to_string ( & since)
939
+ . map ( |since| ( format ! ( "const since {since}" ) , format ! ( "const: {since}" ) ) )
935
940
}
936
941
Some ( ConstStability { level : StabilityLevel :: Unstable { issue, .. } , feature, .. } ) => {
937
942
let unstable = if let Some ( n) = issue {
@@ -971,13 +976,21 @@ fn render_stability_since_raw_with_extra(
971
976
!stability. is_empty ( )
972
977
}
973
978
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
+
974
987
#[ inline]
975
988
fn render_stability_since_raw (
976
989
w : & mut Buffer ,
977
- ver : Option < Symbol > ,
990
+ ver : Option < Since > ,
978
991
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 > ,
981
994
) -> bool {
982
995
render_stability_since_raw_with_extra (
983
996
w,
0 commit comments