From 042f1df198c6be96f08afe8b2e938ddfbeba0330 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Fri, 15 Jun 2018 18:16:43 -0500 Subject: [PATCH] process cross-crate glob re-exports --- src/librustdoc/clean/inline.rs | 17 +++++++++++++++ src/librustdoc/clean/mod.rs | 7 +++++++ .../inline_cross/auxiliary/cross-glob.rs | 15 +++++++++++++ src/test/rustdoc/inline_cross/cross-glob.rs | 21 +++++++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 src/test/rustdoc/inline_cross/auxiliary/cross-glob.rs create mode 100644 src/test/rustdoc/inline_cross/cross-glob.rs diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index f112f3ca2ae..80eb2d1e214 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -116,6 +116,23 @@ pub fn try_inline(cx: &DocContext, def: Def, name: ast::Name, visited: &mut FxHa Some(ret) } +pub fn try_inline_glob(cx: &DocContext, def: Def, visited: &mut FxHashSet) + -> Option> +{ + if def == Def::Err { return None } + let did = def.def_id(); + if did.is_local() { return None } + + match def { + Def::Mod(did) => { + let m = build_module(cx, did, visited); + Some(m.items) + } + // glob imports on things like enums aren't inlined even for local exports, so just bail + _ => None, + } +} + pub fn load_attrs(cx: &DocContext, did: DefId) -> clean::Attributes { cx.tcx.get_attrs(did).clean(cx) } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 54647b45159..15c2e7b72f6 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -3862,6 +3862,13 @@ fn clean(&self, cx: &DocContext) -> Vec { }); let path = self.path.clean(cx); let inner = if self.glob { + if !denied { + let mut visited = FxHashSet(); + if let Some(items) = inline::try_inline_glob(cx, path.def, &mut visited) { + return items; + } + } + Import::Glob(resolve_use_source(cx, path)) } else { let name = self.name; diff --git a/src/test/rustdoc/inline_cross/auxiliary/cross-glob.rs b/src/test/rustdoc/inline_cross/auxiliary/cross-glob.rs new file mode 100644 index 00000000000..5067ce9e9a3 --- /dev/null +++ b/src/test/rustdoc/inline_cross/auxiliary/cross-glob.rs @@ -0,0 +1,15 @@ +// 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 = "inner"] + +pub struct SomeStruct; + +pub fn some_fn() {} diff --git a/src/test/rustdoc/inline_cross/cross-glob.rs b/src/test/rustdoc/inline_cross/cross-glob.rs new file mode 100644 index 00000000000..21cf158c13b --- /dev/null +++ b/src/test/rustdoc/inline_cross/cross-glob.rs @@ -0,0 +1,21 @@ +// 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:cross-glob.rs +// build-aux-docs +// ignore-cross-compile + +extern crate inner; + +// @has cross_glob/struct.SomeStruct.html +// @has cross_glob/fn.some_fn.html +// @!has cross_glob/index.html '//code' 'pub use inner::*;' +#[doc(inline)] +pub use inner::*; -- 2.44.0