about summary refs log tree commit diff
diff options
context:
space:
mode:
authormitaa <mitaa.ceb@gmail.com>2016-04-24 14:11:26 +0200
committermitaa <mitaa.ceb@gmail.com>2016-04-24 20:32:21 +0200
commit6603c95414bd3adb10e6b3ba548f69952df8f290 (patch)
tree36b1587c3e51345c9ecfad3134e696f92a5f17b8
parentdca7f0162c862f0b592614da6d2215307da7e6c2 (diff)
downloadrust-6603c95414bd3adb10e6b3ba548f69952df8f290.tar.gz
rust-6603c95414bd3adb10e6b3ba548f69952df8f290.zip
Check reachability for inlined extern links too
An item is inlined and recorded as inlined even if it is
`doc(hidden)`, leading to unchecked external links.
-rw-r--r--src/librustdoc/html/format.rs8
-rw-r--r--src/test/auxiliary/rustdoc-hidden.rs14
-rw-r--r--src/test/rustdoc/inline_cross/inline_hidden.rs22
3 files changed, 41 insertions, 3 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index d4212bba590..26d82ccea5b 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -291,17 +291,19 @@ impl fmt::Display for clean::Path {
 
 pub fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> {
     let cache = cache();
+    if !did.is_local() && !cache.access_levels.is_doc_reachable(did) {
+        return None
+    }
+
     let loc = CURRENT_LOCATION_KEY.with(|l| l.borrow().clone());
     let &(ref fqp, shortty) = match cache.paths.get(&did) {
         Some(p) => p,
         None => return None,
     };
+
     let mut url = if did.is_local() || cache.inlined.contains(&did) {
         repeat("../").take(loc.len()).collect::<String>()
     } else {
-        if !cache.access_levels.is_doc_reachable(did) {
-            return None
-        }
         match cache.extern_locations[&did.krate] {
             (_, render::Remote(ref s)) => s.to_string(),
             (_, render::Local) => repeat("../").take(loc.len()).collect(),
diff --git a/src/test/auxiliary/rustdoc-hidden.rs b/src/test/auxiliary/rustdoc-hidden.rs
new file mode 100644
index 00000000000..aae3eb84fb5
--- /dev/null
+++ b/src/test/auxiliary/rustdoc-hidden.rs
@@ -0,0 +1,14 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[doc(hidden)]
+pub struct Foo;
+
+pub struct Bar;
diff --git a/src/test/rustdoc/inline_cross/inline_hidden.rs b/src/test/rustdoc/inline_cross/inline_hidden.rs
new file mode 100644
index 00000000000..c59b5afd1c4
--- /dev/null
+++ b/src/test/rustdoc/inline_cross/inline_hidden.rs
@@ -0,0 +1,22 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// aux-build:rustdoc-hidden.rs
+// build-aux-docs
+// ignore-cross-compile
+
+extern crate rustdoc_hidden;
+
+#[doc(no_inline)]
+pub use rustdoc_hidden::Foo;
+
+// @has inline_hidden/fn.foo.html
+// @!has - '//a/@title' 'Foo'
+pub fn foo(_: Foo) {}