Migrate clippy::author to rustc_ast::FormatArgs#10698
Conversation
|
Thanks for this, didn't know
A new utility function could be nice, I'm not that happy with the current API. However we can't match on the HIR of |
8d31a5e to
1072d6e
Compare
Ah, yeah that makes sense. I've changed |
1072d6e to
b78097c
Compare
| callback: impl FnOnce(&FormatArgs), | ||
| start: &'hir Expr<'hir>, | ||
| expn_id: ExpnId, | ||
| ) -> Vec<&'hir Expr<'hir>> { |
There was a problem hiding this comment.
It'd want to be callback: impl FnOnce(&FormatArgs, Vec<...>) rather than returning the Vec, lints generally want access to both at the same time
There was a problem hiding this comment.
Oh, sorry for misunderstanding then. Although I'm not quite sure how to apply it in the author lint, if we don't return the args, it wouldn't quite fit into the if-chain author lint tries to build, i. e.
&& macros::collect_from_args(cx, |args, _fmt_args| { if /* another if-chain */ { /* report your lint here */ } }, e, macro_call.expn)- this does not only introduce another level of indentation, but also requires some code refactoring to support, which is, in my opinion, quite a bit out of scope for the author lint.
If you have any ideas on how to mitigate this, I would be happy to hear, otherwise I can close the PR and submit an issue on this.
There was a problem hiding this comment.
For author hmm that's tricky, I guess you could always print a comment saying to take a look at the function
|
☔ The latest upstream changes (presumably #10647) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Since #11444 was merged |
|
Hey @Alexendoo, this is a ping from triage. It seems like @Niki4tap hasn't responded to your last message where you suggested that you'll pick this PR up. Do we want to close this one due to inactivity? |
|
Yeah I'll take a look at it after #12567 which changes how they work (again 😛) |
This PR aims to migrate
clippy::authorlint to newFormatArgsAST, since it's been ICEing after the change.repro.rs:
Current ICE
After this PR
r? @Alexendoo
I've seen you migrate other lints, so I think your feedback will be valuable here. Thanks in advance :)
(if anyone else has an opinion that might be useful here, you're free to comment too)
Also, I'm not exactly sure if a new utility function is needed here, or it would better to reuse existing ones like
clippy_utils::macros::find_format_args.note: I think
authorlint is mostly internal, and the change is too, but on the other hand it's a bugfix, so I'm not sure what to put in the changelog, let there be none for now :)changelog: none