@@ -188,7 +188,16 @@ fn merge_reexports(
188
188
fn fold_mod ( fold : fold:: fold < path_map > , doc : doc:: moddoc ) -> doc:: moddoc {
189
189
let doc = fold:: default_seq_fold_mod ( fold, doc) ;
190
190
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
+
192
201
let new_items = get_new_items ( path, fold. ctxt ) ;
193
202
#debug ( "merging into %?: %?" , path, new_items) ;
194
203
@@ -309,6 +318,25 @@ fn should_rename_items_reexported_with_different_names() {
309
318
assert doc. topmod . mods ( ) [ 1 ] . fns ( ) [ 0 ] . name ( ) == "x" ;
310
319
}
311
320
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
+
312
340
#[ cfg( test) ]
313
341
mod test {
314
342
fn mk_doc ( source : str ) -> doc:: cratedoc {
0 commit comments