Skip to content

Commit 510ad74

Browse files
committed
Add regression tests for seemingly fixed issues
1 parent e1b9081 commit 510ad74

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ check-pass
2+
3+
#![feature(const_trait_impl, const_destruct, const_clone)]
4+
5+
use std::marker::Destruct;
6+
7+
const fn f<T, F: [const] Fn(&T) -> T + [const] Destruct>(_: F) {}
8+
9+
const fn g<T: [const] Clone>() {
10+
f(<T as Clone>::clone);
11+
}
12+
13+
fn main() {}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//@ run-pass
2+
3+
#![allow(incomplete_features)]
4+
#![feature(const_closures, const_trait_impl)]
5+
6+
const fn create_array<const N: usize>(mut f: impl [const] FnMut(usize) -> u32 + Copy) -> [u32; N] {
7+
let mut array = [0; N];
8+
let mut i = 0;
9+
loop {
10+
array[i] = f(i);
11+
i += 1;
12+
if i == N {
13+
break;
14+
}
15+
}
16+
array
17+
}
18+
19+
fn main() {
20+
// This works fine.
21+
let x = create_array(const |i| 2 * i as u32);
22+
assert_eq!(x, [0, 2, 4, 6, 8]);
23+
24+
// This closure had caused an ICE.
25+
let y = create_array(const |i| 2 * i as u32 + 1);
26+
assert_eq!(y, [1, 3, 5, 7, 9]);
27+
}

0 commit comments

Comments
 (0)