Skip to content

Commit

Permalink
Add ui test of const fn
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 22, 2024
1 parent 486f662 commit 6a3d6bc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/ui/const-fn.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use no_panic::no_panic;

#[no_panic]
const fn f() {}

fn main() {}
9 changes: 9 additions & 0 deletions tests/ui/const-fn.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0015]: cannot call non-const closure in constant functions
--> tests/ui/const-fn.rs:3:1
|
3 | #[no_panic]
| ^^^^^^^^^^^
|
= note: closures need an RFC before allowed to be called in constant functions
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the attribute macro `no_panic` (in Nightly builds, run with -Z macro-backtrace for more info)

0 comments on commit 6a3d6bc

Please sign in to comment.