Skip to content

Commit e0cb4ce

Browse files
committed
Check the MSRV for unnecessary_debug_formatting
`unnecessary_debug_formatting` suggests display() respected for MSRV but lacking of tests. This adds tests to check MSRV for OsStr. changelog: none
1 parent 4ead403 commit e0cb4ce

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

tests/ui/unnecessary_os_str_debug_formatting.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,16 @@ fn main() {
2121
let _: String = format!("{:?}", os_str); //~ unnecessary_debug_formatting
2222
let _: String = format!("{:?}", os_string); //~ unnecessary_debug_formatting
2323
}
24+
25+
#[clippy::msrv = "1.86"]
26+
fn msrv_1_86() {
27+
let os_str = OsStr::new("test");
28+
println!("{:?}", os_str);
29+
}
30+
31+
#[clippy::msrv = "1.87"]
32+
fn msrv_1_87() {
33+
let os_str = OsStr::new("test");
34+
println!("{:?}", os_str);
35+
//~^ unnecessary_debug_formatting
36+
}

tests/ui/unnecessary_os_str_debug_formatting.stderr

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,14 @@ LL | let _: String = format!("{:?}", os_string);
5454
= help: use `Display` formatting and change this to `os_string.display()`
5555
= note: switching to `Display` formatting will change how the value is shown; escaped characters will no longer be escaped and surrounding quotes will be removed
5656

57-
error: aborting due to 6 previous errors
57+
error: unnecessary `Debug` formatting in `println!` args
58+
--> tests/ui/unnecessary_os_str_debug_formatting.rs:34:22
59+
|
60+
LL | println!("{:?}", os_str);
61+
| ^^^^^^
62+
|
63+
= help: use `Display` formatting and change this to `os_str.display()`
64+
= note: switching to `Display` formatting will change how the value is shown; escaped characters will no longer be escaped and surrounding quotes will be removed
65+
66+
error: aborting due to 7 previous errors
5867

0 commit comments

Comments
 (0)