Add more detailed explanations for #13885 regression test

This commit is contained in:
Guillaume Gomez 2025-01-15 16:42:56 +01:00
parent a7fb37c1d8
commit 00104a4167

View file

@ -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)]