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.
This commit is contained in:
parent
dca7f0162c
commit
6603c95414
3 changed files with 41 additions and 3 deletions
|
@ -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(),
|
||||
|
|
14
src/test/auxiliary/rustdoc-hidden.rs
Normal file
14
src/test/auxiliary/rustdoc-hidden.rs
Normal file
|
@ -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;
|
22
src/test/rustdoc/inline_cross/inline_hidden.rs
Normal file
22
src/test/rustdoc/inline_cross/inline_hidden.rs
Normal file
|
@ -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) {}
|
Loading…
Add table
Add a link
Reference in a new issue