This commit is contained in:
Deadbeef 2021-12-06 20:46:05 +08:00
parent e70e4d499d
commit 5166f68754
No known key found for this signature in database
GPG Key ID: 6D017A96D8E6C2F9
3 changed files with 24 additions and 1 deletions

View File

@ -1319,6 +1319,11 @@ pub fn with_user_facing(mut self) -> Self {
self
}
pub fn without_const(mut self) -> Self {
self.packed.set_tag(ParamTag { constness: hir::Constness::NotConst, ..self.packed.tag() });
self
}
/// Returns a new parameter environment with the same clauses, but
/// which "reveals" the true results of projections in all cases
/// (even for associated types that are specializable). This is

View File

@ -80,7 +80,7 @@ fn check_closure(
let generator_types = check_fn(
self,
self.param_env,
self.param_env.without_const(),
liberated_sig,
decl,
expr.hir_id,

View File

@ -0,0 +1,18 @@
// check-pass
#![feature(const_trait_impl)]
#![feature(const_fn_trait_bound)]
trait Convert<T> {
fn to(self) -> T;
}
impl<A, B> const Convert<B> for A where B: ~const From<A> {
fn to(self) -> B {
B::from(self)
}
}
const FOO: fn() -> String = || "foo".to();
fn main() {}