Skip to content

Commit eae9f46

Browse files
committed
Don't inline impls from doc(hidden) modules
1 parent c9852e2 commit eae9f46

File tree

3 files changed

+52
-11
lines changed

3 files changed

+52
-11
lines changed

src/librustdoc/clean/inline.rs

+16-11
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,11 @@ pub fn build_impls(cx: &DocContext, tcx: &ty::ctxt,
260260
match def {
261261
cstore::DlImpl(did) => build_impl(cx, tcx, did, impls),
262262
cstore::DlDef(Def::Mod(did)) => {
263+
// Don't recurse if this is a #[doc(hidden)] module
264+
if load_attrs(cx, tcx, did).iter().any(|a| is_doc_hidden(a)) {
265+
return;
266+
}
267+
263268
for item in tcx.sess.cstore.item_children(did) {
264269
populate_impls(cx, tcx, item.def, impls)
265270
}
@@ -423,19 +428,19 @@ pub fn build_impl(cx: &DocContext,
423428
deprecation: stability::lookup_deprecation(tcx, did).clean(cx),
424429
def_id: did,
425430
});
431+
}
426432

427-
fn is_doc_hidden(a: &clean::Attribute) -> bool {
428-
match *a {
429-
clean::List(ref name, ref inner) if *name == "doc" => {
430-
inner.iter().any(|a| {
431-
match *a {
432-
clean::Word(ref s) => *s == "hidden",
433-
_ => false,
434-
}
435-
})
436-
}
437-
_ => false
433+
fn is_doc_hidden(a: &clean::Attribute) -> bool {
434+
match *a {
435+
clean::List(ref name, ref inner) if *name == "doc" => {
436+
inner.iter().any(|a| {
437+
match *a {
438+
clean::Word(ref s) => *s == "hidden",
439+
_ => false,
440+
}
441+
})
438442
}
443+
_ => false
439444
}
440445
}
441446

src/test/auxiliary/issue-29584.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub struct Foo;
12+
13+
#[doc(hidden)]
14+
mod bar {
15+
trait Bar {}
16+
17+
impl Bar for ::Foo {}
18+
}

src/test/rustdoc/issue-29584.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:issue-29584.rs
12+
// ignore-cross-compile
13+
14+
extern crate issue_29584;
15+
16+
// @has issue_29584/struct.Foo.html
17+
// @!has - 'impl Bar for'
18+
pub use issue_29584::Foo;

0 commit comments

Comments
 (0)