Skip to content

Commit 044b3d9

Browse files
authored
Merge pull request #2633 from mikerite/ref_cow_tests
Move ref cow tests
2 parents 71a15bf + 2fd671e commit 044b3d9

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

tests/ui/needless_borrow.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,3 @@ fn issue_1432() {
5151

5252
let _ = v.iter().filter(|&a| a.is_empty());
5353
}
54-
55-
#[allow(dead_code)]
56-
fn test_cow_with_ref(c: &Cow<[i32]>) {
57-
}
58-
59-
#[allow(dead_code)]
60-
fn test_cow(c: Cow<[i32]>) {
61-
let _c = c;
62-
}

tests/ui/needless_borrow.stderr

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,5 @@ error: this pattern creates a reference to a reference
3838
50 | let _ = v.iter().filter(|&ref a| a.is_empty());
3939
| ^^^^^ help: change this to: `a`
4040

41-
error: using a reference to `Cow` is not recommended.
42-
--> $DIR/needless_borrow.rs:56:25
43-
|
44-
56 | fn test_cow_with_ref(c: &Cow<[i32]>) {
45-
| ^^^^^^^^^^^ help: change this to: `&[i32]`
46-
|
47-
= note: `-D ptr-arg` implied by `-D warnings`
48-
49-
error: aborting due to 7 previous errors
41+
error: aborting due to 6 previous errors
5042

tests/ui/ptr_arg.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
2-
31
#![allow(unused, many_single_char_names)]
42
#![warn(ptr_arg)]
53

4+
use std::borrow::Cow;
5+
66
fn do_vec(x: &Vec<i64>) {
77
//Nothing here
88
}
@@ -67,3 +67,11 @@ fn false_positive_capacity_too(x: &String) -> String {
6767
x.clone()
6868
}
6969

70+
#[allow(dead_code)]
71+
fn test_cow_with_ref(c: &Cow<[i32]>) {
72+
}
73+
74+
#[allow(dead_code)]
75+
fn test_cow(c: Cow<[i32]>) {
76+
let _c = c;
77+
}

tests/ui/ptr_arg.stderr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,11 @@ help: change `y.as_str()` to
7676
62 | let c = y;
7777
| ^
7878

79-
error: aborting due to 6 previous errors
79+
error: using a reference to `Cow` is not recommended.
80+
--> $DIR/ptr_arg.rs:71:25
81+
|
82+
71 | fn test_cow_with_ref(c: &Cow<[i32]>) {
83+
| ^^^^^^^^^^^ help: change this to: `&[i32]`
84+
85+
error: aborting due to 7 previous errors
8086

0 commit comments

Comments
 (0)