@@ -436,16 +436,9 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
436
436
}
437
437
438
438
clean:: ImportItem ( ref import) => {
439
- let stab_tags = if let Some ( import_def_id) = import. source . did {
440
- // Just need an item with the correct def_id and attrs
441
- let import_item =
442
- clean:: Item { item_id : import_def_id. into ( ) , ..( * myitem) . clone ( ) } ;
443
-
444
- let stab_tags = Some ( extra_info_tags ( & import_item, item, tcx) . to_string ( ) ) ;
445
- stab_tags
446
- } else {
447
- None
448
- } ;
439
+ let stab_tags = import. source . did . map_or_else ( String :: new, |import_def_id| {
440
+ extra_info_tags ( tcx, myitem, item, Some ( import_def_id) ) . to_string ( )
441
+ } ) ;
449
442
450
443
w. write_str ( ITEM_TABLE_ROW_OPEN ) ;
451
444
let id = match import. kind {
@@ -454,7 +447,6 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
454
447
}
455
448
clean:: ImportKind :: Glob => String :: new ( ) ,
456
449
} ;
457
- let stab_tags = stab_tags. unwrap_or_default ( ) ;
458
450
let ( stab_tags_before, stab_tags_after) = if stab_tags. is_empty ( ) {
459
451
( "" , "" )
460
452
} else {
@@ -521,7 +513,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
521
513
{docs_before}{docs}{docs_after}",
522
514
name = EscapeBodyTextWithWbr ( myitem. name. unwrap( ) . as_str( ) ) ,
523
515
visibility_and_hidden = visibility_and_hidden,
524
- stab_tags = extra_info_tags( myitem, item, tcx ) ,
516
+ stab_tags = extra_info_tags( tcx , myitem, item, None ) ,
525
517
class = myitem. type_( ) ,
526
518
unsafety_flag = unsafety_flag,
527
519
href = item_path( myitem. type_( ) , myitem. name. unwrap( ) . as_str( ) ) ,
@@ -544,9 +536,10 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
544
536
/// Render the stability, deprecation and portability tags that are displayed in the item's summary
545
537
/// at the module level.
546
538
fn extra_info_tags < ' a , ' tcx : ' a > (
539
+ tcx : TyCtxt < ' tcx > ,
547
540
item : & ' a clean:: Item ,
548
541
parent : & ' a clean:: Item ,
549
- tcx : TyCtxt < ' tcx > ,
542
+ import_def_id : Option < DefId > ,
550
543
) -> impl fmt:: Display + ' a + Captures < ' tcx > {
551
544
display_fn ( move |f| {
552
545
fn tag_html < ' a > (
@@ -564,18 +557,18 @@ fn extra_info_tags<'a, 'tcx: 'a>(
564
557
}
565
558
566
559
// The trailing space after each tag is to space it properly against the rest of the docs.
567
- if let Some ( depr) = & item. deprecation ( tcx) {
560
+ let deprecation = import_def_id
561
+ . map_or_else ( || item. deprecation ( tcx) , |import_did| tcx. lookup_deprecation ( import_did) ) ;
562
+ if let Some ( depr) = deprecation {
568
563
let message = if depr. is_in_effect ( ) { "Deprecated" } else { "Deprecation planned" } ;
569
564
write ! ( f, "{}" , tag_html( "deprecated" , "" , message) ) ?;
570
565
}
571
566
572
567
// The "rustc_private" crates are permanently unstable so it makes no sense
573
568
// to render "unstable" everywhere.
574
- if item
575
- . stability ( tcx)
576
- . as_ref ( )
577
- . is_some_and ( |s| s. is_unstable ( ) && s. feature != sym:: rustc_private)
578
- {
569
+ let stability = import_def_id
570
+ . map_or_else ( || item. stability ( tcx) , |import_did| tcx. lookup_stability ( import_did) ) ;
571
+ if stability. is_some_and ( |s| s. is_unstable ( ) && s. feature != sym:: rustc_private) {
579
572
write ! ( f, "{}" , tag_html( "unstable" , "" , "Experimental" ) ) ?;
580
573
}
581
574
0 commit comments