Skip to content

Commit a12c9cf

Browse files
committed
Update UI test
1 parent bd57b85 commit a12c9cf

File tree

2 files changed

+52
-62
lines changed

2 files changed

+52
-62
lines changed

tests/ui/deriving/deriving-from-wrong-target.rs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,27 @@
55
#![allow(dead_code)]
66

77
#[derive(From)]
8+
//~^ ERROR `#[derive(From)]` used on a struct with no fields
89
struct S1;
9-
//~^ ERROR `#[derive(From)]` can only be used on structs with a single field
1010

1111
#[derive(From)]
12+
//~^ ERROR `#[derive(From)]` used on a struct with no fields
1213
struct S2 {}
13-
//~^ ERROR `#[derive(From)]` can only be used on structs with a single field
1414

1515
#[derive(From)]
16+
//~^ ERROR `#[derive(From)]` used on a struct with multiple fields
1617
struct S3(u32, bool);
17-
//~^ ERROR `#[derive(From)]` can only be used on structs with a single field
1818

1919
#[derive(From)]
20-
//~v ERROR `#[derive(From)]` can only be used on structs with a single field
20+
//~^ ERROR `#[derive(From)]` used on a struct with multiple fields
2121
struct S4 {
2222
a: u32,
2323
b: bool,
2424
}
2525

2626
#[derive(From)]
27+
//~^ ERROR `#[derive(From)]` used on an enum
2728
enum E1 {}
28-
//~^ ERROR `#[derive(From)]` can only be used on structs with a single field
29-
30-
#[derive(From)]
31-
//~v ERROR `#[derive(From)]` can only be used on structs with a single field
32-
enum E2 {
33-
V1,
34-
V2,
35-
}
36-
37-
#[derive(From)]
38-
//~v ERROR `#[derive(From)]` can only be used on structs with a single field
39-
enum E3 {
40-
V1(u32),
41-
V2(bool),
42-
}
4329

4430
#[derive(From)]
4531
//~^ ERROR the size for values of type `T` cannot be known at compilation time [E0277]
Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,60 @@
1-
error: `#[derive(From)]` can only be used on structs with a single field
2-
--> $DIR/deriving-from-wrong-target.rs:8:1
1+
error: `#[derive(From)]` used on a struct with no fields
2+
--> $DIR/deriving-from-wrong-target.rs:7:10
33
|
4+
LL | #[derive(From)]
5+
| ^^^^
6+
LL |
47
LL | struct S1;
5-
| ^^^^^^^^^^
8+
| ^^
9+
|
10+
= note: `#[derive(From)]` can only be used on structs with exactly one field
611

7-
error: `#[derive(From)]` can only be used on structs with a single field
8-
--> $DIR/deriving-from-wrong-target.rs:12:1
12+
error: `#[derive(From)]` used on a struct with no fields
13+
--> $DIR/deriving-from-wrong-target.rs:11:10
914
|
15+
LL | #[derive(From)]
16+
| ^^^^
17+
LL |
1018
LL | struct S2 {}
11-
| ^^^^^^^^^^^^
19+
| ^^
20+
|
21+
= note: `#[derive(From)]` can only be used on structs with exactly one field
1222

13-
error: `#[derive(From)]` can only be used on structs with a single field
14-
--> $DIR/deriving-from-wrong-target.rs:16:1
23+
error: `#[derive(From)]` used on a struct with multiple fields
24+
--> $DIR/deriving-from-wrong-target.rs:15:10
1525
|
26+
LL | #[derive(From)]
27+
| ^^^^
28+
LL |
1629
LL | struct S3(u32, bool);
17-
| ^^^^^^^^^^^^^^^^^^^^^
30+
| ^^
31+
|
32+
= note: `#[derive(From)]` can only be used on structs with exactly one field
1833

19-
error: `#[derive(From)]` can only be used on structs with a single field
20-
--> $DIR/deriving-from-wrong-target.rs:21:1
21-
|
22-
LL | / struct S4 {
23-
LL | | a: u32,
24-
LL | | b: bool,
25-
LL | | }
26-
| |_^
34+
error: `#[derive(From)]` used on a struct with multiple fields
35+
--> $DIR/deriving-from-wrong-target.rs:19:10
36+
|
37+
LL | #[derive(From)]
38+
| ^^^^
39+
LL |
40+
LL | struct S4 {
41+
| ^^
42+
|
43+
= note: `#[derive(From)]` can only be used on structs with exactly one field
2744

28-
error: `#[derive(From)]` can only be used on structs with a single field
29-
--> $DIR/deriving-from-wrong-target.rs:27:1
45+
error: `#[derive(From)]` used on an enum
46+
--> $DIR/deriving-from-wrong-target.rs:26:10
3047
|
48+
LL | #[derive(From)]
49+
| ^^^^
50+
LL |
3151
LL | enum E1 {}
32-
| ^^^^^^^^^^
33-
34-
error: `#[derive(From)]` can only be used on structs with a single field
35-
--> $DIR/deriving-from-wrong-target.rs:32:1
36-
|
37-
LL | / enum E2 {
38-
LL | | V1,
39-
LL | | V2,
40-
LL | | }
41-
| |_^
42-
43-
error: `#[derive(From)]` can only be used on structs with a single field
44-
--> $DIR/deriving-from-wrong-target.rs:39:1
45-
|
46-
LL | / enum E3 {
47-
LL | | V1(u32),
48-
LL | | V2(bool),
49-
LL | | }
50-
| |_^
52+
| ^^
53+
|
54+
= note: `#[derive(From)]` can only be used on structs with exactly one field
5155

5256
error[E0277]: the size for values of type `T` cannot be known at compilation time
53-
--> $DIR/deriving-from-wrong-target.rs:44:10
57+
--> $DIR/deriving-from-wrong-target.rs:30:10
5458
|
5559
LL | #[derive(From)]
5660
| ^^^^ doesn't have a size known at compile-time
@@ -67,7 +71,7 @@ LL + struct SUnsizedField<T> {
6771
|
6872

6973
error[E0277]: the size for values of type `T` cannot be known at compilation time
70-
--> $DIR/deriving-from-wrong-target.rs:44:10
74+
--> $DIR/deriving-from-wrong-target.rs:30:10
7175
|
7276
LL | #[derive(From)]
7377
| ^^^^ doesn't have a size known at compile-time
@@ -76,7 +80,7 @@ LL | struct SUnsizedField<T: ?Sized> {
7680
| - this type parameter needs to be `Sized`
7781
|
7882
note: required because it appears within the type `SUnsizedField<T>`
79-
--> $DIR/deriving-from-wrong-target.rs:47:8
83+
--> $DIR/deriving-from-wrong-target.rs:33:8
8084
|
8185
LL | struct SUnsizedField<T: ?Sized> {
8286
| ^^^^^^^^^^^^^
@@ -88,7 +92,7 @@ LL + struct SUnsizedField<T> {
8892
|
8993

9094
error[E0277]: the size for values of type `T` cannot be known at compilation time
91-
--> $DIR/deriving-from-wrong-target.rs:48:11
95+
--> $DIR/deriving-from-wrong-target.rs:34:11
9296
|
9397
LL | struct SUnsizedField<T: ?Sized> {
9498
| - this type parameter needs to be `Sized`
@@ -106,6 +110,6 @@ help: function arguments must have a statically known size, borrowed types alway
106110
LL | last: &T,
107111
| +
108112

109-
error: aborting due to 10 previous errors
113+
error: aborting due to 8 previous errors
110114

111115
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)