Skip to content

Commit

Permalink
Fix #91489
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Dec 12, 2021
1 parent e70e4d4 commit 5166f68
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,11 @@ impl<'tcx> ParamEnv<'tcx> {
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
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

let generator_types = check_fn(
self,
self.param_env,
self.param_env.without_const(),
liberated_sig,
decl,
expr.hir_id,
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit 5166f68

Please sign in to comment.