-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
possible regression around paths and macro-generated modules #38190
Comments
Oh yeah, and the error:
|
This was unintentionally introduced in #37569. Investigating further, it appears that non-inline modules parsed into I think the best way forward is to fix this regression and the pre-existing bug at once and backport to beta (I'll submit a PR by tomorrow). Fixing the pre-existing bug technically a breaking change, but I believe it won't break anything not already broken by #37569, and I haven't seen any breakage from #37602 in the weekly regression reports. |
Well this did break my code, I was using a non-stripped-down version of |
Another weird part of the regression has to do with |
@durka
Right, that's the regression that #37569 introduced. We've never set the When I lifted parser construction out of a loop, the initial token changed so that its span became Even when the first token's span has a file, its directory isn't always the correct choice since it doesn't take into account inline modules in the file (this is the preexisting bug). |
My invocations of |
What I'm not clear about is if |
We load the module's file when we parse |
Ideally, we would load the file for a non-inline module more lazily, so that we knew exactly where will end up in the module hierarchy before we look for the file. We might be able to implement this today with negligible breakage. |
Well ideally the directory would be hygienic, so that
|
cc @nrc |
Oh man, so the interpretation of a mod statement in a macro input depends on the macro pattern, e.g. macro_rules! m { ($i:item) => { mod x { $i } } }
m! { mod y; } // error: no file y.rs or y/mod.rs macro_rules! as_item { ($i:item) => { $i } }
macro_rules! m { ($($t:tt)*) => { as_item!(mod x { $($t)* }); } }
m! { mod y; } // error: no file x/y.rs or x/y/mod.rs Fun! I guess this likely can't be changed due to backcompat. |
I think changing to #38190 (comment) wouldn't cause breakage in practice. If it does, we'll have to wait for macros 2.0. |
Fixed in #38205. |
#38205 fixes my project. |
I have some code that builds on stable and does not build on beta. I am not sure whether it is exploiting a compiler bug or not, but the changes seem related to #37602 (cc @jseyfried).
Here is the code: https://github.com/durka/mod-dir-regr
Note that if you
pretty=expanded
the code on stable, then use the beta compiler to compile it, it does work. So there is something going on with the macro.The text was updated successfully, but these errors were encountered: