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) + } + } } }