@@ -436,16 +436,9 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
436436 }
437437
438438 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+ } ) ;
449442
450443 w. write_str ( ITEM_TABLE_ROW_OPEN ) ;
451444 let id = match import. kind {
@@ -454,7 +447,6 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
454447 }
455448 clean:: ImportKind :: Glob => String :: new ( ) ,
456449 } ;
457- let stab_tags = stab_tags. unwrap_or_default ( ) ;
458450 let ( stab_tags_before, stab_tags_after) = if stab_tags. is_empty ( ) {
459451 ( "" , "" )
460452 } else {
@@ -521,7 +513,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
521513 {docs_before}{docs}{docs_after}",
522514 name = EscapeBodyTextWithWbr ( myitem. name. unwrap( ) . as_str( ) ) ,
523515 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 ) ,
525517 class = myitem. type_( ) ,
526518 unsafety_flag = unsafety_flag,
527519 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:
544536/// Render the stability, deprecation and portability tags that are displayed in the item's summary
545537/// at the module level.
546538fn extra_info_tags < ' a , ' tcx : ' a > (
539+ tcx : TyCtxt < ' tcx > ,
547540 item : & ' a clean:: Item ,
548541 parent : & ' a clean:: Item ,
549- tcx : TyCtxt < ' tcx > ,
542+ import_def_id : Option < DefId > ,
550543) -> impl fmt:: Display + ' a + Captures < ' tcx > {
551544 display_fn ( move |f| {
552545 fn tag_html < ' a > (
@@ -564,18 +557,18 @@ fn extra_info_tags<'a, 'tcx: 'a>(
564557 }
565558
566559 // 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 {
568563 let message = if depr. is_in_effect ( ) { "Deprecated" } else { "Deprecation planned" } ;
569564 write ! ( f, "{}" , tag_html( "deprecated" , "" , message) ) ?;
570565 }
571566
572567 // The "rustc_private" crates are permanently unstable so it makes no sense
573568 // 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) {
579572 write ! ( f, "{}" , tag_html( "unstable" , "" , "Experimental" ) ) ?;
580573 }
581574
0 commit comments