Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility behavior of changing the out_dir is incredibly confusing #699

Open
not-my-profile opened this issue Jan 11, 2023 · 2 comments
Milestone

Comments

@not-my-profile
Copy link

I was just getting incredibly confused why lalrpop::Configuration().set_out_dir("out").process_current_dir() wrote the .rs file to the current directory instead of the out/ directory. I looked through the documentation and couldn't find any answer, I looked through the api/mod.rs source code and couldn't find any answer. Only when digging deeper into the source code I found the following:

// If the lalrpop file is not in in_dir, the result is that the
// .rs file is created in the same directory as the lalrpop file
// for compatibility reasons
Ok(out_dir
.join(lalrpop_file.strip_prefix(&in_dir).unwrap_or(lalrpop_file))
.with_extension(ext))

And process_current_dir apparently sets the in_dir to ./src triggering this "compatibility" behavior.

This is so incredibly unintuitive that I think that behavior should either be removed or the Configuration API be deprecated in favor of something more sane.

@youknowone
Copy link
Contributor

@nikomatsakis do you have any idea about this issue?

@nikomatsakis
Copy link
Collaborator

I don't remember much of the details here but I definitely think we should clean this up for 1.0. I was trying it out on a recent project and I also hit some issues with a .lalrpop file that was not in the root directory, I think the problem was more that I didn't know what to specify as the path in the lalrpop_mod macro, though.

@nikomatsakis nikomatsakis added this to the 1.0 milestone Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants