Skip to content

Commit

Permalink
Add more detailed explanations for #13885 regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jan 15, 2025
1 parent a7fb37c commit 00104a4
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/ui/{literal_string_with_formatting_args}.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@
// The `dbg` macro generates a literal with the name of the current file, so
// we need to ensure the lint is not emitted in this case.

// Clippy sets `-Zflatten_format_args=no`, which changes the default behavior of how format args
// are lowered and only that one has this non-macro span. Adding the flag makes it repro on
// godbolt and shows a root context span for the file name string.
//
// So instead of having:
//
// ```
// Lit(
// Spanned {
// node: Str(
// "[/app/example.rs:2:5] \"something\" = ",
// Cooked,
// ),
// span: /rustc/eb54a50837ad4bcc9842924f27e7287ca66e294c/library/std/src/macros.rs:365:35: 365:58 (#4),
// },
// ),
// ```
//
// We get:
//
// ```
// Lit(
// Spanned {
// node: Str(
// "/app/example.rs",
// Cooked,
// ),
// span: /app/example.rs:2:5: 2:22 (#0),
// },
// )
// ```

#![crate_name = "foo"]
#![allow(unused)]
#![warn(clippy::literal_string_with_formatting_args)]
Expand Down

0 comments on commit 00104a4

Please sign in to comment.