Skip to content

Commit 714d0a2

Browse files
committed
transpile: factor out cloning of module path
1 parent e74cd3a commit 714d0a2

File tree

1 file changed

+3
-4
lines changed
  • c2rust-transpile/src/translator

1 file changed

+3
-4
lines changed

c2rust-transpile/src/translator/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,31 +1011,30 @@ fn make_submodule(
10111011
.get_file_include_line_number(file_id)
10121012
.unwrap_or(0);
10131013
let mod_name = clean_path(mod_names, file_path);
1014+
let use_path = || vec!["self".into(), mod_name.clone()];
10141015

10151016
for item in items.iter() {
10161017
let ident_name = match item_ident(item) {
10171018
Some(i) => i.to_string(),
10181019
None => continue,
10191020
};
1020-
let use_path = vec!["self".into(), mod_name.clone()];
10211021

10221022
let vis = match item_vis(item) {
10231023
Some(Visibility::Public(_)) => mk().pub_(),
10241024
Some(_) => mk(),
10251025
None => continue,
10261026
};
10271027

1028-
use_item_store.add_use_with_attr(false, use_path, &ident_name, vis);
1028+
use_item_store.add_use_with_attr(false, use_path(), &ident_name, vis);
10291029
}
10301030

10311031
for foreign_item in foreign_items.iter() {
10321032
let ident_name = match foreign_item_ident_vis(foreign_item) {
10331033
Some((ident, _vis)) => ident.to_string(),
10341034
None => continue,
10351035
};
1036-
let use_path = vec!["self".into(), mod_name.clone()];
10371036

1038-
use_item_store.add_use(false, use_path, &ident_name);
1037+
use_item_store.add_use(false, use_path(), &ident_name);
10391038
}
10401039

10411040
for item in uses.into_items() {

0 commit comments

Comments
 (0)