@@ -204,7 +204,10 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
204
204
return Ok ( ( res, Some ( path_str. to_owned ( ) ) ) ) ;
205
205
}
206
206
other => {
207
- debug ! ( "failed to resolve {} in namespace {:?} (got {:?})" , path_str, ns, other) ;
207
+ debug ! (
208
+ "failed to resolve {} in namespace {:?} (got {:?})" ,
209
+ path_str, ns, other
210
+ ) ;
208
211
debug ! ( "extra_fragment is {:?}" , extra_fragment) ;
209
212
return Ok ( ( res, extra_fragment. clone ( ) ) ) ;
210
213
}
@@ -564,10 +567,9 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
564
567
let mut path_str;
565
568
let ( res, fragment) = {
566
569
let mut kind = None ;
567
- path_str = if let Some ( prefix) =
568
- [ "struct@" , "enum@" , "type@" , "trait@" , "union@" ]
569
- . iter ( )
570
- . find ( |p| link. starts_with ( * * p) )
570
+ path_str = if let Some ( prefix) = [ "struct@" , "enum@" , "type@" , "trait@" , "union@" ]
571
+ . iter ( )
572
+ . find ( |p| link. starts_with ( * * p) )
571
573
{
572
574
kind = Some ( TypeNS ) ;
573
575
link. trim_start_matches ( prefix)
@@ -766,22 +768,30 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
766
768
if let Res :: PrimTy ( _) = res {
767
769
item. attrs . links . push ( ( ori_link, None , fragment) ) ;
768
770
} else {
769
- // ~~WRONG: TODO: I think this happens too late and we need to instead put this in `self.resolve`~~
770
- debug ! ( "item {:?} resolved to {:?}" , item, res) ;
771
+ debug ! ( "linked item {} resolved to {:?}" , path_str, res) ;
771
772
if let Some ( local) = res. opt_def_id ( ) . and_then ( |def_id| def_id. as_local ( ) ) {
773
+ use rustc_hir:: def_id:: LOCAL_CRATE ;
774
+
772
775
let hir_id = self . cx . tcx . hir ( ) . as_local_hir_id ( local) ;
773
- if !self . cx . tcx . privacy_access_levels ( rustc_hir:: def_id:: LOCAL_CRATE ) . is_exported ( hir_id) {
776
+ if !self . cx . tcx . privacy_access_levels ( LOCAL_CRATE ) . is_exported ( hir_id)
777
+ && !self . cx . render_options . document_private
778
+ {
774
779
let item_name = item. name . as_deref ( ) . unwrap_or ( "<unknown>" ) ;
780
+ let err_msg = format ! (
781
+ "public documentation for `{}` links to a private item" ,
782
+ item_name
783
+ ) ;
775
784
build_diagnostic (
776
785
cx,
777
786
& item,
778
787
path_str,
779
788
& dox,
780
789
link_range,
781
- & format ! ( "public documentation for `{}` links to a private item" , item_name ) ,
790
+ & err_msg ,
782
791
"this item is private" ,
783
792
None ,
784
793
) ;
794
+ continue ;
785
795
}
786
796
}
787
797
let id = register_res ( cx, res) ;
0 commit comments