Skip to content

Commit

Permalink
pdl-derive: Remove src/ from the list of searched paths
Browse files Browse the repository at this point in the history
Source pdl files are expected as relative paths from
the cargo manifest dir
  • Loading branch information
hchataing committed Sep 1, 2023
1 parent 9ca8018 commit e541846
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pdl-derive/src/lib.rs
Expand Up @@ -22,13 +22,10 @@ use syn::parse_macro_input;
fn pdl_proc_macro(path: syn::LitStr, input: syn::ItemMod) -> TokenStream {
// Locate the source grammar file.
let root = env::var("CARGO_MANIFEST_DIR").unwrap_or_else(|_| ".".into());
let Some(relative_path) =
[Path::new(&root).join(path.value()), Path::new(&root).join("src").join(path.value())]
.into_iter()
.find(|path| path.exists())
else {
let relative_path = Path::new(&root).join(path.value());
if !relative_path.exists() {
return syn::Error::new(path.span(), "error: unable to find file").to_compile_error();
};
}

// Load and parse the grammar.
let mut sources = pdl_compiler::ast::SourceDatabase::new();
Expand Down

0 comments on commit e541846

Please sign in to comment.