diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-13 06:41:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-13 06:41:23 +0100 |
| commit | 5d131407daea78c0490e6958d84dd69447fae8a6 (patch) | |
| tree | 752a44c87f7f88457e96aebb1099cab080231814 /compiler/rustc_trait_selection/src/traits | |
| parent | e42a7024305417e516a1dd9cf58eff3d5af62c69 (diff) | |
| parent | 96b8225d8dd971bc2ecc7aa12068adcda9a9f20f (diff) | |
| download | rust-5d131407daea78c0490e6958d84dd69447fae8a6.tar.gz rust-5d131407daea78c0490e6958d84dd69447fae8a6.zip | |
Rollup merge of #122360 - veera-sivarajan:bugfix-121941, r=compiler-errors
Don't Create `ParamCandidate` When Obligation Contains Errors Fixes #121941 I'm not sure if I understand this correctly but this bug was caused by an error type incorrectly matching against `ParamCandidate`. This was introduced by the changes made in #72621 (figured using cargo-bisect-rustc). This PR fixes it by skipping `ParamCandidate` generation when an error type is involved. Also, this is similar to #73005 but addresses `ParamCandidate` instead of `ImplCandidate`.
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs | 7 |
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 |
