Skip to content

Add MSRV test for unnecessary_debug_formatting with OsStr #15001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions tests/ui/unnecessary_os_str_debug_formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
11 changes: 10 additions & 1 deletion tests/ui/unnecessary_os_str_debug_formatting.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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