summaryrefslogtreecommitdiffstats
path: root/tests/ui/const-generics/issues/issue-70180-2-stalled_on.rs
blob: 95e548428747f8256ffe1ff2cc0752e35c056d4d (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
25
26
27
28
29
30
31
32
33
// build-pass

fn works() {
    let array/*: [u8; _]*/ = default_byte_array();
    let _: [_; 4] = array;
    Foo::foo(&array);
}

fn didnt_work() {
    let array/*: [u8; _]*/ = default_byte_array();
    Foo::foo(&array);
    let _: [_; 4] = array;
}

trait Foo<T> {
    fn foo(&self) {}
}

impl Foo<i32> for [u8; 4] {}
impl Foo<i64> for [u8; 8] {}

// Only needed because `[u8; _]` is not valid type syntax.
fn default_byte_array<const N: usize>() -> [u8; N]
where
    [u8; N]: Default,
{
    Default::default()
}

fn main() {
    works();
    didnt_work();
}