-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Migrate write.rs to a late pass #8518
Conversation
r? @flip1995 (rust-highfive has picked a reviewer for you, use r? to override) |
☔ The latest upstream changes (presumably #8534) made this pull request unmergeable. Please resolve the merge conflicts. |
40301d3
to
c638cce
Compare
Thanks for putting in the work! This loses many useful suggestions. Retaining those is currently not really possible as a LatePass. I nominated this issue for discussion in the next Clippy meeting, if we're ready for this tradeoff. |
☔ The latest upstream changes (presumably #8232) made this pull request unmergeable. Please resolve the merge conflicts. |
c638cce
to
a3553f1
Compare
You should be able to walk the chain of |
8b92deb
to
7e6a1c4
Compare
I think this is ready to review now that I've finished upsetting the dogfood test 😄 The |
☔ The latest upstream changes (presumably #8576) made this pull request unmergeable. Please resolve the merge conflicts. |
97c8cfb
to
2f51fd3
Compare
☔ The latest upstream changes (presumably #8788) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #8797) made this pull request unmergeable. Please resolve the merge conflicts. |
6750424
to
b2722b2
Compare
☔ The latest upstream changes (presumably #9069) made this pull request unmergeable. Please resolve the merge conflicts. |
b2722b2
to
4797c3c
Compare
☔ The latest upstream changes (presumably #9099) made this pull request unmergeable. Please resolve the merge conflicts. |
I wrote inline format arguments lint #9233 that can convert |
☔ The latest upstream changes (presumably #9323) made this pull request unmergeable. Please resolve the merge conflicts. |
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.
Nice rewrite, the code looks really clean and I enjoyed reading through it.
I just left a few comments of "please add a comment here", nothing major.
Sorry again for taking so long.
Ugh, thanks for the heads up. I'll try to get to all of this until early Sunday afternoon CEST, when my workaction ends and my vacation starts 👍 |
Refactor `FormatArgsExpn` It now for each format argument `{..}` has: - The `Expr` it points to, and how it does so (named/named inline/numbered/implicit) - The parsed `FormatSpec` (format trait/fill/align/etc., the precision/width and any value they point to) - Many spans The caller no longer needs to pair up arguments to their value, or separately interpret the `specs` `Expr`s when it isn't `None` The gist is that it combines the result of [`rustc_parse_format::Parser`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_parse_format/struct.Parser.html) with the macro expansion itself This unfortunately makes the code a bit longer, however we need to use both as neither have all the information we're after. `rustc_parse_format` doesn't have the information to resolve named arguments to their values. The macro expansion doesn't contain whether the positions are implicit/numbered/named, or the spans for format arguments Wanted by #9233 and #8518 to be able to port the changes from #9040 Also fixes #8643, previously the format args seem to have been paired up with the wrong values somehow changelog: [`format_in_format_args`]: Fix false positive due to misattributed arguments r? `@flip1995` cc `@nyurik`
Ran into some span issues - rust-lang/rust#100851 |
03c7bde
to
8276e68
Compare
Rebased it onto master, there weren't many substantial changes to the existing lints but I marked |
☔ The latest upstream changes (presumably #9406) made this pull request unmergeable. Please resolve the merge conflicts. |
8276e68
to
75a8444
Compare
Seems like this is getting really really close to merging! 🤞 I tried rebasing #9233 on top of this, but with all the constant changes and forced-pushes it is a bit too difficult to keep it up to date, so patiently waiting until the merge :). Based on @flip1995 comment, seems like there is nothing blocking it now 🎉 |
☔ The latest upstream changes (presumably #9447) made this pull request unmergeable. Please resolve the merge conflicts. |
75a8444
to
4dd22c7
Compare
4dd22c7
to
6fc6d87
Compare
Thanks! Sorry it took so long... $day_job is currently taking up all my time. Let's get this merged. @bors r+ p=1 |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
changelog: Migrates write.rs from a pre expansion pass to a late pass
changelog: [
positional_named_format_parameters
] is renamed in favour of the rustc lintnamed_arguments_used_positionally
print!
print_literal
/write_literal
no longer lint no longer lint literals that come from macro expansions, e.g.env!("FOO")
print_with_newline
/write_with_newline
no longer lint strings with any internal\r
or\n
sA false negative,print_literal
/write_literal
don't lint format strings that produceFormatSpec
s, e.g. ones containing pretty print/width/align specifiersSuggestion changes:
print_literal
/write_literal
no longer have suggestions, as the spans for the{}
s were not easily obtainableprint_with_newline
/write_with_newline
has a better suggestion for a sole literal newline, but no longer has suggestions for len > 1 strings that end in a literal newlineuse_debug
spans are less precise, now point to the whole format stringThe diff for write.rs is pretty unwieldy, other than for the
declare_clippy_lint!
s I think you'd be better off viewing it as a brand new file rather than looking at the diff, as it's mostly written from scratchcc #6610, fixes #5721, fixes #7195, fixes #8615