-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Rewrite style.rs
using syn
#4220
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @tgross35 (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
Huge thanks for working on this!! I’ll take a look in a couple of days :) |
d54c31a
to
55476a0
Compare
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.
Sorry that took a little longer than expected. Overall this looks great, most of the comments I left relate to things we can probably upgrade now since the original is from 2016.
One meta thing - maybe it's better to put this into a new module of libc-test/src/
and then only run it in libc-test/test
. Then you could add a new test file to check this implementation itself, just have a bunch of examples in strings and assert they pass/fail.
dcb2fb0
to
c9c4ad0
Compare
I couldn't quite get it to work with |
Sorry for cramming so much into one pr but I think I came up with some decent rules for doing the libc/libc-test/test/style/mod.rs Lines 22 to 26 in 60c840e
Here are some examples, mostly taken from what you mentioned in the issue/review comments: libc/libc-test/test/style_tests.rs Lines 135 to 260 in 60c840e
|
b73c617
to
e71680a
Compare
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.
Sorry this took a little while, usually I sweep this repo about once a week. Overall, looks great! I left a handful of mostly stylistic suggestions, nothing major.
After you make any changes please just clean up the history and we should be able to get this in.
I couldn't quite get it to work with
libc-test/src/
since there were some linking errors, I think having to do with usingcc
in the build script. For now I just moved the common functionality intotests/style/mod.rs
similar to what is suggested here so that we can test the style checker implementation as well: https://doc.rust-lang.org/rust-by-example/testing/integration_testing.html.
A solution for this would probably be to make a ctest
feature that is enabled by default and turns on cc
, then for these style tests we just run with --no-default-features
. But that's a change for later (I think the test library needs some refactoring anyway).
Sorry for cramming so much into one pr but I think I came up with some decent rules for doing the
#[cfg(...)]
checking, basically just checking if there are duplicates and standalone positive#[cfg(...)]
attributes instead of requiring thatcfg_if!
is used everywhere:
Thanks for getting this feature in! It seems reasonable to me and, more importantly, it seems straightforward to adjust if needed.
No problem at all! I just addressed the comments and cleaned up the history :) |
I'm not quite sure why emscripten is failing, seems like it's failing to run the C build? I don't know why that would be, seems like it should be unrelated. |
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.
In any case lgtm, thanks for getting this done! I'll try to figure out if our emscripten CI just broke somehow, unless you have any ideas.
Yeah I wasn't sure about this either, it was passing earlier and I don't think addressing the review comments should have touched anything related to the build script. |
Just reran it and it passes now so maybe it was a flake? |
That's lucky 🎉. Thanks again for making this happen! |
Description
syn
instead of text-based parsing since it's more accurate and easier to work withstyle.rs
tolibc-test
and make it run as a part ofcargo test
, as well as cleaning it up a bit and adding tests for the style checker implementation itselfcfg_if!
macros, and tries to apply the same logic that the previousstyle.rs
script dids!
macrosCloses #4109
Sources
Checklist
libc-test/semver
have been updated*LAST
or*MAX
areincluded (see #3131)
cd libc-test && cargo test --target mytarget
);especially relevant for platforms that may not be checked in CI