@@ -53,7 +53,7 @@ use rustc_hir::def_id::{DefId, DefIdSet};
5353use rustc_middle:: ty:: print:: PrintTraitRefExt ;
5454use rustc_middle:: ty:: { self , TyCtxt } ;
5555use rustc_session:: RustcVersion ;
56- use rustc_span:: symbol:: { Symbol , sym } ;
56+ use rustc_span:: symbol:: Symbol ;
5757use rustc_span:: { BytePos , DUMMY_SP , FileName , RealFileName } ;
5858use serde:: ser:: SerializeMap ;
5959use serde:: { Serialize , Serializer } ;
@@ -675,17 +675,23 @@ enum ShortItemInfo {
675675 Deprecation {
676676 message : String ,
677677 } ,
678- /// The feature corresponding to an unstable item, and optionally
679- /// a tracking issue URL and number.
678+ /// The features corresponding to an unstable item, and optionally
679+ /// a tracking issue URL and number for each .
680680 Unstable {
681- feature : String ,
682- tracking : Option < ( String , u32 ) > ,
681+ features : Vec < UnstableFeature > ,
683682 } ,
684683 Portability {
685684 message : String ,
686685 } ,
687686}
688687
688+ #[ derive( Template ) ]
689+ #[ template( path = "unstable_feature.html" ) ]
690+ struct UnstableFeature {
691+ feature : String ,
692+ tracking : Option < ( String , u32 ) > ,
693+ }
694+
689695/// Render the stability, deprecation and portability information that is displayed at the top of
690696/// the item's documentation.
691697fn short_item_info (
@@ -724,19 +730,24 @@ fn short_item_info(
724730
725731 // Render unstable items. But don't render "rustc_private" crates (internal compiler crates).
726732 // Those crates are permanently unstable so it makes no sense to render "unstable" everywhere.
727- if let Some ( ( StabilityLevel :: Unstable { reason : _ , issue , .. } , feature ) ) = item
733+ if let Some ( StabilityLevel :: Unstable { unstables , .. } ) = item
728734 . stability ( cx. tcx ( ) )
729735 . as_ref ( )
730- . filter ( |stab| stab. feature != sym :: rustc_private )
731- . map ( |stab| ( stab. level , stab . feature ) )
736+ . filter ( |stab| ! stab. is_rustc_private ( ) )
737+ . map ( |stab| & stab. level )
732738 {
733- let tracking = if let ( Some ( url) , Some ( issue) ) = ( & cx. shared . issue_tracker_base_url , issue)
734- {
735- Some ( ( url. clone ( ) , issue. get ( ) ) )
736- } else {
737- None
739+ let track = |issue : Option < std:: num:: NonZero < u32 > > | {
740+ if let ( Some ( url) , Some ( issue) ) = ( & cx. shared . issue_tracker_base_url , issue) {
741+ Some ( ( url. clone ( ) , issue. get ( ) ) )
742+ } else {
743+ None
744+ }
738745 } ;
739- extra_info. push ( ShortItemInfo :: Unstable { feature : feature. to_string ( ) , tracking } ) ;
746+ let features = unstables
747+ . iter ( )
748+ . map ( |u| UnstableFeature { feature : u. feature . to_string ( ) , tracking : track ( u. issue ) } )
749+ . collect ( ) ;
750+ extra_info. push ( ShortItemInfo :: Unstable { features } ) ;
740751 }
741752
742753 if let Some ( message) = portability ( item, parent) {
@@ -990,7 +1001,7 @@ fn assoc_method(
9901001fn render_stability_since_raw_with_extra (
9911002 w : & mut Buffer ,
9921003 stable_version : Option < StableSince > ,
993- const_stability : Option < ConstStability > ,
1004+ const_stability : Option < & ConstStability > ,
9941005 extra_class : & str ,
9951006) -> bool {
9961007 let mut title = String :: new ( ) ;
@@ -1006,12 +1017,16 @@ fn render_stability_since_raw_with_extra(
10061017 since_to_string ( & since)
10071018 . map ( |since| ( format ! ( "const since {since}" ) , format ! ( "const: {since}" ) ) )
10081019 }
1009- Some ( ConstStability { level : StabilityLevel :: Unstable { issue , .. } , feature , .. } ) => {
1020+ Some ( ConstStability { level : StabilityLevel :: Unstable { unstables , .. } , .. } ) => {
10101021 if stable_version. is_none ( ) {
10111022 // don't display const unstable if entirely unstable
10121023 None
10131024 } else {
1014- let unstable = if let Some ( n) = issue {
1025+ // if constness depends on multiple unstable features, only link to the first
1026+ // tracking issue found, to save space. the issue description should link to issues
1027+ // for any features it can intersect with
1028+ let feature_issue = unstables. iter ( ) . find_map ( |u| u. issue . map ( |n| ( u. feature , n) ) ) ;
1029+ let unstable = if let Some ( ( feature, n) ) = feature_issue {
10151030 format ! (
10161031 "<a \
10171032 href=\" https://github.com/rust-lang/rust/issues/{n}\" \
@@ -1061,7 +1076,7 @@ fn since_to_string(since: &StableSince) -> Option<String> {
10611076fn render_stability_since_raw (
10621077 w : & mut Buffer ,
10631078 ver : Option < StableSince > ,
1064- const_stability : Option < ConstStability > ,
1079+ const_stability : Option < & ConstStability > ,
10651080) -> bool {
10661081 render_stability_since_raw_with_extra ( w, ver, const_stability, "" )
10671082}
0 commit comments