gcc/testsuite/rust/compile/issue-1235.rs
raw| 1 | // { dg-additional-options "-w" } |
| 2 | #[lang = "sized"] |
| 3 | pub trait Sized {} |
| 4 | |
| 5 | struct FatPtr<T> { |
| 6 | data: *const T, |
| 7 | len: usize, |
| 8 | } |
| 9 | |
| 10 | pub union Repr<T> { |
| 11 | rust: *const [T], |
| 12 | rust_mut: *mut [T], |
| 13 | raw: FatPtr<T>, |
| 14 | } |
| 15 | |
| 16 | impl<T> [T] { |
| 17 | pub const fn is_empty(&self) -> bool { |
| 18 | self.len() == 0 |
| 19 | } |
| 20 | |
| 21 | pub const fn len(&self) -> usize { |
| 22 | unsafe { Repr { rust: self }.raw.len } |
| 23 | } |
| 24 | } |