Skip to content

Commit 111ecc5

Browse files
committed
Update ui tests for warning on colliding aliases
1 parent edd6fe9 commit 111ecc5

File tree

4 files changed

+107
-87
lines changed

4 files changed

+107
-87
lines changed

test_suite/tests/ui/conflict/alias-enum.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,6 @@ enum E3 {
7676
b,
7777
}
7878

79-
fn main() {}
79+
fn main() {
80+
@//fail
81+
}
+64-56
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,79 @@
1-
error: alias `b` conflicts with deserialization name of other field
2-
--> tests/ui/conflict/alias-enum.rs:8:9
1+
error: expected expression, found `@`
2+
--> tests/ui/conflict/alias-enum.rs:80:5
33
|
4-
8 | / /// Expected error on "alias b", because this is a name of other field
5-
9 | | /// Error on "alias a" is not expected because this is a name of this field
6-
10 | | /// Error on "alias c" is not expected because field `c` is skipped
7-
11 | | #[serde(alias = "a", alias = "b", alias = "c")]
8-
12 | | a: (),
9-
| |_____________^
4+
80 | @//fail
5+
| ^ expected expression
106

11-
error: alias `c` already used by field a
12-
--> tests/ui/conflict/alias-enum.rs:14:9
7+
warning: unreachable pattern
8+
--> tests/ui/conflict/alias-enum.rs:16:9
139
|
14-
14 | / /// Expected error on "alias c", because it is already used as alias of `a`
15-
15 | | #[serde(alias = "c")]
16-
16 | | b: (),
17-
| |_____________^
10+
11 | #[serde(alias = "a", alias = "b", alias = "c")]
11+
| --- matches all the relevant values
12+
...
13+
16 | b: (),
14+
| ^ no value can reach this
15+
|
16+
= note: `#[warn(unreachable_patterns)]` on by default
17+
18+
warning: unreachable pattern
19+
--> tests/ui/conflict/alias-enum.rs:15:25
20+
|
21+
11 | #[serde(alias = "a", alias = "b", alias = "c")]
22+
| --- matches all the relevant values
23+
...
24+
15 | #[serde(alias = "c")]
25+
| ^^^ no value can reach this
1826

19-
error: alias `c` conflicts with deserialization name of other field
20-
--> tests/ui/conflict/alias-enum.rs:23:9
27+
warning: unreachable pattern
28+
--> tests/ui/conflict/alias-enum.rs:28:26
2129
|
22-
23 | / /// Expected error on "alias c", because this is a name of other field after
23-
24 | | /// applying rename rules
24-
25 | | #[serde(alias = "b", alias = "c")]
25-
26 | | a: (),
26-
| |_____________^
30+
25 | #[serde(alias = "b", alias = "c")]
31+
| --- matches all the relevant values
32+
...
33+
28 | #[serde(rename = "c")]
34+
| ^^^ no value can reach this
2735

28-
error: alias `B` conflicts with deserialization name of other field
29-
--> tests/ui/conflict/alias-enum.rs:34:9
36+
warning: unreachable pattern
37+
--> tests/ui/conflict/alias-enum.rs:38:9
3038
|
31-
34 | / /// Expected error on "alias B", because this is a name of field after
32-
35 | | /// applying rename rules
33-
36 | | #[serde(alias = "B", alias = "c")]
34-
37 | | a: (),
35-
| |_____________^
39+
36 | #[serde(alias = "B", alias = "c")]
40+
| --- matches all the relevant values
41+
37 | a: (),
42+
38 | b: (),
43+
| ^ no value can reach this
3644

37-
error: alias `b` conflicts with deserialization name of other variant
38-
--> tests/ui/conflict/alias-enum.rs:44:5
45+
warning: unreachable pattern
46+
--> tests/ui/conflict/alias-enum.rs:52:5
3947
|
40-
44 | / /// Expected error on "alias b", because this is a name of other variant
41-
45 | | /// Error on "alias a" is not expected because this is a name of this variant
42-
46 | | /// Error on "alias c" is not expected because variant `c` is skipped
43-
47 | | #[serde(alias = "a", alias = "b", alias = "c")]
44-
48 | | a,
45-
| |_____^
48+
47 | #[serde(alias = "a", alias = "b", alias = "c")]
49+
| --- matches all the relevant values
50+
...
51+
52 | b,
52+
| ^ no value can reach this
4653

47-
error: alias `c` already used by variant a
48-
--> tests/ui/conflict/alias-enum.rs:50:5
54+
warning: unreachable pattern
55+
--> tests/ui/conflict/alias-enum.rs:51:21
4956
|
50-
50 | / /// Expected error on "alias c", because it is already used as alias of `a`
51-
51 | | #[serde(alias = "c")]
52-
52 | | b,
53-
| |_____^
57+
47 | #[serde(alias = "a", alias = "b", alias = "c")]
58+
| --- matches all the relevant values
59+
...
60+
51 | #[serde(alias = "c")]
61+
| ^^^ no value can reach this
5462

55-
error: alias `c` conflicts with deserialization name of other variant
56-
--> tests/ui/conflict/alias-enum.rs:60:5
63+
warning: unreachable pattern
64+
--> tests/ui/conflict/alias-enum.rs:65:22
5765
|
58-
60 | / /// Expected error on "alias c", because this is a name of other variant after
59-
61 | | /// applying rename rules
60-
62 | | #[serde(alias = "b", alias = "c")]
61-
63 | | a,
62-
| |_____^
66+
62 | #[serde(alias = "b", alias = "c")]
67+
| --- matches all the relevant values
68+
...
69+
65 | #[serde(rename = "c")]
70+
| ^^^ no value can reach this
6371

64-
error: alias `B` conflicts with deserialization name of other variant
65-
--> tests/ui/conflict/alias-enum.rs:72:5
72+
warning: unreachable pattern
73+
--> tests/ui/conflict/alias-enum.rs:76:5
6674
|
67-
72 | / /// Expected error on "alias B", because this is a name of variant after
68-
73 | | /// applying rename rules
69-
74 | | #[serde(alias = "B", alias = "c")]
70-
75 | | a,
71-
| |_____^
75+
74 | #[serde(alias = "B", alias = "c")]
76+
| --- matches all the relevant values
77+
75 | a,
78+
76 | b,
79+
| ^ no value can reach this

test_suite/tests/ui/conflict/alias.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,6 @@ struct S3 {
3737
b: (),
3838
}
3939

40-
fn main() {}
40+
fn main() {
41+
@//fail
42+
}
+37-29
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,43 @@
1-
error: alias `b` conflicts with deserialization name of other field
2-
--> tests/ui/conflict/alias.rs:5:5
3-
|
4-
5 | / /// Expected error on "alias b", because this is a name of other field
5-
6 | | /// Error on "alias a" is not expected because this is a name of this field
6-
7 | | /// Error on "alias c" is not expected because field `c` is skipped
7-
8 | | #[serde(alias = "a", alias = "b", alias = "c")]
8-
9 | | a: (),
9-
| |_________^
1+
error: expected expression, found `@`
2+
--> tests/ui/conflict/alias.rs:41:5
3+
|
4+
41 | @//fail
5+
| ^ expected expression
6+
7+
warning: unreachable pattern
8+
--> tests/ui/conflict/alias.rs:13:5
9+
|
10+
8 | #[serde(alias = "a", alias = "b", alias = "c")]
11+
| --- matches all the relevant values
12+
...
13+
13 | b: (),
14+
| ^ no value can reach this
15+
|
16+
= note: `#[warn(unreachable_patterns)]` on by default
1017

11-
error: alias `c` already used by field a
12-
--> tests/ui/conflict/alias.rs:11:5
18+
warning: unreachable pattern
19+
--> tests/ui/conflict/alias.rs:12:21
1320
|
14-
11 | / /// Expected error on "alias c", because it is already used as alias of `a`
15-
12 | | #[serde(alias = "c")]
16-
13 | | b: (),
17-
| |_________^
21+
8 | #[serde(alias = "a", alias = "b", alias = "c")]
22+
| --- matches all the relevant values
23+
...
24+
12 | #[serde(alias = "c")]
25+
| ^^^ no value can reach this
1826

19-
error: alias `c` conflicts with deserialization name of other field
20-
--> tests/ui/conflict/alias.rs:21:5
27+
warning: unreachable pattern
28+
--> tests/ui/conflict/alias.rs:26:22
2129
|
22-
21 | / /// Expected error on "alias c", because this is a name of other field after
23-
22 | | /// applying rename rules
24-
23 | | #[serde(alias = "b", alias = "c")]
25-
24 | | a: (),
26-
| |_________^
30+
23 | #[serde(alias = "b", alias = "c")]
31+
| --- matches all the relevant values
32+
...
33+
26 | #[serde(rename = "c")]
34+
| ^^^ no value can reach this
2735

28-
error: alias `B` conflicts with deserialization name of other field
29-
--> tests/ui/conflict/alias.rs:33:5
36+
warning: unreachable pattern
37+
--> tests/ui/conflict/alias.rs:37:5
3038
|
31-
33 | / /// Expected error on "alias B", because this is a name of field after
32-
34 | | /// applying rename rules
33-
35 | | #[serde(alias = "B", alias = "c")]
34-
36 | | a: (),
35-
| |_________^
39+
35 | #[serde(alias = "B", alias = "c")]
40+
| --- matches all the relevant values
41+
36 | a: (),
42+
37 | b: (),
43+
| ^ no value can reach this

0 commit comments

Comments
 (0)