@@ -2100,14 +2100,15 @@ fn get_all_import_attributes<'hir>(
21002100 tcx : TyCtxt < ' hir > ,
21012101 target_def_id : LocalDefId ,
21022102 attributes : & mut Vec < ast:: Attribute > ,
2103+ is_inline : bool ,
21032104) {
21042105 let hir_map = tcx. hir ( ) ;
21052106 let mut visitor = OneLevelVisitor :: new ( hir_map, target_def_id) ;
21062107 let mut visited = FxHashSet :: default ( ) ;
21072108 // If the item is an import and has at least a path with two parts, we go into it.
21082109 while let hir:: ItemKind :: Use ( path, _) = item. kind && visited. insert ( item. hir_id ( ) ) {
21092110 // We add the attributes from this import into the list.
2110- add_without_unwanted_attributes ( attributes, hir_map. attrs ( item. hir_id ( ) ) ) ;
2111+ add_without_unwanted_attributes ( attributes, hir_map. attrs ( item. hir_id ( ) ) , is_inline ) ;
21112112
21122113 let def_id = if path. segments . len ( ) > 1 {
21132114 match path. segments [ path. segments . len ( ) - 2 ] . res {
@@ -2189,7 +2190,16 @@ fn filter_tokens_from_list(
21892190/// * `doc(inline)`
21902191/// * `doc(no_inline)`
21912192/// * `doc(hidden)`
2192- fn add_without_unwanted_attributes ( attrs : & mut Vec < ast:: Attribute > , new_attrs : & [ ast:: Attribute ] ) {
2193+ fn add_without_unwanted_attributes (
2194+ attrs : & mut Vec < ast:: Attribute > ,
2195+ new_attrs : & [ ast:: Attribute ] ,
2196+ is_inline : bool ,
2197+ ) {
2198+ // If it's `#[doc(inline)]`, we don't want all attributes, otherwise we keep everything.
2199+ if !is_inline {
2200+ attrs. extend_from_slice ( new_attrs) ;
2201+ return ;
2202+ }
21932203 for attr in new_attrs {
21942204 let mut attr = attr. clone ( ) ;
21952205 match attr. kind {
@@ -2321,9 +2331,10 @@ fn clean_maybe_renamed_item<'tcx>(
23212331 {
23222332 // First, we add the attributes from the current import.
23232333 extra_attrs. extend_from_slice ( inline:: load_attrs ( cx, import_id. to_def_id ( ) ) ) ;
2334+ let is_inline = extra_attrs. lists ( sym:: doc) . get_word_attr ( sym:: inline) . is_some ( ) ;
23242335 // Then we get all the various imports' attributes.
2325- get_all_import_attributes ( use_node, cx. tcx , item. owner_id . def_id , & mut extra_attrs) ;
2326- add_without_unwanted_attributes ( & mut extra_attrs, inline:: load_attrs ( cx, def_id) ) ;
2336+ get_all_import_attributes ( use_node, cx. tcx , item. owner_id . def_id , & mut extra_attrs, is_inline ) ;
2337+ add_without_unwanted_attributes ( & mut extra_attrs, inline:: load_attrs ( cx, def_id) , is_inline ) ;
23272338 } else {
23282339 // We only keep the item's attributes.
23292340 extra_attrs. extend_from_slice ( inline:: load_attrs ( cx, def_id) ) ;
0 commit comments