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