@@ -39,6 +39,7 @@ use std::hash::Hash;
39
39
use std:: mem;
40
40
use thin_vec:: ThinVec ;
41
41
42
+ use crate :: clean:: inline:: merge_attrs;
42
43
use crate :: core:: { self , DocContext , ImplTraitParam } ;
43
44
use crate :: formats:: item_type:: ItemType ;
44
45
use crate :: visit_ast:: Module as DocModule ;
@@ -2373,21 +2374,22 @@ fn clean_maybe_renamed_item<'tcx>(
2373
2374
_ => unreachable ! ( "not yet converted" ) ,
2374
2375
} ;
2375
2376
2376
- let mut extra_attrs = Vec :: new ( ) ;
2377
+ let mut import_attrs = Vec :: new ( ) ;
2378
+ let mut target_attrs = Vec :: new ( ) ;
2377
2379
if let Some ( import_id) = import_id &&
2378
2380
let Some ( hir:: Node :: Item ( use_node) ) = cx. tcx . hir ( ) . find_by_def_id ( import_id)
2379
2381
{
2380
2382
let is_inline = inline:: load_attrs ( cx, import_id. to_def_id ( ) ) . lists ( sym:: doc) . get_word_attr ( sym:: inline) . is_some ( ) ;
2381
2383
// 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) ;
2384
2386
} else {
2385
2387
// 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) ) ;
2387
2389
}
2388
2390
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 ) ) ;
2391
2393
2392
2394
let mut item =
2393
2395
Item :: from_def_id_and_attrs_and_parts ( def_id, Some ( name) , kind, Box :: new ( attrs) , cfg) ;
0 commit comments