@@ -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 ;
@@ -2349,21 +2350,22 @@ fn clean_maybe_renamed_item<'tcx>(
2349
2350
_ => unreachable ! ( "not yet converted" ) ,
2350
2351
} ;
2351
2352
2352
- let mut extra_attrs = Vec :: new ( ) ;
2353
+ let mut import_attrs = Vec :: new ( ) ;
2354
+ let mut target_attrs = Vec :: new ( ) ;
2353
2355
if let Some ( import_id) = import_id &&
2354
2356
let Some ( hir:: Node :: Item ( use_node) ) = cx. tcx . hir ( ) . find_by_def_id ( import_id)
2355
2357
{
2356
2358
let is_inline = inline:: load_attrs ( cx, import_id. to_def_id ( ) ) . lists ( sym:: doc) . get_word_attr ( sym:: inline) . is_some ( ) ;
2357
2359
// 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) ;
2360
2362
} else {
2361
2363
// 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) ) ;
2363
2365
}
2364
2366
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 ) ) ;
2367
2369
2368
2370
let mut item =
2369
2371
Item :: from_def_id_and_attrs_and_parts ( def_id, Some ( name) , kind, Box :: new ( attrs) , cfg) ;
0 commit comments