blob: 6134e91f31e49023b341abb7d32f99fda2b4eb43 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
// run-pass
// revisions: mirunsafeck thirunsafeck
// [thirunsafeck]compile-flags: -Z thir-unsafeck
use std::fmt;
union U {
a: u8
}
impl fmt::Display for U {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
unsafe { write!(f, "Oh hai {}", self.a) }
}
}
fn main() {
assert_eq!(U { a: 2 }.to_string(), "Oh hai 2");
}
|