Skip to content

Commit 354ee75

Browse files
committed
Same mode name may import twice
Change Vec to HashSet Signed-off-by: jokemanfire <[email protected]>
1 parent 0e6f3ff commit 354ee75

File tree

1 file changed

+5
-4
lines changed
  • protobuf-codegen/src/gen

1 file changed

+5
-4
lines changed

protobuf-codegen/src/gen/all.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::collections::HashMap;
1+
use std::collections::{HashMap,HashSet};
22

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

36-
let mut mods = Vec::new();
36+
let mut mods = HashSet::new();
3737

3838
let customize = CustomizeElemCtx {
3939
for_elem: customize.clone(),
@@ -49,15 +49,16 @@ pub(crate) fn gen_all(
4949
));
5050
let gen_file_result = gen_file(file, &files_map, &root_scope, &customize, parser)?;
5151
results.push(gen_file_result.compiler_plugin_result);
52-
mods.push(gen_file_result.mod_name);
52+
mods.insert(gen_file_result.mod_name);
5353
}
5454

5555
if customize.for_elem.inside_protobuf.unwrap_or(false) {
5656
results.push(gen_well_known_types_mod());
5757
}
5858

5959
if customize.for_elem.gen_mod_rs.unwrap_or(true) {
60-
results.push(gen_mod_rs(&mods));
60+
let r_vec:Vec<String> = mods.into_iter().collect();
61+
results.push(gen_mod_rs(&r_vec));
6162
}
6263

6364
Ok(results)

0 commit comments

Comments
 (0)