Skip to content

Commit 370fbcc

Browse files
committed
or-patterns: #47390: we rely on names to exercise IndexMap.
1 parent 05cc3c0 commit 370fbcc

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ fn main() {
3333
let mut mut_unused_var = 1;
3434

3535
let (mut var, unused_var) = (1, 2);
36+
// NOTE: `var` comes after `unused_var` lexicographically yet the warning
37+
// for `var` will be emitted before the one for `unused_var`. We use an
38+
// `IndexMap` to ensure this is the case instead of a `BTreeMap`.
3639

3740
if let SoulHistory { corridors_of_light,
3841
mut hours_are_suns,

src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.stderr

+10-10
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@ LL | let (mut var, unused_var) = (1, 2);
3030
| ^^^^^^^^^^ help: consider prefixing with an underscore: `_unused_var`
3131

3232
warning: unused variable: `corridors_of_light`
33-
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:37:26
33+
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:40:26
3434
|
3535
LL | if let SoulHistory { corridors_of_light,
3636
| ^^^^^^^^^^^^^^^^^^ help: try ignoring the field: `corridors_of_light: _`
3737

3838
warning: variable `hours_are_suns` is assigned to, but never used
39-
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:38:30
39+
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:41:30
4040
|
4141
LL | mut hours_are_suns,
4242
| ^^^^^^^^^^^^^^
4343
|
4444
= note: consider using `_hours_are_suns` instead
4545

4646
warning: value assigned to `hours_are_suns` is never read
47-
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:40:9
47+
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:43:9
4848
|
4949
LL | hours_are_suns = false;
5050
| ^^^^^^^^^^^^^^
@@ -58,43 +58,43 @@ LL | #![warn(unused)] // UI tests pass `-A unused` (#43896)
5858
= help: maybe it is overwritten before being read?
5959

6060
warning: unused variable: `fire`
61-
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:44:32
61+
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:47:32
6262
|
6363
LL | let LovelyAmbition { lips, fire } = the_spirit;
6464
| ^^^^ help: try ignoring the field: `fire: _`
6565

6666
warning: unused variable: `case`
67-
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:53:23
67+
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:56:23
6868
|
6969
LL | Large::Suit { case } => {}
7070
| ^^^^ help: try ignoring the field: `case: _`
7171

7272
warning: unused variable: `case`
73-
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:58:24
73+
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:61:24
7474
|
7575
LL | &Large::Suit { case } => {}
7676
| ^^^^ help: try ignoring the field: `case: _`
7777

7878
warning: unused variable: `case`
79-
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:63:27
79+
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:66:27
8080
|
8181
LL | box Large::Suit { case } => {}
8282
| ^^^^ help: try ignoring the field: `case: _`
8383

8484
warning: unused variable: `case`
85-
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:68:24
85+
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:71:24
8686
|
8787
LL | (Large::Suit { case },) => {}
8888
| ^^^^ help: try ignoring the field: `case: _`
8989

9090
warning: unused variable: `case`
91-
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:73:24
91+
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:76:24
9292
|
9393
LL | [Large::Suit { case }] => {}
9494
| ^^^^ help: try ignoring the field: `case: _`
9595

9696
warning: unused variable: `case`
97-
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:78:29
97+
--> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:81:29
9898
|
9999
LL | Tuple(Large::Suit { case }, ()) => {}
100100
| ^^^^ help: try ignoring the field: `case: _`

0 commit comments

Comments
 (0)