@@ -53,7 +53,7 @@ use rustc_hir::def_id::{DefId, DefIdSet};
53
53
use rustc_middle:: ty:: print:: PrintTraitRefExt ;
54
54
use rustc_middle:: ty:: { self , TyCtxt } ;
55
55
use rustc_session:: RustcVersion ;
56
- use rustc_span:: symbol:: { Symbol , sym } ;
56
+ use rustc_span:: symbol:: Symbol ;
57
57
use rustc_span:: { BytePos , DUMMY_SP , FileName , RealFileName } ;
58
58
use serde:: ser:: SerializeMap ;
59
59
use serde:: { Serialize , Serializer } ;
@@ -674,17 +674,23 @@ enum ShortItemInfo {
674
674
Deprecation {
675
675
message : String ,
676
676
} ,
677
- /// The feature corresponding to an unstable item, and optionally
678
- /// a tracking issue URL and number.
677
+ /// The features corresponding to an unstable item, and optionally
678
+ /// a tracking issue URL and number for each .
679
679
Unstable {
680
- feature : String ,
681
- tracking : Option < ( String , u32 ) > ,
680
+ features : Vec < UnstableFeature > ,
682
681
} ,
683
682
Portability {
684
683
message : String ,
685
684
} ,
686
685
}
687
686
687
+ #[ derive( Template ) ]
688
+ #[ template( path = "unstable_feature.html" ) ]
689
+ struct UnstableFeature {
690
+ feature : String ,
691
+ tracking : Option < ( String , u32 ) > ,
692
+ }
693
+
688
694
/// Render the stability, deprecation and portability information that is displayed at the top of
689
695
/// the item's documentation.
690
696
fn short_item_info (
@@ -723,19 +729,24 @@ fn short_item_info(
723
729
724
730
// Render unstable items. But don't render "rustc_private" crates (internal compiler crates).
725
731
// Those crates are permanently unstable so it makes no sense to render "unstable" everywhere.
726
- if let Some ( ( StabilityLevel :: Unstable { reason : _ , issue , .. } , feature ) ) = item
732
+ if let Some ( StabilityLevel :: Unstable { unstables , .. } ) = item
727
733
. stability ( cx. tcx ( ) )
728
734
. as_ref ( )
729
- . filter ( |stab| stab. feature != sym :: rustc_private )
730
- . map ( |stab| ( stab. level , stab . feature ) )
735
+ . filter ( |stab| ! stab. is_rustc_private ( ) )
736
+ . map ( |stab| & stab. level )
731
737
{
732
- let tracking = if let ( Some ( url) , Some ( issue) ) = ( & cx. shared . issue_tracker_base_url , issue)
733
- {
734
- Some ( ( url. clone ( ) , issue. get ( ) ) )
735
- } else {
736
- None
738
+ let track = |issue : Option < std:: num:: NonZero < u32 > > | {
739
+ if let ( Some ( url) , Some ( issue) ) = ( & cx. shared . issue_tracker_base_url , issue) {
740
+ Some ( ( url. clone ( ) , issue. get ( ) ) )
741
+ } else {
742
+ None
743
+ }
737
744
} ;
738
- extra_info. push ( ShortItemInfo :: Unstable { feature : feature. to_string ( ) , tracking } ) ;
745
+ let features = unstables
746
+ . iter ( )
747
+ . map ( |u| UnstableFeature { feature : u. feature . to_string ( ) , tracking : track ( u. issue ) } )
748
+ . collect ( ) ;
749
+ extra_info. push ( ShortItemInfo :: Unstable { features } ) ;
739
750
}
740
751
741
752
if let Some ( message) = portability ( item, parent) {
@@ -989,7 +1000,7 @@ fn assoc_method(
989
1000
fn render_stability_since_raw_with_extra (
990
1001
w : & mut Buffer ,
991
1002
stable_version : Option < StableSince > ,
992
- const_stability : Option < ConstStability > ,
1003
+ const_stability : Option < & ConstStability > ,
993
1004
extra_class : & str ,
994
1005
) -> bool {
995
1006
let mut title = String :: new ( ) ;
@@ -1005,12 +1016,16 @@ fn render_stability_since_raw_with_extra(
1005
1016
since_to_string ( & since)
1006
1017
. map ( |since| ( format ! ( "const since {since}" ) , format ! ( "const: {since}" ) ) )
1007
1018
}
1008
- Some ( ConstStability { level : StabilityLevel :: Unstable { issue , .. } , feature , .. } ) => {
1019
+ Some ( ConstStability { level : StabilityLevel :: Unstable { unstables , .. } , .. } ) => {
1009
1020
if stable_version. is_none ( ) {
1010
1021
// don't display const unstable if entirely unstable
1011
1022
None
1012
1023
} else {
1013
- let unstable = if let Some ( n) = issue {
1024
+ // if constness depends on multiple unstable features, only link to the first
1025
+ // tracking issue found, to save space. the issue description should link to issues
1026
+ // for any features it can intersect with
1027
+ let feature_issue = unstables. iter ( ) . find_map ( |u| u. issue . map ( |n| ( u. feature , n) ) ) ;
1028
+ let unstable = if let Some ( ( feature, n) ) = feature_issue {
1014
1029
format ! (
1015
1030
"<a \
1016
1031
href=\" https://github.com/rust-lang/rust/issues/{n}\" \
@@ -1060,7 +1075,7 @@ fn since_to_string(since: &StableSince) -> Option<String> {
1060
1075
fn render_stability_since_raw (
1061
1076
w : & mut Buffer ,
1062
1077
ver : Option < StableSince > ,
1063
- const_stability : Option < ConstStability > ,
1078
+ const_stability : Option < & ConstStability > ,
1064
1079
) -> bool {
1065
1080
render_stability_since_raw_with_extra ( w, ver, const_stability, "" )
1066
1081
}
0 commit comments