File tree 1 file changed +25
-0
lines changed 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -1216,6 +1216,29 @@ impl LinkCollector<'_, '_> {
1216
1216
. emit ( ) ;
1217
1217
}
1218
1218
1219
+ fn filter_private_hidden_candidates (
1220
+ & self ,
1221
+ candidates : & mut Vec < ( Res , Option < DefId > ) > ,
1222
+ module_def_id : DefId ,
1223
+ ) {
1224
+ candidates. retain ( |( candidate, _) | {
1225
+ let Res :: Def ( _, def_id) = candidate else { return true } ;
1226
+
1227
+ if !self . cx . render_options . document_private
1228
+ && let visibility = self . cx . tcx . visibility ( def_id)
1229
+ && !visibility. is_public ( )
1230
+ && !self . cx . tcx . has_attr ( * def_id, sym:: rustc_doc_primitive)
1231
+ && !visibility. is_accessible_from ( module_def_id, self . cx . tcx )
1232
+ {
1233
+ false
1234
+ } else if !self . cx . render_options . document_hidden && self . cx . tcx . is_doc_hidden ( def_id) {
1235
+ false
1236
+ } else {
1237
+ true
1238
+ }
1239
+ } ) ;
1240
+ }
1241
+
1219
1242
fn resolve_with_disambiguator_cached (
1220
1243
& mut self ,
1221
1244
key : ResolutionInfo ,
@@ -1250,6 +1273,8 @@ impl LinkCollector<'_, '_> {
1250
1273
}
1251
1274
}
1252
1275
1276
+ self . filter_private_hidden_candidates ( & mut candidates, key. module_id ) ;
1277
+
1253
1278
// If there are multiple items with the same "kind" (for example, both "associated types")
1254
1279
// and after removing duplicated kinds, only one remains, the `ambiguity_error` function
1255
1280
// won't emit an error. So at this point, we can just take the first candidate as it was
You can’t perform that action at this time.
0 commit comments