Skip to content

Commit 412f000

Browse files
committed
Add test for issue-52432
1 parent bae9832 commit 412f000

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/test/ui/consts/issue-52432.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![feature(const_raw_ptr_to_usize_cast)]
2+
3+
fn main() {
4+
[(); &(static |x| {}) as *const _ as usize];
5+
//~^ ERROR: closures cannot be static
6+
//~| ERROR: type annotations needed
7+
[(); &(static || {}) as *const _ as usize];
8+
//~^ ERROR: closures cannot be static
9+
//~| ERROR: evaluation of constant value failed
10+
}

src/test/ui/consts/issue-52432.stderr

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
error[E0697]: closures cannot be static
2+
--> $DIR/issue-52432.rs:4:12
3+
|
4+
LL | [(); &(static |x| {}) as *const _ as usize];
5+
| ^^^^^^^^^^
6+
7+
error[E0697]: closures cannot be static
8+
--> $DIR/issue-52432.rs:7:12
9+
|
10+
LL | [(); &(static || {}) as *const _ as usize];
11+
| ^^^^^^^^^
12+
13+
error[E0282]: type annotations needed
14+
--> $DIR/issue-52432.rs:4:20
15+
|
16+
LL | [(); &(static |x| {}) as *const _ as usize];
17+
| ^ consider giving this closure parameter a type
18+
19+
error[E0080]: evaluation of constant value failed
20+
--> $DIR/issue-52432.rs:7:10
21+
|
22+
LL | [(); &(static || {}) as *const _ as usize];
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants
24+
25+
error: aborting due to 4 previous errors
26+
27+
Some errors have detailed explanations: E0080, E0282, E0697.
28+
For more information about an error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)