@@ -2251,6 +2251,22 @@ fn stability_tags(item: &clean::Item, parent: &clean::Item) -> String {
2251
2251
tags
2252
2252
}
2253
2253
2254
+ fn portability ( item : & clean:: Item , parent : Option < & clean:: Item > ) -> Option < String > {
2255
+ let cfg = match ( & item. attrs . cfg , parent. and_then ( |p| p. attrs . cfg . as_ref ( ) ) ) {
2256
+ ( Some ( cfg) , Some ( parent_cfg) ) => cfg. simplify_with ( parent_cfg) ,
2257
+ ( cfg, _) => cfg. as_deref ( ) . cloned ( ) ,
2258
+ } ;
2259
+
2260
+ debug ! (
2261
+ "Portability {:?} - {:?} = {:?}" ,
2262
+ item. attrs. cfg,
2263
+ parent. and_then( |p| p. attrs. cfg. as_ref( ) ) ,
2264
+ cfg
2265
+ ) ;
2266
+
2267
+ Some ( format ! ( "<div class=\" stab portability\" >{}</div>" , cfg?. render_long_html( ) ) )
2268
+ }
2269
+
2254
2270
/// Render the stability and/or deprecation warning that is displayed at the top of the item's
2255
2271
/// documentation.
2256
2272
fn short_stability ( item : & clean:: Item , cx : & Context , parent : Option < & clean:: Item > ) -> Vec < String > {
@@ -2328,19 +2344,8 @@ fn short_stability(item: &clean::Item, cx: &Context, parent: Option<&clean::Item
2328
2344
stability. push ( format ! ( "<div class=\" stab unstable\" >{}</div>" , message) ) ;
2329
2345
}
2330
2346
2331
- let cfg = match ( & item. attrs . cfg , parent. and_then ( |p| p. attrs . cfg . as_ref ( ) ) ) {
2332
- ( Some ( cfg) , Some ( parent_cfg) ) => cfg. simplify_with ( parent_cfg) ,
2333
- ( cfg, _) => cfg. as_deref ( ) . cloned ( ) ,
2334
- } ;
2335
-
2336
- debug ! (
2337
- "Portability {:?} - {:?} = {:?}" ,
2338
- item. attrs. cfg,
2339
- parent. and_then( |p| p. attrs. cfg. as_ref( ) ) ,
2340
- cfg
2341
- ) ;
2342
- if let Some ( cfg) = cfg {
2343
- stability. push ( format ! ( "<div class=\" stab portability\" >{}</div>" , cfg. render_long_html( ) ) ) ;
2347
+ if let Some ( portability) = portability ( item, parent) {
2348
+ stability. push ( portability) ;
2344
2349
}
2345
2350
2346
2351
stability
@@ -2431,6 +2436,7 @@ fn item_function(w: &mut Buffer, cx: &Context, it: &clean::Item, f: &clean::Func
2431
2436
fn render_implementor (
2432
2437
cx : & Context ,
2433
2438
implementor : & Impl ,
2439
+ parent : & clean:: Item ,
2434
2440
w : & mut Buffer ,
2435
2441
implementor_dups : & FxHashMap < & str , ( DefId , bool ) > ,
2436
2442
aliases : & [ String ] ,
@@ -2450,7 +2456,7 @@ fn render_implementor(
2450
2456
w,
2451
2457
cx,
2452
2458
implementor,
2453
- None ,
2459
+ parent ,
2454
2460
AssocItemLink :: Anchor ( None ) ,
2455
2461
RenderMode :: Normal ,
2456
2462
implementor. impl_item . stable_since ( ) . as_deref ( ) ,
@@ -2480,7 +2486,7 @@ fn render_impls(
2480
2486
& mut buffer,
2481
2487
cx,
2482
2488
i,
2483
- Some ( containing_item) ,
2489
+ containing_item,
2484
2490
assoc_link,
2485
2491
RenderMode :: Normal ,
2486
2492
containing_item. stable_since ( ) . as_deref ( ) ,
@@ -2727,7 +2733,7 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait,
2727
2733
w,
2728
2734
cx,
2729
2735
& implementor,
2730
- None ,
2736
+ it ,
2731
2737
assoc_link,
2732
2738
RenderMode :: Normal ,
2733
2739
implementor. impl_item . stable_since ( ) . as_deref ( ) ,
@@ -2749,7 +2755,7 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait,
2749
2755
"<div class=\" item-list\" id=\" implementors-list\" >" ,
2750
2756
) ;
2751
2757
for implementor in concrete {
2752
- render_implementor ( cx, implementor, w, & implementor_dups, & [ ] , cache) ;
2758
+ render_implementor ( cx, implementor, it , w, & implementor_dups, & [ ] , cache) ;
2753
2759
}
2754
2760
write_loading_content ( w, "</div>" ) ;
2755
2761
@@ -2764,6 +2770,7 @@ fn item_trait(w: &mut Buffer, cx: &Context, it: &clean::Item, t: &clean::Trait,
2764
2770
render_implementor (
2765
2771
cx,
2766
2772
implementor,
2773
+ it,
2767
2774
w,
2768
2775
& implementor_dups,
2769
2776
& collect_paths_for_type ( implementor. inner_impl ( ) . for_ . clone ( ) ) ,
@@ -3430,7 +3437,7 @@ fn render_assoc_items(
3430
3437
w,
3431
3438
cx,
3432
3439
i,
3433
- Some ( containing_item) ,
3440
+ containing_item,
3434
3441
AssocItemLink :: Anchor ( None ) ,
3435
3442
render_mode,
3436
3443
containing_item. stable_since ( ) . as_deref ( ) ,
@@ -3622,7 +3629,7 @@ fn render_impl(
3622
3629
w : & mut Buffer ,
3623
3630
cx : & Context ,
3624
3631
i : & Impl ,
3625
- parent : Option < & clean:: Item > ,
3632
+ parent : & clean:: Item ,
3626
3633
link : AssocItemLink < ' _ > ,
3627
3634
render_mode : RenderMode ,
3628
3635
outer_version : Option < & str > ,
@@ -3635,6 +3642,9 @@ fn render_impl(
3635
3642
aliases : & [ String ] ,
3636
3643
cache : & Cache ,
3637
3644
) {
3645
+ let traits = & cache. traits ;
3646
+ let trait_ = i. trait_did ( ) . map ( |did| & traits[ & did] ) ;
3647
+
3638
3648
if render_mode == RenderMode :: Normal {
3639
3649
let id = cx. derive_id ( match i. inner_impl ( ) . trait_ {
3640
3650
Some ( ref t) => {
@@ -3687,6 +3697,13 @@ fn render_impl(
3687
3697
) ;
3688
3698
}
3689
3699
write ! ( w, "</h3>" ) ;
3700
+
3701
+ if trait_. is_some ( ) {
3702
+ if let Some ( portability) = portability ( & i. impl_item , Some ( parent) ) {
3703
+ write ! ( w, "<div class=\" stability\" >{}</div>" , portability) ;
3704
+ }
3705
+ }
3706
+
3690
3707
if let Some ( ref dox) = cx. shared . maybe_collapsed_doc_value ( & i. impl_item ) {
3691
3708
let mut ids = cx. id_map . borrow_mut ( ) ;
3692
3709
write ! (
@@ -3709,7 +3726,7 @@ fn render_impl(
3709
3726
w : & mut Buffer ,
3710
3727
cx : & Context ,
3711
3728
item : & clean:: Item ,
3712
- parent : Option < & clean:: Item > ,
3729
+ parent : & clean:: Item ,
3713
3730
link : AssocItemLink < ' _ > ,
3714
3731
render_mode : RenderMode ,
3715
3732
is_default_item : bool ,
@@ -3794,7 +3811,7 @@ fn render_impl(
3794
3811
if let Some ( it) = t. items . iter ( ) . find ( |i| i. name == item. name ) {
3795
3812
// We need the stability of the item from the trait
3796
3813
// because impls can't have a stability.
3797
- document_stability ( w, cx, it, is_hidden, parent) ;
3814
+ document_stability ( w, cx, it, is_hidden, Some ( parent) ) ;
3798
3815
if item. doc_value ( ) . is_some ( ) {
3799
3816
document_full ( w, item, cx, "" , is_hidden) ;
3800
3817
} else if show_def_docs {
@@ -3804,30 +3821,27 @@ fn render_impl(
3804
3821
}
3805
3822
}
3806
3823
} else {
3807
- document_stability ( w, cx, item, is_hidden, parent) ;
3824
+ document_stability ( w, cx, item, is_hidden, Some ( parent) ) ;
3808
3825
if show_def_docs {
3809
3826
document_full ( w, item, cx, "" , is_hidden) ;
3810
3827
}
3811
3828
}
3812
3829
} else {
3813
- document_stability ( w, cx, item, is_hidden, parent) ;
3830
+ document_stability ( w, cx, item, is_hidden, Some ( parent) ) ;
3814
3831
if show_def_docs {
3815
3832
document_short ( w, item, link, "" , is_hidden) ;
3816
3833
}
3817
3834
}
3818
3835
}
3819
3836
}
3820
3837
3821
- let traits = & cache. traits ;
3822
- let trait_ = i. trait_did ( ) . map ( |did| & traits[ & did] ) ;
3823
-
3824
3838
write ! ( w, "<div class=\" impl-items\" >" ) ;
3825
3839
for trait_item in & i. inner_impl ( ) . items {
3826
3840
doc_impl_item (
3827
3841
w,
3828
3842
cx,
3829
3843
trait_item,
3830
- parent,
3844
+ if trait_ . is_some ( ) { & i . impl_item } else { parent } ,
3831
3845
link,
3832
3846
render_mode,
3833
3847
false ,
@@ -3843,7 +3857,7 @@ fn render_impl(
3843
3857
cx : & Context ,
3844
3858
t : & clean:: Trait ,
3845
3859
i : & clean:: Impl ,
3846
- parent : Option < & clean:: Item > ,
3860
+ parent : & clean:: Item ,
3847
3861
render_mode : RenderMode ,
3848
3862
outer_version : Option < & str > ,
3849
3863
show_def_docs : bool ,
@@ -3884,7 +3898,7 @@ fn render_impl(
3884
3898
cx,
3885
3899
t,
3886
3900
& i. inner_impl ( ) ,
3887
- parent ,
3901
+ & i . impl_item ,
3888
3902
render_mode,
3889
3903
outer_version,
3890
3904
show_def_docs,
0 commit comments