diff options
| author | Michael Goulet <michael@errs.io> | 2023-02-09 18:14:13 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-02-10 00:35:25 +0000 |
| commit | 3c4e1f85cb7103751bf99e3d826051ab42700dcc (patch) | |
| tree | 08a38f00aec3dad3992fab8822c4ef6231edb1e5 /compiler/rustc_trait_selection/src | |
| parent | 8996ea93b6e554148c4286e62b613f12a3ee505c (diff) | |
| download | rust-3c4e1f85cb7103751bf99e3d826051ab42700dcc.tar.gz rust-3c4e1f85cb7103751bf99e3d826051ab42700dcc.zip | |
Multiple candidates with same response is not ambiguous
Diffstat (limited to 'compiler/rustc_trait_selection/src')
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/assembly.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/assembly.rs b/compiler/rustc_trait_selection/src/solve/assembly.rs index 775974d8e9a..126ec60b3d6 100644 --- a/compiler/rustc_trait_selection/src/solve/assembly.rs +++ b/compiler/rustc_trait_selection/src/solve/assembly.rs @@ -4,6 +4,7 @@ use super::infcx_ext::InferCtxtExt; #[cfg(doc)] use super::trait_goals::structural_traits::*; use super::{CanonicalResponse, Certainty, EvalCtxt, Goal, MaybeCause, QueryResult}; +use itertools::Itertools; use rustc_hir::def_id::DefId; use rustc_infer::traits::query::NoSolution; use rustc_infer::traits::util::elaborate_predicates; @@ -489,9 +490,9 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { i += 1; } - // If there are *STILL* multiple candidates, give up - // and report ambiguity. - if candidates.len() > 1 { + // If there are *STILL* multiple candidates that have *different* response + // results, give up and report ambiguity. + if candidates.len() > 1 && !candidates.iter().map(|cand| cand.result).all_equal() { let certainty = if candidates.iter().all(|x| { matches!(x.result.value.certainty, Certainty::Maybe(MaybeCause::Overflow)) }) { @@ -503,6 +504,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> { } } + // FIXME: What if there are >1 candidates left with the same response, and one is a reservation impl? Ok(self.discard_reservation_impl(candidates.pop().unwrap()).result) } |
