Open
Description
I tried this code (playground):
#![feature(const_trait_impl)]
use std::marker::Destruct;
const fn f<T, F: ~const Fn(&T) -> T + ~const Destruct>(_: F) {}
const fn g<T: ~const Clone>() {
f(<T as Clone>::clone);
}
I got a compile error:
error[E0277]: the trait bound `for<'a> for<'a> fn(&'a T) -> T {<T as Clone>::clone}: ~const Fn<(&'a T,)>` is not satisfied
--> src\lib.rs:8:7
|
8 | f(<T as Clone>::clone);
| - ^^^^^^^^^^^^^^^^^^^ expected an `Fn<(&T,)>` closure, found `for<'a> fn(&'a T) -> T {<T as Clone>::clone}`
| |
| required by a bound introduced by this call
|
= help: the trait `for<'a> ~const Fn<(&'a T,)>` is not implemented for fn item `for<'a> fn(&'a T) -> T {<T as Clone>::clone}`
note: the trait `for<'a> Fn<(&'a T,)>` is implemented for `for<'a> fn(&'a T) -> T {<T as Clone>::clone}`, but that implementation is not `const`
--> src\lib.rs:8:7
|
8 | f(<T as Clone>::clone);
| ^^^^^^^^^^^^^^^^^^^
note: required by a bound in `f`
--> src\lib.rs:5:18
|
5 | const fn f<T, F: ~const Fn(&T) -> T + ~const Destruct>(_: F) {}
| ^^^^^^^^^^^^^^^^^^ required by this bound in `f`
Meta
rustc --version --verbose
:
rustc 1.67.0-nightly (42325c525 2022-11-11)
binary: rustc
commit-hash: 42325c525b9d3885847a3f803abe53c562d289da
commit-date: 2022-11-11
host: x86_64-pc-windows-msvc
release: 1.67.0-nightly
LLVM version: 15.0.4