aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/rust/compile/issue-1235.rs
blob: 7c85ac4a6b0027d5547cc078fda2eae3520b30e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// { dg-additional-options "-w" }
#[lang = "sized"]
pub trait Sized {}

struct FatPtr<T> {
    data: *const T,
    len: usize,
}

pub union Repr<T> {
    rust: *const [T],
    rust_mut: *mut [T],
    raw: FatPtr<T>,
}

impl<T> [T] {
    pub const fn is_empty(&self) -> bool {
        self.len() == 0
    }

    pub const fn len(&self) -> usize {
        unsafe { Repr { rust: self }.raw.len }
    }
}