Skip to content
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

fix literal_string_with_formatting_args FP on format inside assert #13898

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

profetia
Copy link
Contributor

fixes: #13885

I found that the error message generated by assert is put on a root context, not sure if it is a bug on the compiler side (I tested dbg and everything went fine, though I do found the generated file name is on a root context too). I simply guarded the lint behind is_dummy.


changelog: [literal_string_with_formatting_args] fix FP on format inside assert

@rustbot
Copy link
Collaborator

rustbot commented Dec 29, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Alexendoo (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 29, 2024
@tamird
Copy link
Contributor

tamird commented Dec 29, 2024

I'm not a clippy expert but this fix looks like a hack to me. Why don't we want to report these? The bug I reported is that this FP happens even when I put an #[allow(...)] on the expression.

@profetia
Copy link
Contributor Author

@tamird I think you misunderstand my point. This FP happens because clippy is linting the panicked message generated by assert!. So adding an #[allow(...)] on the expression will not affected the generated string literal.

fn test_parse() {
    if !parse(#[allow(clippy::literal_string_with_formatting_args)] "foo {:}").is_err()
            {
            ::core::panicking::panic("assertion failed: parse(#[allow(clippy::literal_string_with_formatting_args)] \"foo {:}\").is_err()") // This is line is causing the FP
        };
}

@GuillaumeGomez
Copy link
Member

I'm not sure this is the right fix. The problem here was that I was working on dummy spans, which is why the lint seemed to be emitted on completely unrelated code. I opened #13953.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

literal_string_with_formatting_args false positive on test
5 participants