Skip to content

Commit

Permalink
Update unnecessary_conversion_for_trait
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Oct 30, 2024
1 parent 81f9598 commit c81bf49
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ const WATCHED_INHERENTS: &[&[&str]] = &[
&["core", "slice", "<impl [T]>", "iter"],
&["core", "slice", "<impl [T]>", "iter_mut"],
&["core", "str", "<impl str>", "as_bytes"],
&["core", "str", "<impl str>", "as_str"],
&["std", "ffi", "os_str", "OsStr", "as_encoded_bytes"],
&["std", "ffi", "os_str", "OsStr", "into_os_string"],
&["std", "ffi", "os_str", "OsStr", "new"],
Expand Down Expand Up @@ -131,6 +132,7 @@ const IGNORED_INHERENTS: &[&[&str]] = &[
&["alloc", "string", "String", "from_utf16_lossy"],
&["alloc", "string", "String", "from_utf16be_lossy"],
&["alloc", "string", "String", "from_utf16le_lossy"],
&["alloc", "string", "String", "from_utf8_lossy_owned"],
&["alloc", "string", "String", "leak"],
&["alloc", "vec", "Vec", "into_flattened"],
&["alloc", "vec", "Vec", "leak"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// run-rustfix

#![allow(unused_imports, unused_parens)]
// #![feature(os_str_bytes)]
#![feature(str_as_str)]

use std::{
borrow::{Borrow, BorrowMut},
Expand Down Expand Up @@ -65,6 +65,7 @@ fn main() {
let _ = Command::new("ls").args(["-a", "-l"]);
let _ = Command::new("ls").args(["-a", "-l"]);

let _ = std::fs::write("x", "");
let _ = std::fs::write("x", "");

let _ = os_str_or_bytes(osstr);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// run-rustfix

#![allow(unused_imports, unused_parens)]
// #![feature(os_str_bytes)]
#![feature(str_as_str)]

use std::{
borrow::{Borrow, BorrowMut},
Expand Down Expand Up @@ -66,6 +66,7 @@ fn main() {
let _ = Command::new("ls").args(["-a", "-l"].iter_mut());

let _ = std::fs::write("x", "".as_bytes());
let _ = std::fs::write("x", "".as_str());

let _ = os_str_or_bytes(osstr.as_encoded_bytes());
let _ = is_empty_os(osstring.clone().into_boxed_os_str().into_os_string());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,112 +151,118 @@ LL | let _ = std::fs::write("x", "".as_bytes());
| ^^^^^^^^^^^ help: remove this

warning: the receiver implements the required traits
--> $DIR/general.rs:70:34
--> $DIR/general.rs:69:35
|
LL | let _ = std::fs::write("x", "".as_str());
| ^^^^^^^^^ help: remove this

warning: the receiver implements the required traits
--> $DIR/general.rs:71:34
|
LL | let _ = os_str_or_bytes(osstr.as_encoded_bytes());
| ^^^^^^^^^^^^^^^^^^^ help: remove this

warning: the receiver implements the required traits
--> $DIR/general.rs:71:41
--> $DIR/general.rs:72:41
|
LL | let _ = is_empty_os(osstring.clone().into_boxed_os_str().into_os_string());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this

warning: the inner argument implements the required traits
--> $DIR/general.rs:72:28
--> $DIR/general.rs:73:28
|
LL | let _ = std::fs::write(OsStr::new("x"), "");
| ^^^^^^^^^^^^^^^ help: use: `"x"`

warning: the receiver implements the required traits
--> $DIR/general.rs:73:33
--> $DIR/general.rs:74:33
|
LL | let _ = std::fs::write(osstr.to_os_string(), "");
| ^^^^^^^^^^^^^^^ help: remove this

warning: the receiver implements the required traits
--> $DIR/general.rs:75:28
--> $DIR/general.rs:76:28
|
LL | let _ = std::fs::write(osstring.as_os_str(), "");
| ^^^^^^^^^^^^^^^^^^^^ help: use: `&osstring`

warning: the receiver implements the required traits
--> $DIR/general.rs:76:41
--> $DIR/general.rs:77:41
|
LL | let _ = is_empty_os(osstring.clone().into_boxed_os_str());
| ^^^^^^^^^^^^^^^^^^^^ help: remove this

warning: the receiver implements the required traits
--> $DIR/general.rs:77:48
--> $DIR/general.rs:78:48
|
LL | let _ = os_string_or_bytes(osstring.clone().into_encoded_bytes());
| ^^^^^^^^^^^^^^^^^^^^^ help: remove this

warning: the receiver implements the required traits
--> $DIR/general.rs:79:46
--> $DIR/general.rs:80:46
|
LL | let _ = std::fs::write(PathBuf::from("x").as_mut_os_str(), "");
| ^^^^^^^^^^^^^^^^ help: remove this

warning: the receiver implements the required traits
--> $DIR/general.rs:80:32
--> $DIR/general.rs:81:32
|
LL | let _ = std::fs::write(path.as_os_str(), "");
| ^^^^^^^^^^^^ help: remove this

warning: the receiver implements the required traits
--> $DIR/general.rs:81:46
--> $DIR/general.rs:82:46
|
LL | let _ = std::fs::write(PathBuf::from("x").into_boxed_path().into_path_buf(), "");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this

warning: the receiver implements the required traits
--> $DIR/general.rs:82:41
--> $DIR/general.rs:83:41
|
LL | let _ = Command::new("ls").args(path.iter());
| ^^^^^^^ help: remove this

warning: the inner argument implements the required traits
--> $DIR/general.rs:83:28
--> $DIR/general.rs:84:28
|
LL | let _ = std::fs::write(Path::new("x"), "");
| ^^^^^^^^^^^^^^ help: use: `"x"`

warning: the receiver implements the required traits
--> $DIR/general.rs:84:32
--> $DIR/general.rs:85:32
|
LL | let _ = std::fs::write(path.to_path_buf(), "");
| ^^^^^^^^^^^^^^ help: remove this

warning: the receiver implements the required traits
--> $DIR/general.rs:86:28
--> $DIR/general.rs:87:28
|
LL | let _ = std::fs::write(path_buf.as_mut_os_string(), "");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `&mut path_buf`

warning: the receiver implements the required traits
--> $DIR/general.rs:87:28
--> $DIR/general.rs:88:28
|
LL | let _ = std::fs::write(path_buf.as_path(), "");
| ^^^^^^^^^^^^^^^^^^ help: use: `&path_buf`

warning: the receiver implements the required traits
--> $DIR/general.rs:88:44
--> $DIR/general.rs:89:44
|
LL | let _ = std::fs::write(path_buf.clone().into_os_string(), "");
| ^^^^^^^^^^^^^^^^^ help: remove this

warning: the receiver implements the required traits
--> $DIR/general.rs:90:28
--> $DIR/general.rs:91:28
|
LL | let _ = std::fs::write(tempdir.path(), "");
| ^^^^^^^^^^^^^^ help: use: `&tempdir`

warning: the receiver implements the required traits
--> $DIR/general.rs:91:28
--> $DIR/general.rs:92:28
|
LL | let _ = std::fs::write(tempfile.path(), "");
| ^^^^^^^^^^^^^^^ help: use: `&tempfile`

warning: 43 warnings emitted
warning: 44 warnings emitted

0 comments on commit c81bf49

Please sign in to comment.