Skip to content

Commit d37f350

Browse files
ollie27pietroalbini
authored andcommitted
rustdoc: Hide struct and enum variant constructor imports
1 parent 0d6f41b commit d37f350

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

src/librustdoc/visit_ast.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,6 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
365365
});
366366
true
367367
}
368-
hir_map::NodeStructCtor(_) if !glob => {
369-
// struct constructors always show up alongside their struct definitions, we've
370-
// already processed that so just discard this
371-
true
372-
}
373368
_ => false,
374369
};
375370
self.view_item_stack.remove(&def_node_id);
@@ -417,6 +412,13 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
417412
hir::ItemUse(ref path, kind) => {
418413
let is_glob = kind == hir::UseKind::Glob;
419414

415+
// struct and variant constructors always show up alongside their definitions, we've
416+
// already processed them so just discard these.
417+
match path.def {
418+
Def::StructCtor(..) | Def::VariantCtor(..) => return,
419+
_ => {}
420+
}
421+
420422
// If there was a private module in the current path then don't bother inlining
421423
// anything as it will probably be stripped anyway.
422424
if item.vis == hir::Public && self.inside_public_path {
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2018 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+
#![crate_name = "foo"]
12+
13+
pub mod a {
14+
pub struct Foo;
15+
pub enum Bar {
16+
Baz,
17+
}
18+
}
19+
20+
// @count 'foo/index.html' '//*[code="pub use a::Foo;"]' 1
21+
#[doc(no_inline)]
22+
pub use a::Foo;
23+
// @count 'foo/index.html' '//*[code="pub use a::Bar::Baz;"]' 1
24+
#[doc(no_inline)]
25+
pub use a::Bar::Baz;

0 commit comments

Comments
 (0)