Skip to content

Commit 34658b1

Browse files
committed
tools/rust_util: do not include r# prefix in fs paths
1 parent 9d65be7 commit 34658b1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tools/rust_util/src/collect.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::fs;
33
use std::iter;
44
use std::path::{Path, PathBuf};
55
use syn;
6+
use syn::ext::IdentExt;
67
use crate::error::Error;
78

89

@@ -56,10 +57,10 @@ impl FileCollector {
5657
syn::Item::Mod(ref im) => im,
5758
_ => continue,
5859
};
59-
mod_path.push(im.ident.to_string());
60+
mod_path.push(im.ident.unraw().to_string());
6061
if let Some((_, ref inline_items)) = im.content {
6162
let name = path_attr_value(&im.attrs)?
62-
.unwrap_or_else(|| im.ident.to_string());
63+
.unwrap_or_else(|| im.ident.unraw().to_string());
6364
let module = parent_module.iter().copied().chain(iter::once(&name as &_))
6465
.collect::<Vec<_>>();
6566
self.walk_items(inline_items, base_path, mod_path.clone(), &module)?;
@@ -72,7 +73,7 @@ impl FileCollector {
7273
path.push(attr_path);
7374
self.parse(path, mod_path.clone(), false)?;
7475
} else {
75-
let name = im.ident.to_string();
76+
let name = im.ident.unraw().to_string();
7677
// Try `foo/mod.rs` first; if it doesn't exist, try `foo.rs` instead.
7778
path.push(name);
7879
path.push("mod.rs");

0 commit comments

Comments
 (0)