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 @@ impl<'tcx> ParamEnv<'tcx> {
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 /// Returns a new parameter environment with the same clauses, but
/// which "reveals" the true results of projections in all cases /// which "reveals" the true results of projections in all cases
/// (even for associated types that are specializable). This is /// (even for associated types that are specializable). This is

View File

@ -80,7 +80,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let generator_types = check_fn( let generator_types = check_fn(
self, self,
self.param_env, self.param_env.without_const(),
liberated_sig, liberated_sig,
decl, decl,
expr.hir_id, 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() {}