@@ -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 ( ) ) ,
@@ -3431,7 +3438,7 @@ fn render_assoc_items(
3431
3438
w,
3432
3439
cx,
3433
3440
i,
3434
- Some ( containing_item) ,
3441
+ containing_item,
3435
3442
AssocItemLink :: Anchor ( None ) ,
3436
3443
render_mode,
3437
3444
containing_item. stable_since ( ) . as_deref ( ) ,
@@ -3623,7 +3630,7 @@ fn render_impl(
3623
3630
w : & mut Buffer ,
3624
3631
cx : & Context ,
3625
3632
i : & Impl ,
3626
- parent : Option < & clean:: Item > ,
3633
+ parent : & clean:: Item ,
3627
3634
link : AssocItemLink < ' _ > ,
3628
3635
render_mode : RenderMode ,
3629
3636
outer_version : Option < & str > ,
@@ -3636,6 +3643,9 @@ fn render_impl(
3636
3643
aliases : & [ String ] ,
3637
3644
cache : & Cache ,
3638
3645
) {
3646
+ let traits = & cache. traits ;
3647
+ let trait_ = i. trait_did ( ) . map ( |did| & traits[ & did] ) ;
3648
+
3639
3649
if render_mode == RenderMode :: Normal {
3640
3650
let id = cx. derive_id ( match i. inner_impl ( ) . trait_ {
3641
3651
Some ( ref t) => {
@@ -3688,6 +3698,13 @@ fn render_impl(
3688
3698
) ;
3689
3699
}
3690
3700
write ! ( w, "</h3>" ) ;
3701
+
3702
+ if trait_. is_some ( ) {
3703
+ if let Some ( portability) = portability ( & i. impl_item , Some ( parent) ) {
3704
+ write ! ( w, "<div class=\" stability\" >{}</div>" , portability) ;
3705
+ }
3706
+ }
3707
+
3691
3708
if let Some ( ref dox) = cx. shared . maybe_collapsed_doc_value ( & i. impl_item ) {
3692
3709
let mut ids = cx. id_map . borrow_mut ( ) ;
3693
3710
write ! (
@@ -3710,7 +3727,7 @@ fn render_impl(
3710
3727
w : & mut Buffer ,
3711
3728
cx : & Context ,
3712
3729
item : & clean:: Item ,
3713
- parent : Option < & clean:: Item > ,
3730
+ parent : & clean:: Item ,
3714
3731
link : AssocItemLink < ' _ > ,
3715
3732
render_mode : RenderMode ,
3716
3733
is_default_item : bool ,
@@ -3795,7 +3812,7 @@ fn render_impl(
3795
3812
if let Some ( it) = t. items . iter ( ) . find ( |i| i. name == item. name ) {
3796
3813
// We need the stability of the item from the trait
3797
3814
// because impls can't have a stability.
3798
- document_stability ( w, cx, it, is_hidden, parent) ;
3815
+ document_stability ( w, cx, it, is_hidden, Some ( parent) ) ;
3799
3816
if item. doc_value ( ) . is_some ( ) {
3800
3817
document_full ( w, item, cx, "" , is_hidden) ;
3801
3818
} else if show_def_docs {
@@ -3805,30 +3822,27 @@ fn render_impl(
3805
3822
}
3806
3823
}
3807
3824
} else {
3808
- document_stability ( w, cx, item, is_hidden, parent) ;
3825
+ document_stability ( w, cx, item, is_hidden, Some ( parent) ) ;
3809
3826
if show_def_docs {
3810
3827
document_full ( w, item, cx, "" , is_hidden) ;
3811
3828
}
3812
3829
}
3813
3830
} else {
3814
- document_stability ( w, cx, item, is_hidden, parent) ;
3831
+ document_stability ( w, cx, item, is_hidden, Some ( parent) ) ;
3815
3832
if show_def_docs {
3816
3833
document_short ( w, item, link, "" , is_hidden) ;
3817
3834
}
3818
3835
}
3819
3836
}
3820
3837
}
3821
3838
3822
- let traits = & cache. traits ;
3823
- let trait_ = i. trait_did ( ) . map ( |did| & traits[ & did] ) ;
3824
-
3825
3839
write ! ( w, "<div class=\" impl-items\" >" ) ;
3826
3840
for trait_item in & i. inner_impl ( ) . items {
3827
3841
doc_impl_item (
3828
3842
w,
3829
3843
cx,
3830
3844
trait_item,
3831
- parent,
3845
+ if trait_ . is_some ( ) { & i . impl_item } else { parent } ,
3832
3846
link,
3833
3847
render_mode,
3834
3848
false ,
@@ -3844,7 +3858,7 @@ fn render_impl(
3844
3858
cx : & Context ,
3845
3859
t : & clean:: Trait ,
3846
3860
i : & clean:: Impl ,
3847
- parent : Option < & clean:: Item > ,
3861
+ parent : & clean:: Item ,
3848
3862
render_mode : RenderMode ,
3849
3863
outer_version : Option < & str > ,
3850
3864
show_def_docs : bool ,
@@ -3885,7 +3899,7 @@ fn render_impl(
3885
3899
cx,
3886
3900
t,
3887
3901
& i. inner_impl ( ) ,
3888
- parent ,
3902
+ & i . impl_item ,
3889
3903
render_mode,
3890
3904
outer_version,
3891
3905
show_def_docs,
0 commit comments