Skip to content

Commit 5166f68

Browse files
committed
Fix #91489
1 parent e70e4d4 commit 5166f68

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,11 @@ impl<'tcx> ParamEnv<'tcx> {
13191319
self
13201320
}
13211321

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

compiler/rustc_typeck/src/check/closure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8080

8181
let generator_types = check_fn(
8282
self,
83-
self.param_env,
83+
self.param_env.without_const(),
8484
liberated_sig,
8585
decl,
8686
expr.hir_id,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// check-pass
2+
3+
#![feature(const_trait_impl)]
4+
#![feature(const_fn_trait_bound)]
5+
6+
trait Convert<T> {
7+
fn to(self) -> T;
8+
}
9+
10+
impl<A, B> const Convert<B> for A where B: ~const From<A> {
11+
fn to(self) -> B {
12+
B::from(self)
13+
}
14+
}
15+
16+
const FOO: fn() -> String = || "foo".to();
17+
18+
fn main() {}

0 commit comments

Comments
 (0)