Check os_str_display MSRV instead of feature
This feature was stabilized, so the FormatArgs lints should check if the MSRV of the stabilization is met, rather than checking if the feature is enabled.
This commit is contained in:
parent
02e812af4d
commit
53a1ff70e8
6 changed files with 54 additions and 34 deletions
|
|
@ -1,4 +1,3 @@
|
|||
#![feature(os_str_display)]
|
||||
#![warn(clippy::unnecessary_debug_formatting)]
|
||||
|
||||
use std::ffi::{OsStr, OsString};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: unnecessary `Debug` formatting in `println!` args
|
||||
--> tests/ui/unnecessary_os_str_debug_formatting.rs:15:22
|
||||
--> tests/ui/unnecessary_os_str_debug_formatting.rs:14:22
|
||||
|
|
||||
LL | println!("{:?}", os_str);
|
||||
| ^^^^^^
|
||||
|
|
@ -10,7 +10,7 @@ LL | println!("{:?}", os_str);
|
|||
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_debug_formatting)]`
|
||||
|
||||
error: unnecessary `Debug` formatting in `println!` args
|
||||
--> tests/ui/unnecessary_os_str_debug_formatting.rs:16:22
|
||||
--> tests/ui/unnecessary_os_str_debug_formatting.rs:15:22
|
||||
|
|
||||
LL | println!("{:?}", os_string);
|
||||
| ^^^^^^^^^
|
||||
|
|
@ -19,7 +19,7 @@ LL | println!("{:?}", os_string);
|
|||
= 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
|
||||
|
||||
error: unnecessary `Debug` formatting in `println!` args
|
||||
--> tests/ui/unnecessary_os_str_debug_formatting.rs:18:16
|
||||
--> tests/ui/unnecessary_os_str_debug_formatting.rs:17:16
|
||||
|
|
||||
LL | println!("{os_str:?}");
|
||||
| ^^^^^^
|
||||
|
|
@ -28,7 +28,7 @@ LL | println!("{os_str:?}");
|
|||
= 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
|
||||
|
||||
error: unnecessary `Debug` formatting in `println!` args
|
||||
--> tests/ui/unnecessary_os_str_debug_formatting.rs:19:16
|
||||
--> tests/ui/unnecessary_os_str_debug_formatting.rs:18:16
|
||||
|
|
||||
LL | println!("{os_string:?}");
|
||||
| ^^^^^^^^^
|
||||
|
|
@ -37,7 +37,7 @@ LL | println!("{os_string:?}");
|
|||
= 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
|
||||
|
||||
error: unnecessary `Debug` formatting in `format!` args
|
||||
--> tests/ui/unnecessary_os_str_debug_formatting.rs:21:37
|
||||
--> tests/ui/unnecessary_os_str_debug_formatting.rs:20:37
|
||||
|
|
||||
LL | let _: String = format!("{:?}", os_str);
|
||||
| ^^^^^^
|
||||
|
|
@ -46,7 +46,7 @@ LL | let _: String = format!("{:?}", os_str);
|
|||
= 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
|
||||
|
||||
error: unnecessary `Debug` formatting in `format!` args
|
||||
--> tests/ui/unnecessary_os_str_debug_formatting.rs:22:37
|
||||
--> tests/ui/unnecessary_os_str_debug_formatting.rs:21:37
|
||||
|
|
||||
LL | let _: String = format!("{:?}", os_string);
|
||||
| ^^^^^^^^^
|
||||
|
|
|
|||
|
|
@ -25,11 +25,10 @@ fn main() {
|
|||
println!("{}", path.display());
|
||||
println!("{}", path_buf.display());
|
||||
|
||||
// should not fire because feature `os_str_display` is not enabled
|
||||
println!("{:?}", os_str);
|
||||
println!("{:?}", os_string);
|
||||
|
||||
// positive tests
|
||||
println!("{:?}", os_str); //~ unnecessary_debug_formatting
|
||||
println!("{:?}", os_string); //~ unnecessary_debug_formatting
|
||||
|
||||
println!("{:?}", path); //~ unnecessary_debug_formatting
|
||||
println!("{:?}", path_buf); //~ unnecessary_debug_formatting
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,34 @@
|
|||
error: unnecessary `Debug` formatting in `println!` args
|
||||
--> tests/ui/unnecessary_path_debug_formatting.rs:33:22
|
||||
--> tests/ui/unnecessary_path_debug_formatting.rs:29:22
|
||||
|
|
||||
LL | println!("{:?}", os_str);
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: use `Display` formatting and change this to `os_str.display()`
|
||||
= 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
|
||||
= note: `-D clippy::unnecessary-debug-formatting` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_debug_formatting)]`
|
||||
|
||||
error: unnecessary `Debug` formatting in `println!` args
|
||||
--> tests/ui/unnecessary_path_debug_formatting.rs:30:22
|
||||
|
|
||||
LL | println!("{:?}", os_string);
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= help: use `Display` formatting and change this to `os_string.display()`
|
||||
= 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
|
||||
|
||||
error: unnecessary `Debug` formatting in `println!` args
|
||||
--> tests/ui/unnecessary_path_debug_formatting.rs:32:22
|
||||
|
|
||||
LL | println!("{:?}", path);
|
||||
| ^^^^
|
||||
|
|
||||
= help: use `Display` formatting and change this to `path.display()`
|
||||
= 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
|
||||
= note: `-D clippy::unnecessary-debug-formatting` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_debug_formatting)]`
|
||||
|
||||
error: unnecessary `Debug` formatting in `println!` args
|
||||
--> tests/ui/unnecessary_path_debug_formatting.rs:34:22
|
||||
--> tests/ui/unnecessary_path_debug_formatting.rs:33:22
|
||||
|
|
||||
LL | println!("{:?}", path_buf);
|
||||
| ^^^^^^^^
|
||||
|
|
@ -19,7 +37,7 @@ LL | println!("{:?}", path_buf);
|
|||
= 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
|
||||
|
||||
error: unnecessary `Debug` formatting in `println!` args
|
||||
--> tests/ui/unnecessary_path_debug_formatting.rs:36:16
|
||||
--> tests/ui/unnecessary_path_debug_formatting.rs:35:16
|
||||
|
|
||||
LL | println!("{path:?}");
|
||||
| ^^^^
|
||||
|
|
@ -28,7 +46,7 @@ LL | println!("{path:?}");
|
|||
= 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
|
||||
|
||||
error: unnecessary `Debug` formatting in `println!` args
|
||||
--> tests/ui/unnecessary_path_debug_formatting.rs:37:16
|
||||
--> tests/ui/unnecessary_path_debug_formatting.rs:36:16
|
||||
|
|
||||
LL | println!("{path_buf:?}");
|
||||
| ^^^^^^^^
|
||||
|
|
@ -37,7 +55,7 @@ LL | println!("{path_buf:?}");
|
|||
= 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
|
||||
|
||||
error: unnecessary `Debug` formatting in `format!` args
|
||||
--> tests/ui/unnecessary_path_debug_formatting.rs:39:37
|
||||
--> tests/ui/unnecessary_path_debug_formatting.rs:38:37
|
||||
|
|
||||
LL | let _: String = format!("{:?}", path);
|
||||
| ^^^^
|
||||
|
|
@ -46,7 +64,7 @@ LL | let _: String = format!("{:?}", path);
|
|||
= 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
|
||||
|
||||
error: unnecessary `Debug` formatting in `format!` args
|
||||
--> tests/ui/unnecessary_path_debug_formatting.rs:40:37
|
||||
--> tests/ui/unnecessary_path_debug_formatting.rs:39:37
|
||||
|
|
||||
LL | let _: String = format!("{:?}", path_buf);
|
||||
| ^^^^^^^^
|
||||
|
|
@ -55,7 +73,7 @@ LL | let _: String = format!("{:?}", path_buf);
|
|||
= 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
|
||||
|
||||
error: unnecessary `Debug` formatting in `println!` args
|
||||
--> tests/ui/unnecessary_path_debug_formatting.rs:43:22
|
||||
--> tests/ui/unnecessary_path_debug_formatting.rs:42:22
|
||||
|
|
||||
LL | println!("{:?}", &*deref_path);
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
@ -63,5 +81,5 @@ LL | println!("{:?}", &*deref_path);
|
|||
= help: use `Display` formatting and change this to `&*deref_path.display()`
|
||||
= 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
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue