@@ -39,6 +39,7 @@ use std::hash::Hash;
3939use std:: mem;
4040use thin_vec:: ThinVec ;
4141
42+ use crate :: clean:: inline:: merge_attrs;
4243use crate :: core:: { self , DocContext , ImplTraitParam } ;
4344use crate :: formats:: item_type:: ItemType ;
4445use crate :: visit_ast:: Module as DocModule ;
@@ -2373,21 +2374,22 @@ fn clean_maybe_renamed_item<'tcx>(
23732374 _ => unreachable ! ( "not yet converted" ) ,
23742375 } ;
23752376
2376- let mut extra_attrs = Vec :: new ( ) ;
2377+ let mut import_attrs = Vec :: new ( ) ;
2378+ let mut target_attrs = Vec :: new ( ) ;
23772379 if let Some ( import_id) = import_id &&
23782380 let Some ( hir:: Node :: Item ( use_node) ) = cx. tcx . hir ( ) . find_by_def_id ( import_id)
23792381 {
23802382 let is_inline = inline:: load_attrs ( cx, import_id. to_def_id ( ) ) . lists ( sym:: doc) . get_word_attr ( sym:: inline) . is_some ( ) ;
23812383 // Then we get all the various imports' attributes.
2382- get_all_import_attributes ( use_node, cx. tcx , item. owner_id . def_id , & mut extra_attrs , is_inline) ;
2383- add_without_unwanted_attributes ( & mut extra_attrs , inline:: load_attrs ( cx, def_id) , is_inline) ;
2384+ get_all_import_attributes ( use_node, cx. tcx , item. owner_id . def_id , & mut import_attrs , is_inline) ;
2385+ add_without_unwanted_attributes ( & mut target_attrs , inline:: load_attrs ( cx, def_id) , is_inline) ;
23842386 } else {
23852387 // We only keep the item's attributes.
2386- extra_attrs . extend_from_slice ( inline:: load_attrs ( cx, def_id) ) ;
2388+ target_attrs . extend_from_slice ( inline:: load_attrs ( cx, def_id) ) ;
23872389 }
23882390
2389- let attrs = Attributes :: from_ast ( & extra_attrs ) ;
2390- let cfg = extra_attrs . cfg ( cx. tcx , & cx . cache . hidden_cfg ) ;
2391+ let import_parent = import_id . map ( |import_id| cx . tcx . local_parent ( import_id ) . to_def_id ( ) ) ;
2392+ let ( attrs , cfg) = merge_attrs ( cx, import_parent , & target_attrs , Some ( & import_attrs ) ) ;
23912393
23922394 let mut item =
23932395 Item :: from_def_id_and_attrs_and_parts ( def_id, Some ( name) , kind, Box :: new ( attrs) , cfg) ;
0 commit comments