diff options
| author | donkomura <koiru3822fs@gmail.com> | 2025-06-21 14:43:00 +0900 |
|---|---|---|
| committer | donkomura <koiru3822fs@gmail.com> | 2025-06-21 15:03:37 +0900 |
| commit | e0cb4ced0a42d137b2f85f06dd45667299863fa2 (patch) | |
| tree | a09bcc22e345a8fd21a924066dec8c5826c19d3b | |
| parent | 4ead403c9126c21343cf65c28351cb416c180367 (diff) | |
| download | rust-e0cb4ced0a42d137b2f85f06dd45667299863fa2.tar.gz rust-e0cb4ced0a42d137b2f85f06dd45667299863fa2.zip | |
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
| -rw-r--r-- | tests/ui/unnecessary_os_str_debug_formatting.rs | 13 | ||||
| -rw-r--r-- | tests/ui/unnecessary_os_str_debug_formatting.stderr | 11 |
2 files changed, 23 insertions, 1 deletions
diff --git a/tests/ui/unnecessary_os_str_debug_formatting.rs b/tests/ui/unnecessary_os_str_debug_formatting.rs index 6652efd9ae1..66590be3d05 100644 --- a/tests/ui/unnecessary_os_str_debug_formatting.rs +++ b/tests/ui/unnecessary_os_str_debug_formatting.rs @@ -21,3 +21,16 @@ fn main() { let _: String = format!("{:?}", os_str); //~ unnecessary_debug_formatting let _: String = format!("{:?}", os_string); //~ unnecessary_debug_formatting } + +#[clippy::msrv = "1.86"] +fn msrv_1_86() { + let os_str = OsStr::new("test"); + println!("{:?}", os_str); +} + +#[clippy::msrv = "1.87"] +fn msrv_1_87() { + let os_str = OsStr::new("test"); + println!("{:?}", os_str); + //~^ unnecessary_debug_formatting +} diff --git a/tests/ui/unnecessary_os_str_debug_formatting.stderr b/tests/ui/unnecessary_os_str_debug_formatting.stderr index 382e59b0461..f04d2d5bdc8 100644 --- a/tests/ui/unnecessary_os_str_debug_formatting.stderr +++ b/tests/ui/unnecessary_os_str_debug_formatting.stderr @@ -54,5 +54,14 @@ LL | let _: String = format!("{:?}", 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: aborting due to 6 previous errors +error: unnecessary `Debug` formatting in `println!` args + --> tests/ui/unnecessary_os_str_debug_formatting.rs:34: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 + +error: aborting due to 7 previous errors |
