about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
diff options
context:
space:
mode:
authorVeera <sveera.2001@gmail.com>2024-03-11 23:05:43 -0400
committerVeera <sveera.2001@gmail.com>2024-03-12 15:27:08 -0400
commit96b8225d8dd971bc2ecc7aa12068adcda9a9f20f (patch)
tree62dba6efbc272a442e7c5538ba4af7e293f25f16 /compiler/rustc_trait_selection
parent4a0cc881dcc4d800f10672747f61a94377ff6662 (diff)
downloadrust-96b8225d8dd971bc2ecc7aa12068adcda9a9f20f.tar.gz
rust-96b8225d8dd971bc2ecc7aa12068adcda9a9f20f.zip
Don't Create `ParamCandidate` When Obligation Contains Errors
Fixes #121941
Diffstat (limited to 'compiler/rustc_trait_selection')
-rw-r--r--compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
index 66f740b761d..89654ed61ae 100644
--- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
@@ -219,6 +219,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
     ) -> Result<(), SelectionError<'tcx>> {
         debug!(?stack.obligation);
 
+        // An error type will unify with anything. So, avoid
+        // matching an error type with `ParamCandidate`.
+        // This helps us avoid spurious errors like issue #121941.
+        if stack.obligation.predicate.references_error() {
+            return Ok(());
+        }
+
         let all_bounds = stack
             .obligation
             .param_env