Skip to content

Commit 44b23d9

Browse files
committed
test
1 parent 620e36a commit 44b23d9

File tree

5 files changed

+77
-0
lines changed

5 files changed

+77
-0
lines changed

library/coretests/tests/array.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,3 +741,22 @@ fn const_array_ops() {
741741
struct Zst;
742742
assert_eq!([(); 10].try_map(|()| Some(Zst)), Some([const { Zst }; 10]));
743743
}
744+
745+
#[test]
746+
fn extra_const_array_ops() {
747+
const {
748+
let x: [u8; 4] =
749+
{ std::array::from_fn(const |i| i + 4).map(const |x| x * 2).map(const |x| x as _) };
750+
let y = 4;
751+
struct Z(u16);
752+
impl const Drop for Z {
753+
fn drop(&mut self) {}
754+
}
755+
let w = Z(2);
756+
let _x: [u8; 4] = {
757+
std::array::from_fn(const |_| x[0] + y)
758+
.map(const |x| x * (w.0 as u8))
759+
.map(const |x| x as _)
760+
};
761+
}
762+
}

library/coretests/tests/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#![feature(const_bool)]
1818
#![feature(const_cell_traits)]
1919
#![feature(const_clone)]
20+
#![feature(const_closures)]
2021
#![feature(const_cmp)]
2122
#![feature(const_convert)]
2223
#![feature(const_default)]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0277]: the trait bound `Vec<u8>: const Destruct` is not satisfied
2+
--> $DIR/const-closure-with-indestructible-indestructible.rs:10:16
3+
|
4+
LL | i_need(const || {
5+
| _________------_^
6+
| | |
7+
| | required by a bound introduced by this call
8+
LL | |
9+
LL | | let y = v;
10+
LL | | })
11+
| |_________^
12+
|
13+
note: required by a bound in `i_need`
14+
--> $DIR/const-closure-with-indestructible-indestructible.rs:5:20
15+
|
16+
LL | const fn i_need<F: [const] std::marker::Destruct>(x: F) {}
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `i_need`
18+
19+
error: aborting due to 1 previous error
20+
21+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0277]: the trait bound `Vec<u8>: const Destruct` is not satisfied
2+
--> $DIR/const-closure-with-indestructible-indestructible.rs:10:16
3+
|
4+
LL | i_need(const || {
5+
| _________------_^
6+
| | |
7+
| | required by a bound introduced by this call
8+
LL | |
9+
LL | | let y = v;
10+
LL | | })
11+
| |_________^
12+
|
13+
note: required by a bound in `i_need`
14+
--> $DIR/const-closure-with-indestructible-indestructible.rs:5:20
15+
|
16+
LL | const fn i_need<F: [const] std::marker::Destruct>(x: F) {}
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `i_need`
18+
19+
error: aborting due to 1 previous error
20+
21+
For more information about this error, try `rustc --explain E0277`.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@revisions: next old
2+
//@ ignore-compare-mode-next-solver (explicit revisions)
3+
//@[next] compile-flags: -Znext-solver
4+
#![feature(const_trait_impl, const_closures, const_destruct)]
5+
const fn i_need<F: [const] std::marker::Destruct>(x: F) {}
6+
7+
fn main() {
8+
const {
9+
let v = Vec::<u8>::new();
10+
i_need(const || {
11+
//~^ ERROR the trait bound
12+
let y = v;
13+
})
14+
};
15+
}

0 commit comments

Comments
 (0)