Skip to content

Commit 1ea17d2

Browse files
committed
Add inline formatting tests
1 parent 7f61ad5 commit 1ea17d2

4 files changed

+45
-7
lines changed

tests/ui/unnecessary_os_str_debug_formatting.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ fn main() {
1515
println!("{:?}", os_str); //~ unnecessary_debug_formatting
1616
println!("{:?}", os_string); //~ unnecessary_debug_formatting
1717

18+
println!("{os_str:?}"); //~ unnecessary_debug_formatting
19+
println!("{os_string:?}"); //~ unnecessary_debug_formatting
20+
1821
let _: String = format!("{:?}", os_str); //~ unnecessary_debug_formatting
1922
let _: String = format!("{:?}", os_string); //~ unnecessary_debug_formatting
2023
}

tests/ui/unnecessary_os_str_debug_formatting.stderr

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,37 @@ LL | println!("{:?}", os_string);
1616
|
1717
= help: use `Display` formatting and change this to `os_string.display()`
1818

19+
error: unnecessary `Debug` formatting in `println!` args
20+
--> tests/ui/unnecessary_os_str_debug_formatting.rs:18:16
21+
|
22+
LL | println!("{os_str:?}");
23+
| ^^^^^^
24+
|
25+
= help: use `Display` formatting and change this to `os_str.display()`
26+
27+
error: unnecessary `Debug` formatting in `println!` args
28+
--> tests/ui/unnecessary_os_str_debug_formatting.rs:19:16
29+
|
30+
LL | println!("{os_string:?}");
31+
| ^^^^^^^^^
32+
|
33+
= help: use `Display` formatting and change this to `os_string.display()`
34+
1935
error: unnecessary `Debug` formatting in `format!` args
20-
--> tests/ui/unnecessary_os_str_debug_formatting.rs:18:37
36+
--> tests/ui/unnecessary_os_str_debug_formatting.rs:21:37
2137
|
2238
LL | let _: String = format!("{:?}", os_str);
2339
| ^^^^^^
2440
|
2541
= help: use `Display` formatting and change this to `os_str.display()`
2642

2743
error: unnecessary `Debug` formatting in `format!` args
28-
--> tests/ui/unnecessary_os_str_debug_formatting.rs:19:37
44+
--> tests/ui/unnecessary_os_str_debug_formatting.rs:22:37
2945
|
3046
LL | let _: String = format!("{:?}", os_string);
3147
| ^^^^^^^^^
3248
|
3349
= help: use `Display` formatting and change this to `os_string.display()`
3450

35-
error: aborting due to 4 previous errors
51+
error: aborting due to 6 previous errors
3652

tests/ui/unnecessary_path_debug_formatting.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ fn main() {
3333
println!("{:?}", path); //~ unnecessary_debug_formatting
3434
println!("{:?}", path_buf); //~ unnecessary_debug_formatting
3535

36+
println!("{path:?}"); //~ unnecessary_debug_formatting
37+
println!("{path_buf:?}"); //~ unnecessary_debug_formatting
38+
3639
let _: String = format!("{:?}", path); //~ unnecessary_debug_formatting
3740
let _: String = format!("{:?}", path_buf); //~ unnecessary_debug_formatting
3841

tests/ui/unnecessary_path_debug_formatting.stderr

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,45 @@ LL | println!("{:?}", path_buf);
1616
|
1717
= help: use `Display` formatting and change this to `path_buf.display()`
1818

19+
error: unnecessary `Debug` formatting in `println!` args
20+
--> tests/ui/unnecessary_path_debug_formatting.rs:36:16
21+
|
22+
LL | println!("{path:?}");
23+
| ^^^^
24+
|
25+
= help: use `Display` formatting and change this to `path.display()`
26+
27+
error: unnecessary `Debug` formatting in `println!` args
28+
--> tests/ui/unnecessary_path_debug_formatting.rs:37:16
29+
|
30+
LL | println!("{path_buf:?}");
31+
| ^^^^^^^^
32+
|
33+
= help: use `Display` formatting and change this to `path_buf.display()`
34+
1935
error: unnecessary `Debug` formatting in `format!` args
20-
--> tests/ui/unnecessary_path_debug_formatting.rs:36:37
36+
--> tests/ui/unnecessary_path_debug_formatting.rs:39:37
2137
|
2238
LL | let _: String = format!("{:?}", path);
2339
| ^^^^
2440
|
2541
= help: use `Display` formatting and change this to `path.display()`
2642

2743
error: unnecessary `Debug` formatting in `format!` args
28-
--> tests/ui/unnecessary_path_debug_formatting.rs:37:37
44+
--> tests/ui/unnecessary_path_debug_formatting.rs:40:37
2945
|
3046
LL | let _: String = format!("{:?}", path_buf);
3147
| ^^^^^^^^
3248
|
3349
= help: use `Display` formatting and change this to `path_buf.display()`
3450

3551
error: unnecessary `Debug` formatting in `println!` args
36-
--> tests/ui/unnecessary_path_debug_formatting.rs:40:22
52+
--> tests/ui/unnecessary_path_debug_formatting.rs:43:22
3753
|
3854
LL | println!("{:?}", &*deref_path);
3955
| ^^^^^^^^^^^^
4056
|
4157
= help: use `Display` formatting and change this to `&*deref_path.display()`
4258

43-
error: aborting due to 5 previous errors
59+
error: aborting due to 7 previous errors
4460

0 commit comments

Comments
 (0)