@@ -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 } ;
@@ -675,17 +675,23 @@ enum ShortItemInfo {
675
675
Deprecation {
676
676
message : String ,
677
677
} ,
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 .
680
680
Unstable {
681
- feature : String ,
682
- tracking : Option < ( String , u32 ) > ,
681
+ features : Vec < UnstableFeature > ,
683
682
} ,
684
683
Portability {
685
684
message : String ,
686
685
} ,
687
686
}
688
687
688
+ #[ derive( Template ) ]
689
+ #[ template( path = "unstable_feature.html" ) ]
690
+ struct UnstableFeature {
691
+ feature : String ,
692
+ tracking : Option < ( String , u32 ) > ,
693
+ }
694
+
689
695
/// Render the stability, deprecation and portability information that is displayed at the top of
690
696
/// the item's documentation.
691
697
fn short_item_info (
@@ -724,19 +730,24 @@ fn short_item_info(
724
730
725
731
// Render unstable items. But don't render "rustc_private" crates (internal compiler crates).
726
732
// 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
728
734
. stability ( cx. tcx ( ) )
729
735
. 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 )
732
738
{
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
+ }
738
745
} ;
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 } ) ;
740
751
}
741
752
742
753
if let Some ( message) = portability ( item, parent) {
@@ -990,7 +1001,7 @@ fn assoc_method(
990
1001
fn render_stability_since_raw_with_extra (
991
1002
w : & mut Buffer ,
992
1003
stable_version : Option < StableSince > ,
993
- const_stability : Option < ConstStability > ,
1004
+ const_stability : Option < & ConstStability > ,
994
1005
extra_class : & str ,
995
1006
) -> bool {
996
1007
let mut title = String :: new ( ) ;
@@ -1006,12 +1017,16 @@ fn render_stability_since_raw_with_extra(
1006
1017
since_to_string ( & since)
1007
1018
. map ( |since| ( format ! ( "const since {since}" ) , format ! ( "const: {since}" ) ) )
1008
1019
}
1009
- Some ( ConstStability { level : StabilityLevel :: Unstable { issue , .. } , feature , .. } ) => {
1020
+ Some ( ConstStability { level : StabilityLevel :: Unstable { unstables , .. } , .. } ) => {
1010
1021
if stable_version. is_none ( ) {
1011
1022
// don't display const unstable if entirely unstable
1012
1023
None
1013
1024
} 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 {
1015
1030
format ! (
1016
1031
"<a \
1017
1032
href=\" https://github.com/rust-lang/rust/issues/{n}\" \
@@ -1061,7 +1076,7 @@ fn since_to_string(since: &StableSince) -> Option<String> {
1061
1076
fn render_stability_since_raw (
1062
1077
w : & mut Buffer ,
1063
1078
ver : Option < StableSince > ,
1064
- const_stability : Option < ConstStability > ,
1079
+ const_stability : Option < & ConstStability > ,
1065
1080
) -> bool {
1066
1081
render_stability_since_raw_with_extra ( w, ver, const_stability, "" )
1067
1082
}
0 commit comments