Skip to content

Commit acf3242

Browse files
committed
---
yaml --- r: 14459 b: refs/heads/try c: 710258c h: refs/heads/master i: 14457: 4b977d0 14455: ed94dec v: v3
1 parent 87c128b commit acf3242

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: d44ca0923a5545113c96a8953f880090f334872c
5+
refs/heads/try: 710258cc76a72cb68732179bc10a81adc44c66a6
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rustdoc/doc.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
type ast_id = int;
44

5+
// FIXME: We currently give topmod the name of the crate. There would
6+
// probably be fewer special cases if the crate had its own name and
7+
// topmod's name was the empty string.
58
type cratedoc = {
69
topmod: moddoc,
710
};

branches/try/src/rustdoc/reexport_pass.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,16 @@ fn merge_reexports(
188188
fn fold_mod(fold: fold::fold<path_map>, doc: doc::moddoc) -> doc::moddoc {
189189
let doc = fold::default_seq_fold_mod(fold, doc);
190190

191-
let path = doc.path() + [doc.name()];
191+
let is_topmod = doc.id() == rustc::syntax::ast::crate_node_id;
192+
193+
// In the case of the top mod, it really doesn't have a name;
194+
// the name we have here is actually the crate name
195+
let path = if is_topmod {
196+
doc.path()
197+
} else {
198+
doc.path() + [doc.name()]
199+
};
200+
192201
let new_items = get_new_items(path, fold.ctxt);
193202
#debug("merging into %?: %?", path, new_items);
194203

@@ -309,6 +318,25 @@ fn should_rename_items_reexported_with_different_names() {
309318
assert doc.topmod.mods()[1].fns()[0].name() == "x";
310319
}
311320

321+
#[test]
322+
fn should_reexport_in_topmod() {
323+
fn mk_doc(source: str) -> doc::cratedoc {
324+
astsrv::from_str(source) {|srv|
325+
let doc = extract::from_srv(srv, "core");
326+
let doc = path_pass::mk_pass()(srv, doc);
327+
run(srv, doc)
328+
}
329+
}
330+
let source = "import option::{some, none}; \
331+
import option = option::t; \
332+
export option, some, none; \
333+
mod option { \
334+
enum t { some, none } \
335+
}";
336+
let doc = mk_doc(source);
337+
assert doc.topmod.enums()[0].name() == "option";
338+
}
339+
312340
#[cfg(test)]
313341
mod test {
314342
fn mk_doc(source: str) -> doc::cratedoc {

0 commit comments

Comments
 (0)