X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Ftools%2Fclippy%2Ftests%2Fui%2Fformat_args.rs;h=3a434c5bf002a3350a08a0da2988747de925bcc9;hb=a1b06388ce42ab7dd8aad1aebf87fa5299e2e08a;hp=164cc07066dc3b892022b616b34f4130083c12ce;hpb=0f81c7faf5f657704b2e29154af3c09aca7afd67;p=rust.git diff --git a/src/tools/clippy/tests/ui/format_args.rs b/src/tools/clippy/tests/ui/format_args.rs index 164cc07066d..3a434c5bf00 100644 --- a/src/tools/clippy/tests/ui/format_args.rs +++ b/src/tools/clippy/tests/ui/format_args.rs @@ -5,6 +5,7 @@ #![allow(unused_variables)] #![allow(clippy::assertions_on_constants)] #![allow(clippy::eq_op)] +#![allow(clippy::print_literal)] #![warn(clippy::to_string_in_format_args)] use std::io::{stdout, Write}; @@ -97,9 +98,20 @@ fn main() { println!("{}", Z(1).to_string()); println!("{}", x.to_string()); println!("{}", x_ref.to_string()); + // https://github.com/rust-lang/rust-clippy/issues/7903 + println!("{foo}{bar}", foo = "foo".to_string(), bar = "bar"); + println!("{foo}{bar}", foo = "foo", bar = "bar".to_string()); + println!("{foo}{bar}", bar = "bar".to_string(), foo = "foo"); + println!("{foo}{bar}", bar = "bar", foo = "foo".to_string()); + // negative tests println!("error: something failed at {}", Somewhere.to_string()); + // The next two tests are negative because caching the string might be faster than calling `::fmt` twice. println!("{} and again {0}", x.to_string()); + println!("{foo}{foo}", foo = "foo".to_string()); my_macro!(); println!("error: something failed at {}", my_other_macro!()); + // https://github.com/rust-lang/rust-clippy/issues/7903 + println!("{foo}{foo:?}", foo = "foo".to_string()); }