Skip to content

Commit f2ca390

Browse files
committed
fmt
1 parent fe119f0 commit f2ca390

7 files changed

+17
-11
lines changed

tests/ui/format_args.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
#![allow(clippy::print_literal)]
77
#![warn(clippy::to_string_in_format_args)]
88

9+
use indoc::{indoc, printdoc};
910
use std::io::{stdout, Write};
1011
use std::ops::Deref;
1112
use std::panic::Location;
12-
use indoc::{indoc, printdoc};
1313

1414
struct Somewhere;
1515

tests/ui/format_args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
#![allow(clippy::print_literal)]
77
#![warn(clippy::to_string_in_format_args)]
88

9+
use indoc::{indoc, printdoc};
910
use std::io::{stdout, Write};
1011
use std::ops::Deref;
1112
use std::panic::Location;
12-
use indoc::{indoc, printdoc};
1313

1414
struct Somewhere;
1515

tests/ui/format_args_unfixable.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
#![warn(clippy::format_in_format_args)]
44
#![warn(clippy::to_string_in_format_args)]
55

6+
use indoc::{indoc, printdoc};
67
use std::io::{stdout, Error, ErrorKind, Write};
78
use std::ops::Deref;
89
use std::panic::Location;
9-
use indoc::{indoc, printdoc};
1010

1111
macro_rules! my_macro {
1212
() => {
@@ -51,7 +51,10 @@ fn main() {
5151
assert_eq!(0, 0, "error: {}", format!("something failed at {}", Location::caller()));
5252
assert_ne!(0, 0, "error: {}", format!("something failed at {}", Location::caller()));
5353
panic!("error: {}", format!("something failed at {}", Location::caller()));
54-
panic!(indoc!("error: {}"), format!("something failed at {}", Location::caller()));
54+
panic!(
55+
indoc!("error: {}"),
56+
format!("something failed at {}", Location::caller())
57+
);
5558
printdoc!("error: {}", format!("something failed at {}", Location::caller()));
5659

5760
// negative tests

tests/ui/format_args_unfixable.stderr

+5-2
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,11 @@ LL | panic!("error: {}", format!("something failed at {}", Location::caller(
174174
error: `format!` in `panic!` args
175175
--> $DIR/format_args_unfixable.rs:54:5
176176
|
177-
LL | panic!(indoc!("error: {}"), format!("something failed at {}", Location::caller()));
178-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
177+
LL | / panic!(
178+
LL | | indoc!("error: {}"),
179+
LL | | format!("something failed at {}", Location::caller())
180+
LL | | );
181+
| |_____^
179182
|
180183
= help: combine the `format!(..)` arguments with the outer `panic!(..)` call
181184
= help: or consider changing `format!` to `format_args!`

tests/ui/uninlined_format_args.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ fn tester(fn_arg: i32) {
108108

109109
// these should NOT be modified by the lint
110110
println!(concat!("nope ", "{}"), local_i32);
111-
println!(indoc!{"foo={local_i32}"});
111+
println!(indoc!("foo={local_i32}"));
112112
printdoc!("foo={}", local_i32);
113113
println!("val='{local_i32}'");
114114
println!("val='{local_i32 }'");

tests/ui/uninlined_format_args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ fn tester(fn_arg: i32) {
111111

112112
// these should NOT be modified by the lint
113113
println!(concat!("nope ", "{}"), local_i32);
114-
println!(indoc!{"foo={}"}, local_i32);
114+
println!(indoc!("foo={}"), local_i32);
115115
printdoc!("foo={}", local_i32);
116116
println!("val='{local_i32}'");
117117
println!("val='{local_i32 }'");

tests/ui/uninlined_format_args.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -853,13 +853,13 @@ LL + println!("{}", format!("{local_i32}"));
853853
error: variables can be used directly in the `format!` string
854854
--> $DIR/uninlined_format_args.rs:114:5
855855
|
856-
LL | println!(indoc!{"foo={}"}, local_i32);
856+
LL | println!(indoc!("foo={}"), local_i32);
857857
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
858858
|
859859
help: change this to
860860
|
861-
LL - println!(indoc!{"foo={}"}, local_i32);
862-
LL + println!(indoc!{"foo={local_i32}"});
861+
LL - println!(indoc!("foo={}"), local_i32);
862+
LL + println!(indoc!("foo={local_i32}"));
863863
|
864864

865865
error: variables can be used directly in the `format!` string

0 commit comments

Comments
 (0)