Skip to content

Commit 8463b3a

Browse files
authored
Rollup merge of #155907 - oli-obk:push-nypowoyskzxp, r=Kivooeo
Handle hkl const closures I severely overthought this in #153818 😆 The const closure trait solver impl is now in sync with the non-const closure trait solver impl.
2 parents 064d3ee + b465c56 commit 8463b3a

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

compiler/rustc_trait_selection/src/traits/effects.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -554,11 +554,7 @@ fn evaluate_host_effect_for_fn_goal<'tcx>(
554554
// but they don't really need to right now.
555555
ty::CoroutineClosure(_, _) => return Err(EvaluationFailure::NoSolution),
556556

557-
ty::Closure(def, args) => {
558-
// For now we limit ourselves to closures without binders. The next solver can handle them.
559-
args.as_closure().sig().no_bound_vars().ok_or(EvaluationFailure::NoSolution)?;
560-
(def, args)
561-
}
557+
ty::Closure(def, args) => (def, args),
562558

563559
// Everything else needs explicit impls or cannot have an impl
564560
_ => return Err(EvaluationFailure::NoSolution),
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//! Regression test for hkl const closures not working in old solver
2+
3+
//@ check-pass
4+
//@ revisions: current next
5+
//@ ignore-compare-mode-next-solver (explicit revisions)
6+
//@[next] compile-flags: -Znext-solver
7+
8+
#![feature(const_trait_impl)]
9+
#![feature(const_closures)]
10+
const fn partial_compare() {
11+
let len_chain = const move |_a: &_, _b: &_| {};
12+
13+
chaining_impl(len_chain);
14+
}
15+
16+
const fn chaining_impl(x: impl for<'a> [const] FnOnce(&'a usize, &'a usize)) {
17+
std::mem::forget(x);
18+
}
19+
20+
fn main() {}

0 commit comments

Comments
 (0)