diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_trait_selection/Cargo.toml | 1 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/solve/assembly.rs | 8 |
2 files changed, 6 insertions, 3 deletions
diff --git a/compiler/rustc_trait_selection/Cargo.toml b/compiler/rustc_trait_selection/Cargo.toml index 3f863038efb..d3eba43b47e 100644 --- a/compiler/rustc_trait_selection/Cargo.toml +++ b/compiler/rustc_trait_selection/Cargo.toml @@ -24,3 +24,4 @@ rustc_span = { path = "../rustc_span" } rustc_target = { path = "../rustc_target" } rustc_transmute = { path = "../rustc_transmute", features = ["rustc"] } smallvec = { version = "1.8.1", features = ["union", "may_dangle"] } +itertools = "0.10.1" 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) } |
