Skip to content

Commit 8ad8663

Browse files
committed
rm useless pathbuf check from unnecessary_to_owned_check
1 parent 9ae3fcb commit 8ad8663

File tree

3 files changed

+17
-33
lines changed

3 files changed

+17
-33
lines changed

tests/ui/unnecessary_to_owned.fixed

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,6 @@ fn main() {
219219
//~^ redundant_clone
220220
require_os_str(&OsString::from("x"));
221221
//~^ redundant_clone
222-
require_path(&std::path::PathBuf::from("x"));
223-
//~^ redundant_clone
224222
require_str(&String::from("x"));
225223
//~^ redundant_clone
226224
require_slice(&[String::from("x")]);

tests/ui/unnecessary_to_owned.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,6 @@ fn main() {
219219
//~^ redundant_clone
220220
require_os_str(&OsString::from("x").to_os_string());
221221
//~^ redundant_clone
222-
require_path(&std::path::PathBuf::from("x").to_path_buf());
223-
//~^ redundant_clone
224222
require_str(&String::from("x").to_string());
225223
//~^ redundant_clone
226224
require_slice(&[String::from("x")].to_owned());

tests/ui/unnecessary_to_owned.stderr

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,37 +25,25 @@ LL | require_os_str(&OsString::from("x").to_os_string());
2525
| ^^^^^^^^^^^^^^^^^^^
2626

2727
error: redundant clone
28-
--> tests/ui/unnecessary_to_owned.rs:222:48
29-
|
30-
LL | require_path(&std::path::PathBuf::from("x").to_path_buf());
31-
| ^^^^^^^^^^^^^^ help: remove this
32-
|
33-
note: this value is dropped without further use
34-
--> tests/ui/unnecessary_to_owned.rs:222:19
35-
|
36-
LL | require_path(&std::path::PathBuf::from("x").to_path_buf());
37-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38-
39-
error: redundant clone
40-
--> tests/ui/unnecessary_to_owned.rs:224:35
28+
--> tests/ui/unnecessary_to_owned.rs:222:35
4129
|
4230
LL | require_str(&String::from("x").to_string());
4331
| ^^^^^^^^^^^^ help: remove this
4432
|
4533
note: this value is dropped without further use
46-
--> tests/ui/unnecessary_to_owned.rs:224:18
34+
--> tests/ui/unnecessary_to_owned.rs:222:18
4735
|
4836
LL | require_str(&String::from("x").to_string());
4937
| ^^^^^^^^^^^^^^^^^
5038

5139
error: redundant clone
52-
--> tests/ui/unnecessary_to_owned.rs:226:39
40+
--> tests/ui/unnecessary_to_owned.rs:224:39
5341
|
5442
LL | require_slice(&[String::from("x")].to_owned());
5543
| ^^^^^^^^^^^ help: remove this
5644
|
5745
note: this value is dropped without further use
58-
--> tests/ui/unnecessary_to_owned.rs:226:20
46+
--> tests/ui/unnecessary_to_owned.rs:224:20
5947
|
6048
LL | require_slice(&[String::from("x")].to_owned());
6149
| ^^^^^^^^^^^^^^^^^^^
@@ -454,7 +442,7 @@ LL | let _ = IntoIterator::into_iter(slice.to_owned());
454442
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `slice.iter().copied()`
455443

456444
error: allocating a new `String` only to create a temporary `&str` from it
457-
--> tests/ui/unnecessary_to_owned.rs:230:26
445+
--> tests/ui/unnecessary_to_owned.rs:228:26
458446
|
459447
LL | let _ref_str: &str = &String::from_utf8(slice.to_vec()).expect("not UTF-8");
460448
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -466,7 +454,7 @@ LL + let _ref_str: &str = core::str::from_utf8(&slice).expect("not UTF-8");
466454
|
467455

468456
error: allocating a new `String` only to create a temporary `&str` from it
469-
--> tests/ui/unnecessary_to_owned.rs:232:26
457+
--> tests/ui/unnecessary_to_owned.rs:230:26
470458
|
471459
LL | let _ref_str: &str = &String::from_utf8(b"foo".to_vec()).unwrap();
472460
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -478,7 +466,7 @@ LL + let _ref_str: &str = core::str::from_utf8(b"foo").unwrap();
478466
|
479467

480468
error: allocating a new `String` only to create a temporary `&str` from it
481-
--> tests/ui/unnecessary_to_owned.rs:234:26
469+
--> tests/ui/unnecessary_to_owned.rs:232:26
482470
|
483471
LL | let _ref_str: &str = &String::from_utf8(b"foo".as_slice().to_owned()).unwrap();
484472
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -490,7 +478,7 @@ LL + let _ref_str: &str = core::str::from_utf8(b"foo".as_slice()).unwrap();
490478
|
491479

492480
error: unnecessary use of `to_vec`
493-
--> tests/ui/unnecessary_to_owned.rs:292:14
481+
--> tests/ui/unnecessary_to_owned.rs:290:14
494482
|
495483
LL | for t in file_types.to_vec() {
496484
| ^^^^^^^^^^^^^^^^^^^
@@ -503,52 +491,52 @@ LL ~ let path = match get_file_path(t) {
503491
|
504492

505493
error: unnecessary use of `to_string`
506-
--> tests/ui/unnecessary_to_owned.rs:358:24
494+
--> tests/ui/unnecessary_to_owned.rs:356:24
507495
|
508496
LL | Box::new(build(y.to_string()))
509497
| ^^^^^^^^^^^^^ help: use: `y`
510498

511499
error: unnecessary use of `to_string`
512-
--> tests/ui/unnecessary_to_owned.rs:468:12
500+
--> tests/ui/unnecessary_to_owned.rs:466:12
513501
|
514502
LL | id("abc".to_string())
515503
| ^^^^^^^^^^^^^^^^^ help: use: `"abc"`
516504

517505
error: unnecessary use of `to_vec`
518-
--> tests/ui/unnecessary_to_owned.rs:612:37
506+
--> tests/ui/unnecessary_to_owned.rs:610:37
519507
|
520508
LL | IntoFuture::into_future(foo([].to_vec(), &0));
521509
| ^^^^^^^^^^^ help: use: `[]`
522510

523511
error: unnecessary use of `to_vec`
524-
--> tests/ui/unnecessary_to_owned.rs:623:18
512+
--> tests/ui/unnecessary_to_owned.rs:621:18
525513
|
526514
LL | s.remove(&a.to_vec());
527515
| ^^^^^^^^^^^ help: replace it with: `a`
528516

529517
error: unnecessary use of `to_owned`
530-
--> tests/ui/unnecessary_to_owned.rs:628:14
518+
--> tests/ui/unnecessary_to_owned.rs:626:14
531519
|
532520
LL | s.remove(&"b".to_owned());
533521
| ^^^^^^^^^^^^^^^ help: replace it with: `"b"`
534522

535523
error: unnecessary use of `to_string`
536-
--> tests/ui/unnecessary_to_owned.rs:630:14
524+
--> tests/ui/unnecessary_to_owned.rs:628:14
537525
|
538526
LL | s.remove(&"b".to_string());
539527
| ^^^^^^^^^^^^^^^^ help: replace it with: `"b"`
540528

541529
error: unnecessary use of `to_vec`
542-
--> tests/ui/unnecessary_to_owned.rs:636:14
530+
--> tests/ui/unnecessary_to_owned.rs:634:14
543531
|
544532
LL | s.remove(&["b"].to_vec());
545533
| ^^^^^^^^^^^^^^^ help: replace it with: `["b"].as_slice()`
546534

547535
error: unnecessary use of `to_vec`
548-
--> tests/ui/unnecessary_to_owned.rs:638:14
536+
--> tests/ui/unnecessary_to_owned.rs:636:14
549537
|
550538
LL | s.remove(&(&["b"]).to_vec());
551539
| ^^^^^^^^^^^^^^^^^^ help: replace it with: `(&["b"]).as_slice()`
552540

553-
error: aborting due to 82 previous errors
541+
error: aborting due to 81 previous errors
554542

0 commit comments

Comments
 (0)