add the leak check to the new solver

This commit is contained in:
lcnr 2023-05-23 19:34:17 +02:00
parent 04056b5c04
commit 6f9041bd15
2 changed files with 29 additions and 0 deletions

View File

@ -137,6 +137,11 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
#[instrument(level = "debug", skip(self), ret)]
fn compute_external_query_constraints(&self) -> Result<ExternalConstraints<'tcx>, NoSolution> {
self.infcx.leak_check(ty::UniverseIndex::ROOT, None).map_err(|e| {
debug!(?e, "failed the leak check");
NoSolution
})?;
// Cannot use `take_registered_region_obligations` as we may compute the response
// inside of a `probe` whenever we have multiple choices inside of the solver.
let region_obligations = self.infcx.inner.borrow().region_obligations().to_owned();

View File

@ -0,0 +1,24 @@
// run-pass
// revisions: old next
//[next] compile-flags: -Ztrait-solver=next
#![allow(coherence_leak_check)]
trait Trait: Sized {
fn is_higher_ranked(self) -> bool;
}
impl Trait for for<'a> fn(&'a ()) {
fn is_higher_ranked(self) -> bool {
true
}
}
impl<'a> Trait for fn(&'a ()) {
fn is_higher_ranked(self) -> bool {
false
}
}
fn main() {
let x: for<'a> fn(&'a ()) = |&()| ();
assert!(x.is_higher_ranked());
}