]> git.lizzy.rs Git - rust.git/blob - tests/ui/box/thin_align.rs
Rollup merge of #106898 - estebank:ice-forms-are-a-headache, r=Mark-Simulacrum
[rust.git] / tests / ui / box / thin_align.rs
1 #![feature(thin_box)]
2 // run-pass
3 use std::boxed::ThinBox;
4 use std::error::Error;
5 use std::ops::Deref;
6 use std::fmt;
7
8 fn main() {
9     let expected = "Foo error!";
10     let a: ThinBox<dyn Error> = ThinBox::new_unsize(Foo(expected));
11     let a = a.deref();
12     let msg = a.to_string();
13     assert_eq!(expected, msg);
14 }
15
16 #[derive(Debug)]
17 #[repr(align(1024))]
18 struct Foo(&'static str);
19
20 impl fmt::Display for Foo {
21     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22         write!(f, "{}", self.0)
23     }
24 }
25
26 impl Error for Foo {}