Skip to content

Commit

Permalink
Add test for issue-52432
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Nov 12, 2019
1 parent bae9832 commit 412f000
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/test/ui/consts/issue-52432.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![feature(const_raw_ptr_to_usize_cast)]

fn main() {
[(); &(static |x| {}) as *const _ as usize];
//~^ ERROR: closures cannot be static
//~| ERROR: type annotations needed
[(); &(static || {}) as *const _ as usize];
//~^ ERROR: closures cannot be static
//~| ERROR: evaluation of constant value failed
}
28 changes: 28 additions & 0 deletions src/test/ui/consts/issue-52432.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
error[E0697]: closures cannot be static
--> $DIR/issue-52432.rs:4:12
|
LL | [(); &(static |x| {}) as *const _ as usize];
| ^^^^^^^^^^

error[E0697]: closures cannot be static
--> $DIR/issue-52432.rs:7:12
|
LL | [(); &(static || {}) as *const _ as usize];
| ^^^^^^^^^

error[E0282]: type annotations needed
--> $DIR/issue-52432.rs:4:20
|
LL | [(); &(static |x| {}) as *const _ as usize];
| ^ consider giving this closure parameter a type

error[E0080]: evaluation of constant value failed
--> $DIR/issue-52432.rs:7:10
|
LL | [(); &(static || {}) as *const _ as usize];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0080, E0282, E0697.
For more information about an error, try `rustc --explain E0080`.

0 comments on commit 412f000

Please sign in to comment.