-
Notifications
You must be signed in to change notification settings - Fork 33
Fix cache check #525
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
Fix cache check #525
Conversation
With these changes, I think that #513 should consistently fail. |
cfgrammar/src/lib/yacc/mod.rs
Outdated
@@ -47,7 +47,7 @@ impl quote::ToTokens for YaccKind { | |||
tokens.extend(match *self { | |||
YaccKind::Grmtools => quote!(::cfgrammar::yacc::YaccKind::Grmtools), | |||
YaccKind::Original(action_kind) => { | |||
quote!(::cfgrammar::yacc::YaccKind::Original(#action_kind)) | |||
quote!(::cfgrammar::yacc::YaccKind::Original(#action_kind,)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think perhaps it is best to attempt to do something less fragile here.
My thoughts are instead of emitting the cache module,
emit a constant string in the hopes that the pretty printer will ignore the string.
E.g. so go from // CACHE INFORMATION ...
to const CACHE_INFORMATION: &str = "..."
abandoning cache_module
unless we do want to keep it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by 8e32c81 and subsequent commits...
Might want to sqaush out the a08fbdb change? |
lrpar/src/lib/ctbuilder.rs
Outdated
@@ -865,7 +865,7 @@ where | |||
}) | |||
.collect::<Vec<_>>(); | |||
let rule_map_len = rule_map.len(); | |||
quote! { | |||
let cache_info = quote! { | |||
#[allow(unused)] | |||
mod _cache_information_ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may want to do something else here, as we no longer actually compile this code
as we change it it could perhaps start to contain syntax errors, etc.
We could emit both the cache_info module, and the module text within that constant string.
Or we could just emit a formatted string more like the original comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we just want to output the information in one place? Perhaps I've misunderstood!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I guess i'm saying:
this emits a strong:
const CACHE_INFO: &str = "#[allow(unused)] mod _cache_information_ {...
But because we never actually compile mod _cache_information_
anymore, it is just embedded in that string,
so it is both confusing, and we could make a change that would cause mod _cache_information_
to not actually compile but not notice.
I basically just did the minimal change to check that embedding it as a string works as a proof of concept.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed in a687505
Shouldn't we remove |
lrpar/src/lib/ctbuilder.rs
Outdated
// This declaration can be affected by the pretty printer. | ||
// But we would hope the actual cache string is not. | ||
#[allow(unused)] | ||
const CACHE_INFO: &str = #cache; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we can name this const _: &str = #cache
.
I thought this wasn't a valid constant declaration, but it looks like it is now.
Edit it was allowed in: RFC 2562
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also allows us to get rid of #[allow(unused)]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by 3b860ca
So, I think this is much less fragile now than trying to rely on the whitespace hack. |
Please squash. |
This ran into a known cargo footgun where if you emit rerun-if-changed you are responsible for emitting all the rerun-if-changed directives that otherwise would be implied by cargo.
The cache check only runs if the output grammar is newer.
3b860ca
to
5565880
Compare
Squashed. |
Sorry, I really need to figure out how to configure my editor so it can conditionally automatically run rustfmt or not depending upon which directory I'm editing. Because I have some projects that don't use it. Will need a squash |
Please squash. |
This should make the cache more robust to changes that are caused by the pretty printer.
24b77a2
to
93028a5
Compare
Squashed. |
I think this should run the cache check,
E.g. at least the following subset of
.buildbot.sh
now caught a bug where the pretty printerwas emitting a non-whitespace change, and we had to add a comma.