summaryrefslogtreecommitdiffstats
path: root/tests/ui/privacy/union-field-privacy-1.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/privacy/union-field-privacy-1.rs')
-rw-r--r--tests/ui/privacy/union-field-privacy-1.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/ui/privacy/union-field-privacy-1.rs b/tests/ui/privacy/union-field-privacy-1.rs
new file mode 100644
index 000000000..8a84bd86a
--- /dev/null
+++ b/tests/ui/privacy/union-field-privacy-1.rs
@@ -0,0 +1,17 @@
+mod m {
+ pub union U {
+ pub a: u8,
+ pub(super) b: u8,
+ c: u8,
+ }
+}
+
+fn main() { unsafe {
+ let u = m::U { a: 0 }; // OK
+ let u = m::U { b: 0 }; // OK
+ let u = m::U { c: 0 }; //~ ERROR field `c` of union `U` is private
+
+ let m::U { a } = u; // OK
+ let m::U { b } = u; // OK
+ let m::U { c } = u; //~ ERROR field `c` of union `U` is private
+}}