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