diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/privacy/union-field-privacy-1.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/ui/privacy/union-field-privacy-1.rs b/src/test/ui/privacy/union-field-privacy-1.rs new file mode 100644 index 000000000..8a84bd86a --- /dev/null +++ b/src/test/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 +}} |