From 4e8199b572f2035b7749cba276ece3a26630d23e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:21 +0200 Subject: Adding upstream version 1.67.1+dfsg1. Signed-off-by: Daniel Baumann --- .../allow_mixed_uninlined_format_args/clippy.toml | 1 + .../uninlined_format_args.fixed | 14 ++++ .../uninlined_format_args.rs | 14 ++++ .../uninlined_format_args.stderr | 76 ++++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/clippy.toml create mode 100644 src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.fixed create mode 100644 src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs create mode 100644 src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr (limited to 'src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args') diff --git a/src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/clippy.toml b/src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/clippy.toml new file mode 100644 index 000000000..b95e806aa --- /dev/null +++ b/src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/clippy.toml @@ -0,0 +1 @@ +allow-mixed-uninlined-format-args = false diff --git a/src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.fixed b/src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.fixed new file mode 100644 index 000000000..aa8b45b5f --- /dev/null +++ b/src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.fixed @@ -0,0 +1,14 @@ +// run-rustfix +#![warn(clippy::uninlined_format_args)] + +fn main() { + let local_i32 = 1; + let local_f64 = 2.0; + let local_opt: Option = Some(3); + + println!("val='{local_i32}'"); + println!("Hello x is {local_f64:.local_i32$}"); + println!("Hello {local_i32} is {local_f64:.*}", 5); + println!("Hello {local_i32} is {local_f64:.*}", 5); + println!("{local_i32}, {}", local_opt.unwrap()); +} diff --git a/src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs b/src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs new file mode 100644 index 000000000..ad2e4863e --- /dev/null +++ b/src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.rs @@ -0,0 +1,14 @@ +// run-rustfix +#![warn(clippy::uninlined_format_args)] + +fn main() { + let local_i32 = 1; + let local_f64 = 2.0; + let local_opt: Option = Some(3); + + println!("val='{}'", local_i32); + println!("Hello {} is {:.*}", "x", local_i32, local_f64); + println!("Hello {} is {:.*}", local_i32, 5, local_f64); + println!("Hello {} is {2:.*}", local_i32, 5, local_f64); + println!("{}, {}", local_i32, local_opt.unwrap()); +} diff --git a/src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr b/src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr new file mode 100644 index 000000000..ee9417621 --- /dev/null +++ b/src/tools/clippy/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr @@ -0,0 +1,76 @@ +error: variables can be used directly in the `format!` string + --> $DIR/uninlined_format_args.rs:9:5 + | +LL | println!("val='{}'", local_i32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `-D clippy::uninlined-format-args` implied by `-D warnings` +help: change this to + | +LL - println!("val='{}'", local_i32); +LL + println!("val='{local_i32}'"); + | + +error: literal with an empty format string + --> $DIR/uninlined_format_args.rs:10:35 + | +LL | println!("Hello {} is {:.*}", "x", local_i32, local_f64); + | ^^^ + | + = note: `-D clippy::print-literal` implied by `-D warnings` +help: try this + | +LL - println!("Hello {} is {:.*}", "x", local_i32, local_f64); +LL + println!("Hello x is {:.*}", local_i32, local_f64); + | + +error: variables can be used directly in the `format!` string + --> $DIR/uninlined_format_args.rs:10:5 + | +LL | println!("Hello {} is {:.*}", "x", local_i32, local_f64); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: change this to + | +LL - println!("Hello {} is {:.*}", "x", local_i32, local_f64); +LL + println!("Hello {} is {local_f64:.local_i32$}", "x"); + | + +error: variables can be used directly in the `format!` string + --> $DIR/uninlined_format_args.rs:11:5 + | +LL | println!("Hello {} is {:.*}", local_i32, 5, local_f64); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: change this to + | +LL - println!("Hello {} is {:.*}", local_i32, 5, local_f64); +LL + println!("Hello {local_i32} is {local_f64:.*}", 5); + | + +error: variables can be used directly in the `format!` string + --> $DIR/uninlined_format_args.rs:12:5 + | +LL | println!("Hello {} is {2:.*}", local_i32, 5, local_f64); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: change this to + | +LL - println!("Hello {} is {2:.*}", local_i32, 5, local_f64); +LL + println!("Hello {local_i32} is {local_f64:.*}", 5); + | + +error: variables can be used directly in the `format!` string + --> $DIR/uninlined_format_args.rs:13:5 + | +LL | println!("{}, {}", local_i32, local_opt.unwrap()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: change this to + | +LL - println!("{}, {}", local_i32, local_opt.unwrap()); +LL + println!("{local_i32}, {}", local_opt.unwrap()); + | + +error: aborting due to 6 previous errors + -- cgit v1.2.3