about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-09-21 21:24:19 +0200
committerGitHub <noreply@github.com>2019-09-21 21:24:19 +0200
commit25bdd76a545d8a6a62d20d8dad2690abb13ab10f (patch)
tree023d9692d5c1574a1eea33eb787c9655f313cdd7 /src/libsyntax
parent05d7ae25bf0efe7a42df6994eeceee5bff19cf3e (diff)
parent9d4053f6921f3259076e2d88f983f9666a78ef4b (diff)
downloadrust-25bdd76a545d8a6a62d20d8dad2690abb13ab10f.tar.gz
rust-25bdd76a545d8a6a62d20d8dad2690abb13ab10f.zip
Rollup merge of #64635 - gnzlbg:const_fn_ptr, r=oli-obk
Allow using fn pointers in const fn with unleash miri

This allows using function pointers in const fns  when `-Zunleash-the-miri-within-you` is enabled.

If the call to the `const fn` happens in a `const`-context, the function pointer is required to point to a `const fn`:

```rust
fn non_const_fn() -> i32 { 42 }
const fn const_fn() -> i32 { 42 }
const fn foo(x: fn() -> i32) -> i32 { x() }

let x: i32 = foo(non_const_fn_ptr); // OK
let y: i32 = foo(const_fn_ptr); // OK
const X: i32 = foo(non_const_fn_ptr); // ERROR: `non_const_fn` is not `const fn`
const Y: i32 = foo(const_fn_ptr); // OK
```

r? @oli-obk
Diffstat (limited to 'src/libsyntax')
0 files changed, 0 insertions, 0 deletions