Skip to content

Add DesugaringKind::FormatLiteral #142594

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

mejrs
Copy link
Contributor

@mejrs mejrs commented Jun 16, 2025

Implements DesugaringKind::FormatLiteral to mark the FormatArgs desugaring of format literals. The main use for this is to stop yapping about about formatting parameters if we're not anywhere near a format literal. The other use case is to fix suggestions such as #141350. It might also be useful for new or existing diagnostics that check whether they're in a format-like macro.

cc @xizheyin @fmease

@rustbot
Copy link
Collaborator

rustbot commented Jun 16, 2025

r? @SparrowLii

rustbot has assigned @SparrowLii.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 16, 2025

Some changes occurred in compiler/rustc_ast_lowering/src/format.rs

cc @m-ou-se

@fmease
Copy link
Member

fmease commented Jun 16, 2025

We might want to block this on #140748, I'm relatively sure. Just FYI

@mejrs
Copy link
Contributor Author

mejrs commented Jun 16, 2025

Why is that?

@fmease
Copy link
Member

fmease commented Jun 16, 2025

Idk, if it's not conflicting according to git and if it's not stepping on each other's toes in other ways, I guess it's fine — I only skimmed boths diffs. Mara's PR will likely get approved soon anyway.

Copy link
Contributor

@xizheyin xizheyin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, #141633 can be refactored after this.

@@ -50,6 +50,7 @@ pub struct FormatArgs {
///
/// Generally only useful for lints that care about the raw bytes the user wrote.
pub uncooked_fmt_str: (LitKind, Symbol),
pub is_source_literal: bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a doc comment on this field to explain what it means?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants