rustc: Don't add duplicate entries to exp_map

This commit is contained in:
Brian Anderson 2012-02-23 21:06:12 -08:00
parent cb7022cfc2
commit 9982a2a841
2 changed files with 19 additions and 2 deletions

View File

@ -2021,7 +2021,13 @@ fn check_exports(e: @env) {
alt def {
some(def) {
alt e.exp_map.find(path) {
some(v) { *v += [def]; }
some(v) {
// If there are multiple reexports of the same def
// using the same path, then we only need one copy
if !vec::contains(*v, def) {
*v += [def];
}
}
none { e.exp_map.insert(path, @mutable [def]); }
}
}

View File

@ -144,7 +144,6 @@ fn build_reexport_path_map(srv: astsrv::srv, -def_map: def_map) -> path_map {
let name = option::get(vec::last(path));
let reexportdocs = [];
for def in *defs {
let def_id = ast_util::def_id_of_def(def);
alt def_map.find(def_id) {
@ -337,6 +336,18 @@ fn should_reexport_in_topmod() {
assert doc.topmod.enums()[0].name() == "option";
}
#[test]
fn should_not_reexport_multiple_times() {
let source = "import option = option::t; \
export option; \
export option; \
mod option { \
enum t { none, some } \
}";
let doc = test::mk_doc(source);
assert vec::len(doc.topmod.enums()) == 1u;
}
#[cfg(test)]
mod test {
fn mk_doc(source: str) -> doc::cratedoc {