summaryrefslogtreecommitdiffstats
path: root/src/test/ui/union/union-inherent-method.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/union/union-inherent-method.rs')
-rw-r--r--src/test/ui/union/union-inherent-method.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/ui/union/union-inherent-method.rs b/src/test/ui/union/union-inherent-method.rs
new file mode 100644
index 000000000..b0fd22da7
--- /dev/null
+++ b/src/test/ui/union/union-inherent-method.rs
@@ -0,0 +1,16 @@
+// run-pass
+// revisions: mirunsafeck thirunsafeck
+// [thirunsafeck]compile-flags: -Z thir-unsafeck
+
+union U {
+ a: u8,
+}
+
+impl U {
+ fn method(&self) -> u8 { unsafe { self.a } }
+}
+
+fn main() {
+ let u = U { a: 10 };
+ assert_eq!(u.method(), 10);
+}