Skip to content

Commit fdc0153

Browse files
committedNov 6, 2019
rustup improper_ctypes: extern "C" fns
1 parent 0be213b commit fdc0153

File tree

3 files changed

+31
-30
lines changed

3 files changed

+31
-30
lines changed
 

‎tests/ui/functions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ fn bad_multiline(
3131
extern "C" fn extern_fn(
3232
_one: u32,
3333
_two: u32,
34-
_three: &str,
34+
_three: *const u8,
3535
_four: bool,
3636
_five: f32,
3737
_six: f32,
3838
_seven: bool,
39-
_eight: (),
39+
_eight: *const std::ffi::c_void,
4040
) {
4141
}
4242

‎tests/ui/needless_pass_by_value.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use std::borrow::Borrow;
1212
use std::collections::HashSet;
1313
use std::convert::AsRef;
14+
use std::mem::MaybeUninit;
1415

1516
// `v` should be warned
1617
// `w`, `x` and `y` are allowed (moved or mutated)
@@ -111,8 +112,8 @@ trait FalsePositive {
111112
}
112113

113114
// shouldn't warn on extern funcs
114-
extern "C" fn ext(x: String) -> usize {
115-
x.len()
115+
extern "C" fn ext(x: MaybeUninit<usize>) -> usize {
116+
unsafe { x.assume_init() }
116117
}
117118

118119
// whitelist RangeArgument

‎tests/ui/needless_pass_by_value.stderr

+26-26
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
11
error: this argument is passed by value, but not consumed in the function body
2-
--> $DIR/needless_pass_by_value.rs:17:23
2+
--> $DIR/needless_pass_by_value.rs:18:23
33
|
44
LL | fn foo<T: Default>(v: Vec<T>, w: Vec<T>, mut x: Vec<T>, y: Vec<T>) -> Vec<T> {
55
| ^^^^^^ help: consider changing the type to: `&[T]`
66
|
77
= note: `-D clippy::needless-pass-by-value` implied by `-D warnings`
88

99
error: this argument is passed by value, but not consumed in the function body
10-
--> $DIR/needless_pass_by_value.rs:31:11
10+
--> $DIR/needless_pass_by_value.rs:32:11
1111
|
1212
LL | fn bar(x: String, y: Wrapper) {
1313
| ^^^^^^ help: consider changing the type to: `&str`
1414

1515
error: this argument is passed by value, but not consumed in the function body
16-
--> $DIR/needless_pass_by_value.rs:31:22
16+
--> $DIR/needless_pass_by_value.rs:32:22
1717
|
1818
LL | fn bar(x: String, y: Wrapper) {
1919
| ^^^^^^^ help: consider taking a reference instead: `&Wrapper`
2020

2121
error: this argument is passed by value, but not consumed in the function body
22-
--> $DIR/needless_pass_by_value.rs:37:71
22+
--> $DIR/needless_pass_by_value.rs:38:71
2323
|
2424
LL | fn test_borrow_trait<T: Borrow<str>, U: AsRef<str>, V>(t: T, u: U, v: V) {
2525
| ^ help: consider taking a reference instead: `&V`
2626

2727
error: this argument is passed by value, but not consumed in the function body
28-
--> $DIR/needless_pass_by_value.rs:49:18
28+
--> $DIR/needless_pass_by_value.rs:50:18
2929
|
3030
LL | fn test_match(x: Option<Option<String>>, y: Option<Option<String>>) {
3131
| ^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&Option<Option<String>>`
3232

3333
error: this argument is passed by value, but not consumed in the function body
34-
--> $DIR/needless_pass_by_value.rs:62:24
34+
--> $DIR/needless_pass_by_value.rs:63:24
3535
|
3636
LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) {
3737
| ^^^^^^^ help: consider taking a reference instead: `&Wrapper`
3838

3939
error: this argument is passed by value, but not consumed in the function body
40-
--> $DIR/needless_pass_by_value.rs:62:36
40+
--> $DIR/needless_pass_by_value.rs:63:36
4141
|
4242
LL | fn test_destructure(x: Wrapper, y: Wrapper, z: Wrapper) {
4343
| ^^^^^^^ help: consider taking a reference instead: `&Wrapper`
4444

4545
error: this argument is passed by value, but not consumed in the function body
46-
--> $DIR/needless_pass_by_value.rs:78:49
46+
--> $DIR/needless_pass_by_value.rs:79:49
4747
|
4848
LL | fn test_blanket_ref<T: Foo, S: Serialize>(_foo: T, _serializable: S) {}
4949
| ^ help: consider taking a reference instead: `&T`
5050

5151
error: this argument is passed by value, but not consumed in the function body
52-
--> $DIR/needless_pass_by_value.rs:80:18
52+
--> $DIR/needless_pass_by_value.rs:81:18
5353
|
5454
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
5555
| ^^^^^^ help: consider taking a reference instead: `&String`
5656

5757
error: this argument is passed by value, but not consumed in the function body
58-
--> $DIR/needless_pass_by_value.rs:80:29
58+
--> $DIR/needless_pass_by_value.rs:81:29
5959
|
6060
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
6161
| ^^^^^^
@@ -70,13 +70,13 @@ LL | let _ = t.to_string();
7070
| ^^^^^^^^^^^^^
7171

7272
error: this argument is passed by value, but not consumed in the function body
73-
--> $DIR/needless_pass_by_value.rs:80:40
73+
--> $DIR/needless_pass_by_value.rs:81:40
7474
|
7575
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
7676
| ^^^^^^^^ help: consider taking a reference instead: `&Vec<i32>`
7777

7878
error: this argument is passed by value, but not consumed in the function body
79-
--> $DIR/needless_pass_by_value.rs:80:53
79+
--> $DIR/needless_pass_by_value.rs:81:53
8080
|
8181
LL | fn issue_2114(s: String, t: String, u: Vec<i32>, v: Vec<i32>) {
8282
| ^^^^^^^^
@@ -91,85 +91,85 @@ LL | let _ = v.to_owned();
9191
| ^^^^^^^^^^^^
9292

9393
error: this argument is passed by value, but not consumed in the function body
94-
--> $DIR/needless_pass_by_value.rs:93:12
94+
--> $DIR/needless_pass_by_value.rs:94:12
9595
|
9696
LL | s: String,
9797
| ^^^^^^ help: consider changing the type to: `&str`
9898

9999
error: this argument is passed by value, but not consumed in the function body
100-
--> $DIR/needless_pass_by_value.rs:94:12
100+
--> $DIR/needless_pass_by_value.rs:95:12
101101
|
102102
LL | t: String,
103103
| ^^^^^^ help: consider taking a reference instead: `&String`
104104

105105
error: this argument is passed by value, but not consumed in the function body
106-
--> $DIR/needless_pass_by_value.rs:103:23
106+
--> $DIR/needless_pass_by_value.rs:104:23
107107
|
108108
LL | fn baz(&self, _u: U, _s: Self) {}
109109
| ^ help: consider taking a reference instead: `&U`
110110

111111
error: this argument is passed by value, but not consumed in the function body
112-
--> $DIR/needless_pass_by_value.rs:103:30
112+
--> $DIR/needless_pass_by_value.rs:104:30
113113
|
114114
LL | fn baz(&self, _u: U, _s: Self) {}
115115
| ^^^^ help: consider taking a reference instead: `&Self`
116116

117117
error: this argument is passed by value, but not consumed in the function body
118-
--> $DIR/needless_pass_by_value.rs:125:24
118+
--> $DIR/needless_pass_by_value.rs:126:24
119119
|
120120
LL | fn bar_copy(x: u32, y: CopyWrapper) {
121121
| ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper`
122122
|
123123
help: consider marking this type as Copy
124-
--> $DIR/needless_pass_by_value.rs:123:1
124+
--> $DIR/needless_pass_by_value.rs:124:1
125125
|
126126
LL | struct CopyWrapper(u32);
127127
| ^^^^^^^^^^^^^^^^^^^^^^^^
128128

129129
error: this argument is passed by value, but not consumed in the function body
130-
--> $DIR/needless_pass_by_value.rs:131:29
130+
--> $DIR/needless_pass_by_value.rs:132:29
131131
|
132132
LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) {
133133
| ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper`
134134
|
135135
help: consider marking this type as Copy
136-
--> $DIR/needless_pass_by_value.rs:123:1
136+
--> $DIR/needless_pass_by_value.rs:124:1
137137
|
138138
LL | struct CopyWrapper(u32);
139139
| ^^^^^^^^^^^^^^^^^^^^^^^^
140140

141141
error: this argument is passed by value, but not consumed in the function body
142-
--> $DIR/needless_pass_by_value.rs:131:45
142+
--> $DIR/needless_pass_by_value.rs:132:45
143143
|
144144
LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) {
145145
| ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper`
146146
|
147147
help: consider marking this type as Copy
148-
--> $DIR/needless_pass_by_value.rs:123:1
148+
--> $DIR/needless_pass_by_value.rs:124:1
149149
|
150150
LL | struct CopyWrapper(u32);
151151
| ^^^^^^^^^^^^^^^^^^^^^^^^
152152

153153
error: this argument is passed by value, but not consumed in the function body
154-
--> $DIR/needless_pass_by_value.rs:131:61
154+
--> $DIR/needless_pass_by_value.rs:132:61
155155
|
156156
LL | fn test_destructure_copy(x: CopyWrapper, y: CopyWrapper, z: CopyWrapper) {
157157
| ^^^^^^^^^^^ help: consider taking a reference instead: `&CopyWrapper`
158158
|
159159
help: consider marking this type as Copy
160-
--> $DIR/needless_pass_by_value.rs:123:1
160+
--> $DIR/needless_pass_by_value.rs:124:1
161161
|
162162
LL | struct CopyWrapper(u32);
163163
| ^^^^^^^^^^^^^^^^^^^^^^^^
164164

165165
error: this argument is passed by value, but not consumed in the function body
166-
--> $DIR/needless_pass_by_value.rs:143:40
166+
--> $DIR/needless_pass_by_value.rs:144:40
167167
|
168168
LL | fn some_fun<'b, S: Bar<'b, ()>>(_item: S) {}
169169
| ^ help: consider taking a reference instead: `&S`
170170

171171
error: this argument is passed by value, but not consumed in the function body
172-
--> $DIR/needless_pass_by_value.rs:148:20
172+
--> $DIR/needless_pass_by_value.rs:149:20
173173
|
174174
LL | fn more_fun(_item: impl Club<'static, i32>) {}
175175
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider taking a reference instead: `&impl Club<'static, i32>`

0 commit comments

Comments
 (0)