@@ -217,6 +217,10 @@ fn toggle_close(mut w: impl fmt::Write) {
217217}
218218
219219fn item_module ( cx : & Context < ' _ > , item : & clean:: Item , items : & [ clean:: Item ] ) -> impl fmt:: Display {
220+ fn deprecation_class ( is_deprecated : bool ) -> & ' static str {
221+ if is_deprecated { " class=\" deprecated\" " } else { "" }
222+ }
223+
220224 fmt:: from_fn ( |w| {
221225 write ! ( w, "{}" , document( cx, item, None , HeadingOffset :: H2 ) ) ?;
222226
@@ -370,11 +374,18 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
370374 write ! ( w, "</code></dt>" ) ?
371375 }
372376 clean:: ImportItem ( ref import) => {
373- let stab_tags =
374- import. source . did . map_or_else ( String :: new, |import_def_id| {
375- print_extra_info_tags ( tcx, myitem, item, Some ( import_def_id) )
376- . to_string ( )
377- } ) ;
377+ let ( stab_tags, deprecation) = match import. source . did {
378+ Some ( import_def_id) => {
379+ let stab_tags =
380+ print_extra_info_tags ( tcx, myitem, item, Some ( import_def_id) )
381+ . to_string ( ) ;
382+ let deprecation = tcx
383+ . lookup_deprecation ( import_def_id)
384+ . is_some_and ( |deprecation| deprecation. is_in_effect ( ) ) ;
385+ ( stab_tags, deprecation)
386+ }
387+ None => ( String :: new ( ) , item. is_deprecated ( tcx) ) ,
388+ } ;
378389 let id = match import. kind {
379390 clean:: ImportKind :: Simple ( s) => {
380391 format ! ( " id=\" {}\" " , cx. derive_id( format!( "reexport.{s}" ) ) )
@@ -383,8 +394,8 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
383394 } ;
384395 write ! (
385396 w,
386- "<dt{id}> \
387- <code>"
397+ "<dt{id}{deprecation_attr}><code>" ,
398+ deprecation_attr = deprecation_class ( deprecation )
388399 ) ?;
389400 render_attributes_in_code ( w, myitem, "" , cx) ?;
390401 write ! (
@@ -396,9 +407,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
396407 ) ?;
397408 }
398409 _ => {
399- if myitem. name . is_none ( ) {
400- continue ;
401- }
410+ let Some ( item_name) = myitem. name else { continue } ;
402411
403412 let unsafety_flag = match myitem. kind {
404413 clean:: FunctionItem ( _) | clean:: ForeignFunctionItem ( ..)
@@ -431,9 +440,10 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
431440 . into_string ( ) ;
432441 let ( docs_before, docs_after) =
433442 if docs. is_empty ( ) { ( "" , "" ) } else { ( "<dd>" , "</dd>" ) } ;
443+ let deprecation_attr = deprecation_class ( myitem. is_deprecated ( tcx) ) ;
434444 write ! (
435445 w,
436- "<dt>\
446+ "<dt{deprecation_attr} >\
437447 <a class=\" {class}\" href=\" {href}\" title=\" {title1} {title2}\" >\
438448 {name}\
439449 </a>\
@@ -442,12 +452,12 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
442452 {stab_tags}\
443453 </dt>\
444454 {docs_before}{docs}{docs_after}",
445- name = EscapeBodyTextWithWbr ( myitem . name . unwrap ( ) . as_str( ) ) ,
455+ name = EscapeBodyTextWithWbr ( item_name . as_str( ) ) ,
446456 visibility_and_hidden = visibility_and_hidden,
447457 stab_tags = print_extra_info_tags( tcx, myitem, item, None ) ,
448458 class = type_,
449459 unsafety_flag = unsafety_flag,
450- href = print_item_path( type_, myitem . name . unwrap ( ) . as_str( ) ) ,
460+ href = print_item_path( type_, item_name . as_str( ) ) ,
451461 title1 = myitem. type_( ) ,
452462 title2 = full_path( cx, myitem) ,
453463 ) ?;
@@ -778,15 +788,24 @@ fn item_trait(cx: &Context<'_>, it: &clean::Item, t: &clean::Trait) -> impl fmt:
778788
779789 let content = document_full ( m, cx, HeadingOffset :: H5 ) . to_string ( ) ;
780790
791+ let mut deprecation_attr =
792+ if m. is_deprecated ( cx. tcx ( ) ) { " deprecated" } else { "" } ;
793+
781794 let toggled = !content. is_empty ( ) ;
782795 if toggled {
783796 let method_toggle_class =
784797 if item_type. is_method ( ) { " method-toggle" } else { "" } ;
785- write ! ( w, "<details class=\" toggle{method_toggle_class}\" open><summary>" ) ?;
798+ write ! (
799+ w,
800+ "<details \
801+ class=\" toggle{method_toggle_class}{deprecation_attr}\" \
802+ open><summary>"
803+ ) ?;
804+ deprecation_attr = "" ;
786805 }
787806 write ! (
788807 w,
789- "<section id=\" {id}\" class=\" method\" >\
808+ "<section id=\" {id}\" class=\" method{deprecation_attr} \" >\
790809 {}\
791810 <h4 class=\" code-header\" >{}</h4></section>",
792811 render_rightside( cx, m, RenderMode :: Normal ) ,
0 commit comments