Skip to content

Commit dbf72f4

Browse files
committed
test
1 parent 620e36a commit dbf72f4

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

library/coretests/tests/array.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,3 +741,23 @@ 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] = const {
749+
std::array::from_fn(const |i| i + 4).map(const |x| x * 2).map(const |x| x as _)
750+
};
751+
let y = 4;
752+
struct Z(u16);
753+
impl const Drop for Z {
754+
fn drop(&mut self) {}
755+
}
756+
let w = Z(2);
757+
let x: [u8; 4] = const {
758+
std::array::from_fn(const |_| x[0] + y)
759+
.map(const |x| x * Z.0 as _)
760+
.map(const |x| x as _)
761+
};
762+
}
763+
}

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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![feature(const_trait_impl, const_closures, const_destruct)]
2+
const fn i_need<F: [const] std::marker::Destruct>(x: F) {}
3+
4+
fn main() {
5+
const {
6+
let v = Vec::<u8>::new();
7+
i_need(const || { let y = v; })
8+
//~^ ERROR the trait bound
9+
};
10+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0277]: the trait bound `Vec<u8>: const Destruct` is not satisfied
2+
--> $DIR/const-closure-with-indestructible-indestructible.rs:8:16
3+
|
4+
LL | i_need(const || { let y = v; })
5+
| ------ ^^^^^^^^^^^^^^^^^^^^^^^
6+
| |
7+
| required by a bound introduced by this call
8+
|
9+
note: required by a bound in `i_need`
10+
--> $DIR/const-closure-with-indestructible-indestructible.rs:3:20
11+
|
12+
LL | const fn i_need<F: [const] std::marker::Destruct>(x: F) {}
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `i_need`
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)