Skip to content

Add and fix lints from #[clippy::format_args] and explain diag.rs macro organization#8335

Merged
laurmaedje merged 2 commits into
typst:mainfrom
isuffix:clippy-format-args
May 24, 2026
Merged

Add and fix lints from #[clippy::format_args] and explain diag.rs macro organization#8335
laurmaedje merged 2 commits into
typst:mainfrom
isuffix:clippy-format-args

Conversation

@isuffix

@isuffix isuffix commented May 23, 2026

Copy link
Copy Markdown
Collaborator

The first commit adds the #[clippy::format_args] attribute to bail! and friends, which allows us to warn for clippy lints that apply to format!, 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 like error!("message: {}", var) to error!("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::__bail to __bail in the commit was required due to triggering the macro_expanded_macro_exports_accessed_by_absolute_paths warning, since clippy::format_args is a macro expansion around __bail, meaning crate::__bail is 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 ecow re-exports in diag.rs from 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 __bail as bail since this is a very odd pattern in Rust.

@isuffix isuffix added the internals About internal changes to the codebase. label May 23, 2026
isuffix added 2 commits May 23, 2026 16:48
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>.
@isuffix isuffix force-pushed the clippy-format-args branch from b7d95bc to 35b0a7a Compare May 23, 2026 20:48
@laurmaedje laurmaedje added this pull request to the merge queue May 24, 2026
@laurmaedje

Copy link
Copy Markdown
Member

Thanks!

@isuffix

isuffix commented May 24, 2026

Copy link
Copy Markdown
Collaborator Author

Ooh, do we have a merge queue now?

Merged via the queue into typst:main with commit 89d4f50 May 24, 2026
9 checks passed
@saecki

saecki commented May 24, 2026

Copy link
Copy Markdown
Member

I think we had one for quite a while, but your commits are always so nice that they get fast-forward merged :D

@isuffix isuffix deleted the clippy-format-args branch May 24, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internals About internal changes to the codebase.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants