Skip to content

Commit

Permalink
Same mode name may import twice
Browse files Browse the repository at this point in the history
Change Vec to HashSet

Signed-off-by: jokemanfire <[email protected]>
  • Loading branch information
jokemanfire committed Jul 17, 2024
1 parent 0e6f3ff commit f110630
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions protobuf-codegen/src/gen/all.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::collections::{HashMap, HashSet};

use protobuf::descriptor::FileDescriptorProto;
use protobuf::reflect::FileDescriptor;
Expand Down Expand Up @@ -33,7 +33,7 @@ pub(crate) fn gen_all(
.map(|f| Ok((ProtoPath::new(f.proto().name())?, f)))
.collect::<Result<_, anyhow::Error>>()?;

let mut mods = Vec::new();
let mut mods = HashSet::new();

let customize = CustomizeElemCtx {
for_elem: customize.clone(),
Expand All @@ -49,15 +49,16 @@ pub(crate) fn gen_all(
));
let gen_file_result = gen_file(file, &files_map, &root_scope, &customize, parser)?;
results.push(gen_file_result.compiler_plugin_result);
mods.push(gen_file_result.mod_name);
mods.insert(gen_file_result.mod_name);
}

if customize.for_elem.inside_protobuf.unwrap_or(false) {
results.push(gen_well_known_types_mod());
}

if customize.for_elem.gen_mod_rs.unwrap_or(true) {
results.push(gen_mod_rs(&mods));
let r_vec: Vec<String> = mods.into_iter().collect();
results.push(gen_mod_rs(&r_vec));
}

Ok(results)
Expand Down

0 comments on commit f110630

Please sign in to comment.