Skip to content

Commit 16d290d

Browse files
committed
rustdoc: Reexport native functions
1 parent 396540f commit 16d290d

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/rustdoc/reexport_pass.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ fn build_reexport_def_map(
104104

105105
// FIXME: Do a parallel fold
106106
let fold = fold::fold({
107-
fold_mod: fold_mod
107+
fold_mod: fold_mod,
108+
fold_nmod: fold_nmod
108109
with *fold::default_seq_fold(ctxt)
109110
});
110111

@@ -124,6 +125,19 @@ fn build_reexport_def_map(
124125

125126
ret doc;
126127
}
128+
129+
fn fold_nmod(fold: fold::fold<ctxt>, doc: doc::nmoddoc) -> doc::nmoddoc {
130+
let doc = fold::default_seq_fold_nmod(fold, doc);
131+
132+
for fndoc in doc.fns {
133+
let def_id = ast_util::local_def(fndoc.id());
134+
if fold.ctxt.def_set.contains_key(def_id) {
135+
fold.ctxt.def_map.insert(def_id, doc::fntag(fndoc));
136+
}
137+
}
138+
139+
ret doc;
140+
}
127141
}
128142

129143
fn build_reexport_path_map(srv: astsrv::srv, -def_map: def_map) -> path_map {
@@ -298,6 +312,14 @@ fn should_mark_reepxorts_as_such() {
298312
assert doc.topmod.mods()[1].fns()[0].item.reexport == true;
299313
}
300314

315+
#[test]
316+
fn should_duplicate_reexported_native_fns() {
317+
let source = "native mod a { fn b(); } \
318+
mod c { import a::b; export b; }";
319+
let doc = test::mk_doc(source);
320+
assert doc.topmod.mods()[0].fns()[0].name() == "b";
321+
}
322+
301323
#[test]
302324
fn should_duplicate_multiple_reexported_items() {
303325
let source = "mod a { \

0 commit comments

Comments
 (0)