Add and fix lints from #[clippy::format_args] and explain diag.rs macro organization#8335
Merged
Merged
Conversation
The hint fixes were found by manually checking the hits from `rg -U 'hint:(\s|\n)+"[^"]+"[^;`]'` Changing `crate::__bail` to `__bail` was required due to triggering the `macro_expanded_macro_exports_accessed_by_absolute_paths` lint, since `clippy::format_args` is a macro expansion around `__bail`, so `crate::__bail` is an access of the absolute path of a macro expanded macro export. The lint is tracked at <rust-lang/rust#144408>.
b7d95bc to
35b0a7a
Compare
Member
|
Thanks! |
Collaborator
Author
|
Ooh, do we have a merge queue now? |
Member
|
I think we had one for quite a while, but your commits are always so nice that they get fast-forward merged :D |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first commit adds the
#[clippy::format_args]attribute tobail!and friends, which allows us to warn for clippy lints that apply toformat!, which I also fix in the commit. Although it only works for the initial format string, not for hints. The fixes are almost entirely just changes likeerror!("message: {}", var)toerror!("message: {var}").I also added a PR at typst/ecow#62 to apply the attribute on
eco_format!, and I've fixed the warnings doing so would cause.Note that changing
crate::__bailto__bailin the commit was required due to triggering themacro_expanded_macro_exports_accessed_by_absolute_pathswarning, sinceclippy::format_argsis a macro expansion around__bail, meaningcrate::__bailis an access of the absolute path of a macro expanded macro export (I'm so sorry). More details for the warning are tracked at rust-lang/rust#144408.The second commit separates the
ecowre-exports indiag.rsfrom the macro re-exports to change their documentation to#[doc(hidden)], but more importantly it adds comments explaining why we re-export them publicly at all, and why we re-export the macros like__bailasbailsince this is a very odd pattern in Rust.