You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/ui/binding/issue-53114-safety-checks.stderr
+57-7
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,25 @@ LL | let (_,) = (&p.b,);
17
17
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
18
18
19
19
error[E0793]: reference to packed field is unaligned
20
-
--> $DIR/issue-53114-safety-checks.rs:37:11
20
+
--> $DIR/issue-53114-safety-checks.rs:37:16
21
+
|
22
+
LL | let _: _ = &p.b;
23
+
| ^^^^
24
+
|
25
+
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
26
+
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
27
+
28
+
error[E0793]: reference to packed field is unaligned
29
+
--> $DIR/issue-53114-safety-checks.rs:42:20
30
+
|
31
+
LL | let (_,): _ = (&p.b,);
32
+
| ^^^^
33
+
|
34
+
= note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
35
+
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
36
+
37
+
error[E0793]: reference to packed field is unaligned
38
+
--> $DIR/issue-53114-safety-checks.rs:51:11
21
39
|
22
40
LL | match &p.b { _ => { } }
23
41
| ^^^^
@@ -26,7 +44,7 @@ LL | match &p.b { _ => { } }
26
44
= help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers)
27
45
28
46
error[E0793]: reference to packed field is unaligned
29
-
--> $DIR/issue-53114-safety-checks.rs:42:12
47
+
--> $DIR/issue-53114-safety-checks.rs:56:12
30
48
|
31
49
LL | match (&p.b,) { (_,) => { } }
32
50
| ^^^^
@@ -59,38 +77,70 @@ LL | let (_,) = (&u2.a,);
59
77
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
60
78
61
79
error[E0133]: access to union field is unsafe and requires unsafe function or block
62
-
--> $DIR/issue-53114-safety-checks.rs:38:11
80
+
--> $DIR/issue-53114-safety-checks.rs:38:12
81
+
|
82
+
LL | let _: _ = u1.a;
83
+
| ^ access to union field
84
+
|
85
+
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
86
+
87
+
error[E0133]: access to union field is unsafe and requires unsafe function or block
88
+
--> $DIR/issue-53114-safety-checks.rs:39:16
89
+
|
90
+
LL | let _: _ = &u2.a;
91
+
| ^^^^^ access to union field
92
+
|
93
+
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
94
+
95
+
error[E0133]: access to union field is unsafe and requires unsafe function or block
96
+
--> $DIR/issue-53114-safety-checks.rs:43:20
97
+
|
98
+
LL | let (_,): _ = (u1.a,);
99
+
| ^^^^ access to union field
100
+
|
101
+
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
102
+
103
+
error[E0133]: access to union field is unsafe and requires unsafe function or block
104
+
--> $DIR/issue-53114-safety-checks.rs:44:20
105
+
|
106
+
LL | let (_,): _ = (&u2.a,);
107
+
| ^^^^^ access to union field
108
+
|
109
+
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
110
+
111
+
error[E0133]: access to union field is unsafe and requires unsafe function or block
112
+
--> $DIR/issue-53114-safety-checks.rs:52:11
63
113
|
64
114
LL | match u1.a { _ => { } }
65
115
| ^^^^ access to union field
66
116
|
67
117
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
68
118
69
119
error[E0133]: access to union field is unsafe and requires unsafe function or block
70
-
--> $DIR/issue-53114-safety-checks.rs:39:11
120
+
--> $DIR/issue-53114-safety-checks.rs:53:11
71
121
|
72
122
LL | match &u2.a { _ => { } }
73
123
| ^^^^^ access to union field
74
124
|
75
125
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
76
126
77
127
error[E0133]: access to union field is unsafe and requires unsafe function or block
78
-
--> $DIR/issue-53114-safety-checks.rs:43:12
128
+
--> $DIR/issue-53114-safety-checks.rs:57:12
79
129
|
80
130
LL | match (u1.a,) { (_,) => { } }
81
131
| ^^^^ access to union field
82
132
|
83
133
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
84
134
85
135
error[E0133]: access to union field is unsafe and requires unsafe function or block
86
-
--> $DIR/issue-53114-safety-checks.rs:44:12
136
+
--> $DIR/issue-53114-safety-checks.rs:58:12
87
137
|
88
138
LL | match (&u2.a,) { (_,) => { } }
89
139
| ^^^^^ access to union field
90
140
|
91
141
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior
92
142
93
-
error: aborting due to 11 previous errors
143
+
error: aborting due to 17 previous errors
94
144
95
145
Some errors have detailed explanations: E0133, E0793.
96
146
For more information about an error, try `rustc --explain E0133`.
0 commit comments