Skip to content

Commit 7560db2

Browse files
Extend clippy shadow.rs test
1 parent dde5d95 commit 7560db2

2 files changed

Lines changed: 88 additions & 1 deletion

File tree

‎src/tools/clippy/tests/ui/shadow.rs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,19 @@ fn issue14377() {
177177
S { c, d } = S { c: 1, d: 2 };
178178
}
179179

180+
fn plain_same(x: u8) { let x = x; }
181+
//~^ shadow_same
182+
fn tuple_same((x,): (u8,)) { let x = x; }
183+
//~^ shadow_same
184+
185+
fn plain_reuse(x: u8) { let x = x + 1; }
186+
//~^ shadow_reuse
187+
fn tuple_reuse((x,): (u8,)) { let x = x + 1; }
188+
//~^ shadow_reuse
189+
190+
fn plain_unrelated(x: u8) { let x = 1u8; }
191+
//~^ shadow_unrelated
192+
fn tuple_unrelated((x,): (u8,)) { let x = 1u8; }
193+
//~^ shadow_unrelated
194+
180195
fn main() {}

‎src/tools/clippy/tests/ui/shadow.stderr‎

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,5 +316,77 @@ note: previous binding is here
316316
LL | fn issue13795(value: Issue13795) {
317317
| ^^^^^
318318

319-
error: aborting due to 26 previous errors
319+
error: `x` is shadowed by itself in `x`
320+
--> tests/ui/shadow.rs:180:28
321+
|
322+
LL | fn plain_same(x: u8) { let x = x; }
323+
| ^
324+
|
325+
note: previous binding is here
326+
--> tests/ui/shadow.rs:180:15
327+
|
328+
LL | fn plain_same(x: u8) { let x = x; }
329+
| ^
330+
331+
error: `x` is shadowed by itself in `x`
332+
--> tests/ui/shadow.rs:182:34
333+
|
334+
LL | fn tuple_same((x,): (u8,)) { let x = x; }
335+
| ^
336+
|
337+
note: previous binding is here
338+
--> tests/ui/shadow.rs:182:16
339+
|
340+
LL | fn tuple_same((x,): (u8,)) { let x = x; }
341+
| ^
342+
343+
error: `x` is shadowed
344+
--> tests/ui/shadow.rs:185:29
345+
|
346+
LL | fn plain_reuse(x: u8) { let x = x + 1; }
347+
| ^
348+
|
349+
note: previous binding is here
350+
--> tests/ui/shadow.rs:185:16
351+
|
352+
LL | fn plain_reuse(x: u8) { let x = x + 1; }
353+
| ^
354+
355+
error: `x` is shadowed
356+
--> tests/ui/shadow.rs:187:35
357+
|
358+
LL | fn tuple_reuse((x,): (u8,)) { let x = x + 1; }
359+
| ^
360+
|
361+
note: previous binding is here
362+
--> tests/ui/shadow.rs:187:17
363+
|
364+
LL | fn tuple_reuse((x,): (u8,)) { let x = x + 1; }
365+
| ^
366+
367+
error: `x` shadows a previous, unrelated binding
368+
--> tests/ui/shadow.rs:190:33
369+
|
370+
LL | fn plain_unrelated(x: u8) { let x = 1u8; }
371+
| ^
372+
|
373+
note: previous binding is here
374+
--> tests/ui/shadow.rs:190:20
375+
|
376+
LL | fn plain_unrelated(x: u8) { let x = 1u8; }
377+
| ^
378+
379+
error: `x` shadows a previous, unrelated binding
380+
--> tests/ui/shadow.rs:192:39
381+
|
382+
LL | fn tuple_unrelated((x,): (u8,)) { let x = 1u8; }
383+
| ^
384+
|
385+
note: previous binding is here
386+
--> tests/ui/shadow.rs:192:21
387+
|
388+
LL | fn tuple_unrelated((x,): (u8,)) { let x = 1u8; }
389+
| ^
390+
391+
error: aborting due to 32 previous errors
320392

0 commit comments

Comments
 (0)