@@ -11,6 +11,7 @@ use itertools::Itertools;
11
11
use rustc_hash:: { FxHashMap , FxHashSet , FxHasher } ;
12
12
use triomphe:: Arc ;
13
13
14
+ use crate :: item_scope:: ImportOrExternCrate ;
14
15
use crate :: {
15
16
db:: DefDatabase , item_scope:: ItemInNs , nameres:: DefMap , visibility:: Visibility , AssocItemId ,
16
17
ModuleDefId , ModuleId , TraitId ,
@@ -29,6 +30,8 @@ pub struct ImportInfo {
29
30
pub container : ModuleId ,
30
31
/// Whether the import is a trait associated item or not.
31
32
pub is_trait_assoc_item : bool ,
33
+ /// Whether this item is annotated with `#[doc(hidden)]`.
34
+ pub is_doc_hidden : bool ,
32
35
}
33
36
34
37
/// A map from publicly exported items to its name.
@@ -113,14 +116,27 @@ fn collect_import_map(db: &dyn DefDatabase, krate: CrateId) -> FxIndexMap<ItemIn
113
116
} ) ;
114
117
115
118
for ( name, per_ns) in visible_items {
116
- for item in per_ns. iter_items ( ) {
119
+ for ( item, import ) in per_ns. iter_items ( ) {
117
120
// FIXME: Not yet used, but will be once we handle doc(hidden) import sources
118
- let is_doc_hidden = false ;
121
+ let attr_id = if let Some ( import) = import {
122
+ match import {
123
+ ImportOrExternCrate :: ExternCrate ( id) => Some ( id. into ( ) ) ,
124
+ ImportOrExternCrate :: Import ( id) => Some ( id. import . into ( ) ) ,
125
+ }
126
+ } else {
127
+ match item {
128
+ ItemInNs :: Types ( id) | ItemInNs :: Values ( id) => id. try_into ( ) . ok ( ) ,
129
+ ItemInNs :: Macros ( id) => Some ( id. into ( ) ) ,
130
+ }
131
+ } ;
132
+ let is_doc_hidden =
133
+ attr_id. map_or ( false , |attr_id| db. attrs ( attr_id) . has_doc_hidden ( ) ) ;
119
134
120
135
let import_info = ImportInfo {
121
136
name : name. clone ( ) ,
122
137
container : module,
123
138
is_trait_assoc_item : false ,
139
+ is_doc_hidden,
124
140
} ;
125
141
126
142
match depth_map. entry ( item) {
@@ -171,10 +187,10 @@ fn collect_trait_assoc_items(
171
187
trait_import_info : & ImportInfo ,
172
188
) {
173
189
let _p = profile:: span ( "collect_trait_assoc_items" ) ;
174
- for ( assoc_item_name, item) in & db. trait_data ( tr) . items {
190
+ for & ( ref assoc_item_name, item) in & db. trait_data ( tr) . items {
175
191
let module_def_id = match item {
176
- AssocItemId :: FunctionId ( f) => ModuleDefId :: from ( * f) ,
177
- AssocItemId :: ConstId ( c) => ModuleDefId :: from ( * c) ,
192
+ AssocItemId :: FunctionId ( f) => ModuleDefId :: from ( f) ,
193
+ AssocItemId :: ConstId ( c) => ModuleDefId :: from ( c) ,
178
194
// cannot use associated type aliases directly: need a `<Struct as Trait>::TypeAlias`
179
195
// qualifier, ergo no need to store it for imports in import_map
180
196
AssocItemId :: TypeAliasId ( _) => {
@@ -192,6 +208,7 @@ fn collect_trait_assoc_items(
192
208
container : trait_import_info. container ,
193
209
name : assoc_item_name. clone ( ) ,
194
210
is_trait_assoc_item : true ,
211
+ is_doc_hidden : db. attrs ( item. into ( ) ) . has_doc_hidden ( ) ,
195
212
} ;
196
213
map. insert ( assoc_item, assoc_item_info) ;
197
214
}
0 commit comments