about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-12-31 11:32:15 +0000
committerbors <bors@rust-lang.org>2022-12-31 11:32:15 +0000
commit726bbfc8f0d6eb431dfa620c1c8fc3848020cd3c (patch)
tree88ff46e773fd681ef081a5bc7b673883c5816f69 /compiler
parent96c1f338bb5ba7bae2285fc48f249aa5015e542a (diff)
parentf6b45e399e5c75429e66b11760e97d56fc010091 (diff)
downloadrust-726bbfc8f0d6eb431dfa620c1c8fc3848020cd3c.tar.gz
rust-726bbfc8f0d6eb431dfa620c1c8fc3848020cd3c.zip
Auto merge of #106302 - compiler-errors:terr-coerce-w-infer, r=estebank
Suppress errors due to TypeError not coercing with inference variables

Fixes #75331
Fixes #68507
Fixes #82323

cc `@estebank`
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_hir_typeck/src/coercion.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs
index b0cd4a16e98..3fb14e31ea1 100644
--- a/compiler/rustc_hir_typeck/src/coercion.rs
+++ b/compiler/rustc_hir_typeck/src/coercion.rs
@@ -171,6 +171,10 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
 
         // Just ignore error types.
         if a.references_error() || b.references_error() {
+            // Best-effort try to unify these types -- we're already on the error path,
+            // so this will have the side-effect of making sure we have no ambiguities
+            // due to `[type error]` and `_` not coercing together.
+            let _ = self.commit_if_ok(|_| self.at(&self.cause, self.param_env).eq(a, b));
             return success(vec![], self.fcx.tcx.ty_error(), vec![]);
         }