about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorAlex Macleod <alex@macleod.io>2023-03-28 12:22:22 +0000
committerAlex Macleod <alex@macleod.io>2023-03-28 12:22:22 +0000
commit3259b48568c4fe19b60a47011c9fe424b707533c (patch)
tree15911924bfa36b44d44276e779d1040ac6121a17 /tests
parent70db22648bb1a79d2f6978adf6dc40240de59d89 (diff)
Migrate `format_args.rs` to `rustc_ast::FormatArgs`
No longer lints empty precisions `{:.}` as the spans aren't available
Diffstat (limited to 'tests')
-rw-r--r--tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr22
-rw-r--r--tests/ui/uninlined_format_args.fixed2
-rw-r--r--tests/ui/uninlined_format_args.stderr14
-rw-r--r--tests/ui/unused_format_specs.fixed18
-rw-r--r--tests/ui/unused_format_specs.rs18
-rw-r--r--tests/ui/unused_format_specs.stderr54
-rw-r--r--tests/ui/unused_format_specs_unfixable.stderr12
7 files changed, 15 insertions, 125 deletions
diff --git a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr
index ee941762196..1be0cda12fc 100644
--- a/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr
+++ b/tests/ui-toml/allow_mixed_uninlined_format_args/uninlined_format_args.stderr
@@ -11,29 +11,29 @@ LL -     println!("val='{}'", local_i32);
 LL +     println!("val='{local_i32}'");
    |
 
-error: literal with an empty format string
-  --> $DIR/uninlined_format_args.rs:10:35
+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);
-   |                                   ^^^
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: `-D clippy::print-literal` implied by `-D warnings`
-help: try this
+help: change this to
    |
 LL -     println!("Hello {} is {:.*}", "x", local_i32, local_f64);
-LL +     println!("Hello x is {:.*}", 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:10:5
+error: literal with an empty format string
+  --> $DIR/uninlined_format_args.rs:10:35
    |
 LL |     println!("Hello {} is {:.*}", "x", local_i32, local_f64);
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                                   ^^^
    |
-help: change this to
+   = note: `-D clippy::print-literal` implied by `-D warnings`
+help: try this
    |
 LL -     println!("Hello {} is {:.*}", "x", local_i32, local_f64);
-LL +     println!("Hello {} is {local_f64:.local_i32$}", "x");
+LL +     println!("Hello x is {:.*}", local_i32, local_f64);
    |
 
 error: variables can be used directly in the `format!` string
diff --git a/tests/ui/uninlined_format_args.fixed b/tests/ui/uninlined_format_args.fixed
index 1475d781c67..5ecb9a5bf9e 100644
--- a/tests/ui/uninlined_format_args.fixed
+++ b/tests/ui/uninlined_format_args.fixed
@@ -119,7 +119,7 @@ fn tester(fn_arg: i32) {
     println!("Width = {local_i32}, value with width = {local_f64:local_i32$}");
     println!("{local_i32:width$.prec$}");
     println!("{width:width$.prec$}");
-    println!("{}", format!("{local_i32}"));
+    println!("{}", format!("{}", local_i32));
     my_println!("{}", local_i32);
     my_println_args!("{}", local_i32);
 
diff --git a/tests/ui/uninlined_format_args.stderr b/tests/ui/uninlined_format_args.stderr
index a12abf8bef8..dc4af6ef42e 100644
--- a/tests/ui/uninlined_format_args.stderr
+++ b/tests/ui/uninlined_format_args.stderr
@@ -775,18 +775,6 @@ LL +     println!("{width:width$.prec$}");
    |
 
 error: variables can be used directly in the `format!` string
-  --> $DIR/uninlined_format_args.rs:125:20
-   |
-LL |     println!("{}", format!("{}", local_i32));
-   |                    ^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-help: change this to
-   |
-LL -     println!("{}", format!("{}", local_i32));
-LL +     println!("{}", format!("{local_i32}"));
-   |
-
-error: variables can be used directly in the `format!` string
   --> $DIR/uninlined_format_args.rs:143:5
    |
 LL | /     println!(
@@ -856,5 +844,5 @@ LL -     println!("expand='{}'", local_i32);
 LL +     println!("expand='{local_i32}'");
    |
 
-error: aborting due to 72 previous errors
+error: aborting due to 71 previous errors
 
diff --git a/tests/ui/unused_format_specs.fixed b/tests/ui/unused_format_specs.fixed
deleted file mode 100644
index 2930722b42d..00000000000
--- a/tests/ui/unused_format_specs.fixed
+++ /dev/null
@@ -1,18 +0,0 @@
-// run-rustfix
-
-#![warn(clippy::unused_format_specs)]
-#![allow(unused)]
-
-fn main() {
-    let f = 1.0f64;
-    println!("{}", 1.0);
-    println!("{f} {f:?}");
-
-    println!("{}", 1);
-}
-
-fn should_not_lint() {
-    let f = 1.0f64;
-    println!("{:.1}", 1.0);
-    println!("{f:.w$} {f:.*?}", 3, w = 2);
-}
diff --git a/tests/ui/unused_format_specs.rs b/tests/ui/unused_format_specs.rs
deleted file mode 100644
index ee192a000d4..00000000000
--- a/tests/ui/unused_format_specs.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-// run-rustfix
-
-#![warn(clippy::unused_format_specs)]
-#![allow(unused)]
-
-fn main() {
-    let f = 1.0f64;
-    println!("{:.}", 1.0);
-    println!("{f:.} {f:.?}");
-
-    println!("{:.}", 1);
-}
-
-fn should_not_lint() {
-    let f = 1.0f64;
-    println!("{:.1}", 1.0);
-    println!("{f:.w$} {f:.*?}", 3, w = 2);
-}
diff --git a/tests/ui/unused_format_specs.stderr b/tests/ui/unused_format_specs.stderr
deleted file mode 100644
index 7231c17e74c..00000000000
--- a/tests/ui/unused_format_specs.stderr
+++ /dev/null
@@ -1,54 +0,0 @@
-error: empty precision specifier has no effect
-  --> $DIR/unused_format_specs.rs:8:17
-   |
-LL |     println!("{:.}", 1.0);
-   |                 ^
-   |
-   = note: a precision specifier is not required to format floats
-   = note: `-D clippy::unused-format-specs` implied by `-D warnings`
-help: remove the `.`
-   |
-LL -     println!("{:.}", 1.0);
-LL +     println!("{}", 1.0);
-   |
-
-error: empty precision specifier has no effect
-  --> $DIR/unused_format_specs.rs:9:18
-   |
-LL |     println!("{f:.} {f:.?}");
-   |                  ^
-   |
-   = note: a precision specifier is not required to format floats
-help: remove the `.`
-   |
-LL -     println!("{f:.} {f:.?}");
-LL +     println!("{f} {f:.?}");
-   |
-
-error: empty precision specifier has no effect
-  --> $DIR/unused_format_specs.rs:9:24
-   |
-LL |     println!("{f:.} {f:.?}");
-   |                        ^
-   |
-   = note: a precision specifier is not required to format floats
-help: remove the `.`
-   |
-LL -     println!("{f:.} {f:.?}");
-LL +     println!("{f:.} {f:?}");
-   |
-
-error: empty precision specifier has no effect
-  --> $DIR/unused_format_specs.rs:11:17
-   |
-LL |     println!("{:.}", 1);
-   |                 ^
-   |
-help: remove the `.`
-   |
-LL -     println!("{:.}", 1);
-LL +     println!("{}", 1);
-   |
-
-error: aborting due to 4 previous errors
-
diff --git a/tests/ui/unused_format_specs_unfixable.stderr b/tests/ui/unused_format_specs_unfixable.stderr
index 9f1890282e6..cb7156b6baf 100644
--- a/tests/ui/unused_format_specs_unfixable.stderr
+++ b/tests/ui/unused_format_specs_unfixable.stderr
@@ -37,11 +37,7 @@ error: format specifiers have no effect on `format_args!()`
 LL |     println!("{:5}.", format_args_from_macro!());
    |               ^^^^
    |
-help: for the width to apply consider using `format!()`
-  --> $DIR/unused_format_specs_unfixable.rs:16:17
-   |
-LL |     println!("{:5}.", format_args_from_macro!());
-   |                 ^
+   = help: for the width to apply consider using `format!()`
 help: if the current behavior is intentional, remove the format specifiers
    |
 LL -     println!("{:5}.", format_args_from_macro!());
@@ -54,11 +50,7 @@ error: format specifiers have no effect on `format_args!()`
 LL |     println!("{args:5}");
    |               ^^^^^^^^
    |
-help: for the width to apply consider using `format!()`
-  --> $DIR/unused_format_specs_unfixable.rs:19:21
-   |
-LL |     println!("{args:5}");
-   |                     ^
+   = help: for the width to apply consider using `format!()`
 help: if the current behavior is intentional, remove the format specifiers
    |
 LL -     println!("{args:5}");