@@ -2100,14 +2100,15 @@ fn get_all_import_attributes<'hir>(
2100
2100
tcx : TyCtxt < ' hir > ,
2101
2101
target_def_id : LocalDefId ,
2102
2102
attributes : & mut Vec < ast:: Attribute > ,
2103
+ is_inline : bool ,
2103
2104
) {
2104
2105
let hir_map = tcx. hir ( ) ;
2105
2106
let mut visitor = OneLevelVisitor :: new ( hir_map, target_def_id) ;
2106
2107
let mut visited = FxHashSet :: default ( ) ;
2107
2108
// If the item is an import and has at least a path with two parts, we go into it.
2108
2109
while let hir:: ItemKind :: Use ( path, _) = item. kind && visited. insert ( item. hir_id ( ) ) {
2109
2110
// 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 ) ;
2111
2112
2112
2113
let def_id = if path. segments . len ( ) > 1 {
2113
2114
match path. segments [ path. segments . len ( ) - 2 ] . res {
@@ -2189,7 +2190,16 @@ fn filter_tokens_from_list(
2189
2190
/// * `doc(inline)`
2190
2191
/// * `doc(no_inline)`
2191
2192
/// * `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
+ }
2193
2203
for attr in new_attrs {
2194
2204
let mut attr = attr. clone ( ) ;
2195
2205
match attr. kind {
@@ -2321,9 +2331,10 @@ fn clean_maybe_renamed_item<'tcx>(
2321
2331
{
2322
2332
// First, we add the attributes from the current import.
2323
2333
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 ( ) ;
2324
2335
// 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 ) ;
2327
2338
} else {
2328
2339
// We only keep the item's attributes.
2329
2340
extra_attrs. extend_from_slice ( inline:: load_attrs ( cx, def_id) ) ;
0 commit comments