diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 31f85e21d7133..0551b9bc1f0b4 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -1245,11 +1245,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { expr, ); - return self + return Err(self .commit_if_ok(|_| { - self.at(cause, self.param_env).lub(DefineOpaqueTypes::No, prev_ty, new_ty) + self.at(cause, self.param_env).lub(DefineOpaqueTypes::Yes, prev_ty, new_ty) }) - .map(|ok| self.register_infer_ok_obligations(ok)); + .unwrap_err()); } } @@ -1259,10 +1259,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if let Some(e) = first_error { Err(e) } else { - self.commit_if_ok(|_| { - self.at(cause, self.param_env).lub(DefineOpaqueTypes::No, prev_ty, new_ty) - }) - .map(|ok| self.register_infer_ok_obligations(ok)) + Err(self + .commit_if_ok(|_| { + self.at(cause, self.param_env).lub( + DefineOpaqueTypes::Yes, + prev_ty, + new_ty, + ) + }) + .unwrap_err()) } } Ok(ok) => {