Skip to content

Commit b2bbb5a

Browse files
committed
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 #51252
2 parents 2532056 + 042f1df commit b2bbb5a

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

src/librustdoc/clean/inline.rs

+17
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,23 @@ pub fn try_inline(cx: &DocContext, def: Def, name: ast::Name, visited: &mut FxHa
116116
Some(ret)
117117
}
118118

119+
pub fn try_inline_glob(cx: &DocContext, def: Def, visited: &mut FxHashSet<DefId>)
120+
-> Option<Vec<clean::Item>>
121+
{
122+
if def == Def::Err { return None }
123+
let did = def.def_id();
124+
if did.is_local() { return None }
125+
126+
match def {
127+
Def::Mod(did) => {
128+
let m = build_module(cx, did, visited);
129+
Some(m.items)
130+
}
131+
// glob imports on things like enums aren't inlined even for local exports, so just bail
132+
_ => None,
133+
}
134+
}
135+
119136
pub fn load_attrs(cx: &DocContext, did: DefId) -> clean::Attributes {
120137
cx.tcx.get_attrs(did).clean(cx)
121138
}

src/librustdoc/clean/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -3862,6 +3862,13 @@ impl Clean<Vec<Item>> for doctree::Import {
38623862
});
38633863
let path = self.path.clean(cx);
38643864
let inner = if self.glob {
3865+
if !denied {
3866+
let mut visited = FxHashSet();
3867+
if let Some(items) = inline::try_inline_glob(cx, path.def, &mut visited) {
3868+
return items;
3869+
}
3870+
}
3871+
38653872
Import::Glob(resolve_use_source(cx, path))
38663873
} else {
38673874
let name = self.name;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
#![crate_name = "inner"]
12+
13+
pub struct SomeStruct;
14+
15+
pub fn some_fn() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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:cross-glob.rs
12+
// build-aux-docs
13+
// ignore-cross-compile
14+
15+
extern crate inner;
16+
17+
// @has cross_glob/struct.SomeStruct.html
18+
// @has cross_glob/fn.some_fn.html
19+
// @!has cross_glob/index.html '//code' 'pub use inner::*;'
20+
#[doc(inline)]
21+
pub use inner::*;

0 commit comments

Comments
 (0)