Skip to content

Commit 85c1f74

Browse files
committed
Add explicit_auto_deref test for variadic function
1 parent 15df228 commit 85c1f74

File tree

3 files changed

+50
-32
lines changed

3 files changed

+50
-32
lines changed

tests/ui/explicit_auto_deref.fixed

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ fn f_str_t<T>(_: &str, _: T) {}
5959

6060
fn f_box_t<T>(_: &Box<T>) {}
6161

62+
extern "C" {
63+
fn var(_: u32, ...);
64+
}
65+
6266
fn main() {
6367
let s = String::new();
6468

@@ -202,4 +206,9 @@ fn main() {
202206

203207
f_str(&&ref_str); // `needless_borrow` will suggest removing both references
204208
f_str(&ref_str); // `needless_borrow` will suggest removing only one reference
209+
210+
let x = &&40;
211+
unsafe {
212+
var(0, &**x);
213+
}
205214
}

tests/ui/explicit_auto_deref.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ fn f_str_t<T>(_: &str, _: T) {}
5959

6060
fn f_box_t<T>(_: &Box<T>) {}
6161

62+
extern "C" {
63+
fn var(_: u32, ...);
64+
}
65+
6266
fn main() {
6367
let s = String::new();
6468

@@ -202,4 +206,9 @@ fn main() {
202206

203207
f_str(&&*ref_str); // `needless_borrow` will suggest removing both references
204208
f_str(&&**ref_str); // `needless_borrow` will suggest removing only one reference
209+
210+
let x = &&40;
211+
unsafe {
212+
var(0, &**x);
213+
}
205214
}

tests/ui/explicit_auto_deref.stderr

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,193 +1,193 @@
11
error: deref which would be done by auto-deref
2-
--> $DIR/explicit_auto_deref.rs:65:20
2+
--> $DIR/explicit_auto_deref.rs:69:20
33
|
44
LL | let _: &str = &*s;
55
| ^^ help: try this: `s`
66
|
77
= note: `-D clippy::explicit-auto-deref` implied by `-D warnings`
88

99
error: deref which would be done by auto-deref
10-
--> $DIR/explicit_auto_deref.rs:69:12
10+
--> $DIR/explicit_auto_deref.rs:73:12
1111
|
1212
LL | f_str(&*s);
1313
| ^^ help: try this: `s`
1414

1515
error: deref which would be done by auto-deref
16-
--> $DIR/explicit_auto_deref.rs:73:14
16+
--> $DIR/explicit_auto_deref.rs:77:14
1717
|
1818
LL | f_str_t(&*s, &*s); // Don't lint second param.
1919
| ^^ help: try this: `s`
2020

2121
error: deref which would be done by auto-deref
22-
--> $DIR/explicit_auto_deref.rs:76:25
22+
--> $DIR/explicit_auto_deref.rs:80:25
2323
|
2424
LL | let _: &Box<i32> = &**b;
2525
| ^^^ help: try this: `b`
2626

2727
error: deref which would be done by auto-deref
28-
--> $DIR/explicit_auto_deref.rs:82:8
28+
--> $DIR/explicit_auto_deref.rs:86:8
2929
|
3030
LL | c(&*s);
3131
| ^^ help: try this: `s`
3232

3333
error: deref which would be done by auto-deref
34-
--> $DIR/explicit_auto_deref.rs:88:9
34+
--> $DIR/explicit_auto_deref.rs:92:9
3535
|
3636
LL | &**x
3737
| ^^^^ help: try this: `x`
3838

3939
error: deref which would be done by auto-deref
40-
--> $DIR/explicit_auto_deref.rs:92:11
40+
--> $DIR/explicit_auto_deref.rs:96:11
4141
|
4242
LL | { &**x }
4343
| ^^^^ help: try this: `x`
4444

4545
error: deref which would be done by auto-deref
46-
--> $DIR/explicit_auto_deref.rs:96:9
46+
--> $DIR/explicit_auto_deref.rs:100:9
4747
|
4848
LL | &**{ x }
4949
| ^^^^^^^^ help: try this: `{ x }`
5050

5151
error: deref which would be done by auto-deref
52-
--> $DIR/explicit_auto_deref.rs:100:9
52+
--> $DIR/explicit_auto_deref.rs:104:9
5353
|
5454
LL | &***x
5555
| ^^^^^ help: try this: `x`
5656

5757
error: deref which would be done by auto-deref
58-
--> $DIR/explicit_auto_deref.rs:117:13
58+
--> $DIR/explicit_auto_deref.rs:121:13
5959
|
6060
LL | f1(&*x);
6161
| ^^ help: try this: `x`
6262

6363
error: deref which would be done by auto-deref
64-
--> $DIR/explicit_auto_deref.rs:118:13
64+
--> $DIR/explicit_auto_deref.rs:122:13
6565
|
6666
LL | f2(&*x);
6767
| ^^ help: try this: `x`
6868

6969
error: deref which would be done by auto-deref
70-
--> $DIR/explicit_auto_deref.rs:119:13
70+
--> $DIR/explicit_auto_deref.rs:123:13
7171
|
7272
LL | f3(&*x);
7373
| ^^ help: try this: `x`
7474

7575
error: deref which would be done by auto-deref
76-
--> $DIR/explicit_auto_deref.rs:120:28
76+
--> $DIR/explicit_auto_deref.rs:124:28
7777
|
7878
LL | f4.callable_str()(&*x);
7979
| ^^ help: try this: `x`
8080

8181
error: deref which would be done by auto-deref
82-
--> $DIR/explicit_auto_deref.rs:121:13
82+
--> $DIR/explicit_auto_deref.rs:125:13
8383
|
8484
LL | f5(&*x);
8585
| ^^ help: try this: `x`
8686

8787
error: deref which would be done by auto-deref
88-
--> $DIR/explicit_auto_deref.rs:122:13
88+
--> $DIR/explicit_auto_deref.rs:126:13
8989
|
9090
LL | f6(&*x);
9191
| ^^ help: try this: `x`
9292

9393
error: deref which would be done by auto-deref
94-
--> $DIR/explicit_auto_deref.rs:123:28
94+
--> $DIR/explicit_auto_deref.rs:127:28
9595
|
9696
LL | f7.callable_str()(&*x);
9797
| ^^ help: try this: `x`
9898

9999
error: deref which would be done by auto-deref
100-
--> $DIR/explicit_auto_deref.rs:124:26
100+
--> $DIR/explicit_auto_deref.rs:128:26
101101
|
102102
LL | f8.callable_t()(&*x);
103103
| ^^ help: try this: `x`
104104

105105
error: deref which would be done by auto-deref
106-
--> $DIR/explicit_auto_deref.rs:125:13
106+
--> $DIR/explicit_auto_deref.rs:129:13
107107
|
108108
LL | f9(&*x);
109109
| ^^ help: try this: `x`
110110

111111
error: deref which would be done by auto-deref
112-
--> $DIR/explicit_auto_deref.rs:126:14
112+
--> $DIR/explicit_auto_deref.rs:130:14
113113
|
114114
LL | f10(&*x);
115115
| ^^ help: try this: `x`
116116

117117
error: deref which would be done by auto-deref
118-
--> $DIR/explicit_auto_deref.rs:127:27
118+
--> $DIR/explicit_auto_deref.rs:131:27
119119
|
120120
LL | f11.callable_t()(&*x);
121121
| ^^ help: try this: `x`
122122

123123
error: deref which would be done by auto-deref
124-
--> $DIR/explicit_auto_deref.rs:131:17
124+
--> $DIR/explicit_auto_deref.rs:135:17
125125
|
126126
LL | let _ = S1(&*s);
127127
| ^^ help: try this: `s`
128128

129129
error: deref which would be done by auto-deref
130-
--> $DIR/explicit_auto_deref.rs:136:22
130+
--> $DIR/explicit_auto_deref.rs:140:22
131131
|
132132
LL | let _ = S2 { s: &*s };
133133
| ^^ help: try this: `s`
134134

135135
error: deref which would be done by auto-deref
136-
--> $DIR/explicit_auto_deref.rs:152:30
136+
--> $DIR/explicit_auto_deref.rs:156:30
137137
|
138138
LL | let _ = Self::S1(&**s);
139139
| ^^^^ help: try this: `s`
140140

141141
error: deref which would be done by auto-deref
142-
--> $DIR/explicit_auto_deref.rs:153:35
142+
--> $DIR/explicit_auto_deref.rs:157:35
143143
|
144144
LL | let _ = Self::S2 { s: &**s };
145145
| ^^^^ help: try this: `s`
146146

147147
error: deref which would be done by auto-deref
148-
--> $DIR/explicit_auto_deref.rs:156:21
148+
--> $DIR/explicit_auto_deref.rs:160:21
149149
|
150150
LL | let _ = E1::S1(&*s);
151151
| ^^ help: try this: `s`
152152

153153
error: deref which would be done by auto-deref
154-
--> $DIR/explicit_auto_deref.rs:157:26
154+
--> $DIR/explicit_auto_deref.rs:161:26
155155
|
156156
LL | let _ = E1::S2 { s: &*s };
157157
| ^^ help: try this: `s`
158158

159159
error: deref which would be done by auto-deref
160-
--> $DIR/explicit_auto_deref.rs:175:13
160+
--> $DIR/explicit_auto_deref.rs:179:13
161161
|
162162
LL | let _ = (*b).foo;
163163
| ^^^^ help: try this: `b`
164164

165165
error: deref which would be done by auto-deref
166-
--> $DIR/explicit_auto_deref.rs:176:13
166+
--> $DIR/explicit_auto_deref.rs:180:13
167167
|
168168
LL | let _ = (**b).foo;
169169
| ^^^^^ help: try this: `b`
170170

171171
error: deref which would be done by auto-deref
172-
--> $DIR/explicit_auto_deref.rs:191:19
172+
--> $DIR/explicit_auto_deref.rs:195:19
173173
|
174174
LL | let _ = f_str(*ref_str);
175175
| ^^^^^^^^ help: try this: `ref_str`
176176

177177
error: deref which would be done by auto-deref
178-
--> $DIR/explicit_auto_deref.rs:193:19
178+
--> $DIR/explicit_auto_deref.rs:197:19
179179
|
180180
LL | let _ = f_str(**ref_ref_str);
181181
| ^^^^^^^^^^^^^ help: try this: `ref_ref_str`
182182

183183
error: deref which would be done by auto-deref
184-
--> $DIR/explicit_auto_deref.rs:203:13
184+
--> $DIR/explicit_auto_deref.rs:207:13
185185
|
186186
LL | f_str(&&*ref_str); // `needless_borrow` will suggest removing both references
187187
| ^^^^^^^^ help: try this: `ref_str`
188188

189189
error: deref which would be done by auto-deref
190-
--> $DIR/explicit_auto_deref.rs:204:12
190+
--> $DIR/explicit_auto_deref.rs:208:12
191191
|
192192
LL | f_str(&&**ref_str); // `needless_borrow` will suggest removing only one reference
193193
| ^^^^^^^^^^ help: try this: `ref_str`

0 commit comments

Comments
 (0)