]> git.proxmox.com Git - rustc.git/blob - tests/ui/union/union-trait-impl.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / union / union-trait-impl.rs
1 // run-pass
2 // revisions: mirunsafeck thirunsafeck
3 // [thirunsafeck]compile-flags: -Z thir-unsafeck
4
5 use std::fmt;
6
7 union U {
8 a: u8
9 }
10
11 impl fmt::Display for U {
12 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
13 unsafe { write!(f, "Oh hai {}", self.a) }
14 }
15 }
16
17 fn main() {
18 assert_eq!(U { a: 2 }.to_string(), "Oh hai 2");
19 }