From dca7f0162c862f0b592614da6d2215307da7e6c2 Mon Sep 17 00:00:00 2001 From: mitaa Date: Wed, 20 Apr 2016 17:30:26 +0200 Subject: Remove, now unnecessary, workaround This used to be done to avoid inlining impls referencing private items, but is now unnecessary since we actually check that impls do not reference non-doc-reachable items. --- src/test/auxiliary/issue-33113.rs | 17 +++++++++++++++++ src/test/auxiliary/rustdoc-trait-object-impl.rs | 24 ++++++++++++++++++++++++ src/test/rustdoc/inline_cross/issue-32881.rs | 22 ++++++++++++++++++++++ src/test/rustdoc/inline_cross/issue-33113.rs | 20 ++++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 src/test/auxiliary/issue-33113.rs create mode 100644 src/test/auxiliary/rustdoc-trait-object-impl.rs create mode 100644 src/test/rustdoc/inline_cross/issue-32881.rs create mode 100644 src/test/rustdoc/inline_cross/issue-33113.rs (limited to 'src/test') diff --git a/src/test/auxiliary/issue-33113.rs b/src/test/auxiliary/issue-33113.rs new file mode 100644 index 00000000000..c476dda2690 --- /dev/null +++ b/src/test/auxiliary/issue-33113.rs @@ -0,0 +1,17 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_name="bar"] + +pub trait Bar {} +pub struct Foo; + +impl<'a> Bar for &'a char {} +impl Bar for Foo {} diff --git a/src/test/auxiliary/rustdoc-trait-object-impl.rs b/src/test/auxiliary/rustdoc-trait-object-impl.rs new file mode 100644 index 00000000000..317262f4175 --- /dev/null +++ b/src/test/auxiliary/rustdoc-trait-object-impl.rs @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::fmt; + +pub trait Bar {} + +impl<'a> Bar + 'a { + pub fn bar(&self) -> usize { 42 } +} + +impl<'a> fmt::Debug for Bar + 'a { + fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result { + Ok(()) + } +} + diff --git a/src/test/rustdoc/inline_cross/issue-32881.rs b/src/test/rustdoc/inline_cross/issue-32881.rs new file mode 100644 index 00000000000..948061bdcbe --- /dev/null +++ b/src/test/rustdoc/inline_cross/issue-32881.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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:rustdoc-trait-object-impl.rs +// build-aux-docs +// ignore-cross-compile + +extern crate rustdoc_trait_object_impl; + +// @has issue_32881/trait.Bar.html +// @has - '//code' "impl<'a> Bar" +// @has - '//code' "impl<'a> Debug for Bar" + +pub use rustdoc_trait_object_impl::Bar; + diff --git a/src/test/rustdoc/inline_cross/issue-33113.rs b/src/test/rustdoc/inline_cross/issue-33113.rs new file mode 100644 index 00000000000..9ae8fefe730 --- /dev/null +++ b/src/test/rustdoc/inline_cross/issue-33113.rs @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-33113.rs +// build-aux-docs +// ignore-cross-compile + +extern crate bar; + +// @has issue_33113/trait.Bar.html +// @has - '//code' "for &'a char" +// @has - '//code' "for Foo" +pub use bar::Bar; -- cgit 1.4.1-3-g733a5 From 6603c95414bd3adb10e6b3ba548f69952df8f290 Mon Sep 17 00:00:00 2001 From: mitaa Date: Sun, 24 Apr 2016 14:11:26 +0200 Subject: 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. --- src/librustdoc/html/format.rs | 8 +++++--- src/test/auxiliary/rustdoc-hidden.rs | 14 ++++++++++++++ src/test/rustdoc/inline_cross/inline_hidden.rs | 22 ++++++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 src/test/auxiliary/rustdoc-hidden.rs create mode 100644 src/test/rustdoc/inline_cross/inline_hidden.rs (limited to 'src/test') 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)> { 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::() } 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 or the MIT license +// , 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 or the MIT license +// , 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) {} -- cgit 1.4.1-3-g733a5