Auto merge of #51584 - QuietMisdreavus:globs-and-crosses, r=ollie27
rustdoc: process cross-crate glob re-exports Turns out, we were deliberately ignoring glob re-exports when they were occurring across crates, even though we were fully processing them for local re-exports. This will at least bring the two into parity. Fixes https://github.com/rust-lang/rust/issues/51252
This commit is contained in:
commit
b2bbb5a9b7
@ -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<DefId>)
|
||||
-> Option<Vec<clean::Item>>
|
||||
{
|
||||
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)
|
||||
}
|
||||
|
@ -3862,6 +3862,13 @@ impl Clean<Vec<Item>> for doctree::Import {
|
||||
});
|
||||
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;
|
||||
|
15
src/test/rustdoc/inline_cross/auxiliary/cross-glob.rs
Normal file
15
src/test/rustdoc/inline_cross/auxiliary/cross-glob.rs
Normal file
@ -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 <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.
|
||||
|
||||
#![crate_name = "inner"]
|
||||
|
||||
pub struct SomeStruct;
|
||||
|
||||
pub fn some_fn() {}
|
21
src/test/rustdoc/inline_cross/cross-glob.rs
Normal file
21
src/test/rustdoc/inline_cross/cross-glob.rs
Normal file
@ -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 <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: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::*;
|
Loading…
Reference in New Issue
Block a user