From 0e9241cb6e9499e7449973689b12527c03e5333d Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 21 Nov 2023 00:07:55 +0000 Subject: [PATCH] Always make progress on FnOnce ClosureKind goals in the old solver --- compiler/rustc_trait_selection/src/traits/fulfill.rs | 8 +++++++- compiler/rustc_trait_selection/src/traits/select/mod.rs | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs index fb9cf51b513bb..28dbdadaa802d 100644 --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs @@ -420,7 +420,13 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> { ProcessResult::Error(CodeSelectionError(Unimplemented)) } } - None => ProcessResult::Unchanged, + None => { + if kind == ty::ClosureKind::FnOnce { + ProcessResult::Changed(vec![]) + } else { + ProcessResult::Unchanged + } + } } } diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 1ed0da59b64f0..e870a7950878d 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -894,7 +894,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { Ok(EvaluatedToErr) } } - None => Ok(EvaluatedToAmbig), + None => { + if kind == ty::ClosureKind::FnOnce { + Ok(EvaluatedToOk) + } else { + Ok(EvaluatedToAmbig) + } + } } }