Skip to content

Commit

Permalink
Support modules with raw identifiers
Browse files Browse the repository at this point in the history
Example: In the presence a module named `r#match` the visitor would look
for a file named `r#match.rs`, instead of the actual `match.rs`. We now
    remove the `r#` prefix to find the correct file.
  • Loading branch information
henrikhorluck authored and ogoffart committed Jul 20, 2023
1 parent 2ee136e commit 30554cb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion xtr/src/crate_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use std::mem::swap;
use std::path::{Path, PathBuf};
use syn;
use syn::visit::Visit;
use syn::ext::IdentExt;

/**
* Parse a crate to visit every module. The `visitor` function will be called for every file
Expand Down Expand Up @@ -116,7 +117,7 @@ where
}
}

let mod_name = item.ident.to_string();
let mod_name = item.ident.unraw().to_string();
let mut subdir = self.mod_dir.join(mod_name.clone());
subdir.push("mod.rs");
if subdir.is_file() {
Expand Down

0 comments on commit 30554cb

Please sign in to comment.