@@ -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 ;
@@ -2349,21 +2350,22 @@ fn clean_maybe_renamed_item<'tcx>(
23492350 _ => unreachable ! ( "not yet converted" ) ,
23502351 } ;
23512352
2352- let mut extra_attrs = Vec :: new ( ) ;
2353+ let mut import_attrs = Vec :: new ( ) ;
2354+ let mut target_attrs = Vec :: new ( ) ;
23532355 if let Some ( import_id) = import_id &&
23542356 let Some ( hir:: Node :: Item ( use_node) ) = cx. tcx . hir ( ) . find_by_def_id ( import_id)
23552357 {
23562358 let is_inline = inline:: load_attrs ( cx, import_id. to_def_id ( ) ) . lists ( sym:: doc) . get_word_attr ( sym:: inline) . is_some ( ) ;
23572359 // Then we get all the various imports' attributes.
2358- get_all_import_attributes ( use_node, cx. tcx , item. owner_id . def_id , & mut extra_attrs , is_inline) ;
2359- add_without_unwanted_attributes ( & mut extra_attrs , inline:: load_attrs ( cx, def_id) , is_inline) ;
2360+ get_all_import_attributes ( use_node, cx. tcx , item. owner_id . def_id , & mut import_attrs , is_inline) ;
2361+ add_without_unwanted_attributes ( & mut target_attrs , inline:: load_attrs ( cx, def_id) , is_inline) ;
23602362 } else {
23612363 // We only keep the item's attributes.
2362- extra_attrs . extend_from_slice ( inline:: load_attrs ( cx, def_id) ) ;
2364+ target_attrs . extend_from_slice ( inline:: load_attrs ( cx, def_id) ) ;
23632365 }
23642366
2365- let attrs = Attributes :: from_ast ( & extra_attrs ) ;
2366- let cfg = extra_attrs . cfg ( cx. tcx , & cx . cache . hidden_cfg ) ;
2367+ let import_parent = import_id . map ( |import_id| cx . tcx . local_parent ( import_id ) . to_def_id ( ) ) ;
2368+ let ( attrs , cfg) = merge_attrs ( cx, import_parent , & target_attrs , Some ( & import_attrs ) ) ;
23672369
23682370 let mut item =
23692371 Item :: from_def_id_and_attrs_and_parts ( def_id, Some ( name) , kind, Box :: new ( attrs) , cfg) ;
0 commit comments