Closed
Description
I tried this code:
use core::marker::PhantomData;
const fn test() {
let _: PhantomData<fn()> = PhantomData;
}
I expected it to work, but it doesn't work.
Error:
error[E0723]: function pointers in const fn are unstable
--> src/lib.rs:4:32
|
4 | let _: PhantomData<fn()> = PhantomData;
| ^^^^^^^^^^^
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn)]` to the crate attributes to enable
I use PhantomData<fn(T) -> T>
to make type invariant over T
& mark that I don't own T
. I see no reason for this code to be unstable.
Meta
rustc --version --verbose
:
rustc 1.43.0-nightly (433aae93e 2020-02-14)
binary: rustc
commit-hash: 433aae93e4ef866a1fdfefad136b32ed89acd3e7
commit-date: 2020-02-14
host: x86_64-unknown-linux-gnu
release: 1.43.0-nightly
LLVM version: 9.0