]> git.lizzy.rs Git - rust.git/blob - src/test/ui/const-generics/issue-70180-2-stalled_on.rs
Merge commit '4c41a222ca5d1325fb4b6709395bd06e766cc042' into clippyup
[rust.git] / src / test / ui / const-generics / issue-70180-2-stalled_on.rs
1 // build-pass
2 // revisions: full min
3
4 #![cfg_attr(full, feature(const_generics))]
5 #![cfg_attr(full, allow(incomplete_features))]
6
7 fn works() {
8     let array/*: [u8; _]*/ = default_byte_array();
9     let _: [_; 4] = array;
10     Foo::foo(&array);
11 }
12
13 fn didnt_work() {
14     let array/*: [u8; _]*/ = default_byte_array();
15     Foo::foo(&array);
16     let _: [_; 4] = array;
17 }
18
19 trait Foo<T> {
20     fn foo(&self) {}
21 }
22
23 impl Foo<i32> for [u8; 4] {}
24 impl Foo<i64> for [u8; 8] {}
25
26 // Only needed because `[u8; _]` is not valid type syntax.
27 fn default_byte_array<const N: usize>() -> [u8; N]
28 where
29     [u8; N]: Default,
30 {
31     Default::default()
32 }
33
34 fn main() {
35     works();
36     didnt_work();
37 }