mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Multiple candidates with same response is not ambiguous
This commit is contained in:
parent
8996ea93b6
commit
3c4e1f85cb
@ -4773,6 +4773,7 @@ checksum = "8ba09476327c4b70ccefb6180f046ef588c26a24cf5d269a9feba316eb4f029f"
|
|||||||
name = "rustc_trait_selection"
|
name = "rustc_trait_selection"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"itertools",
|
||||||
"rustc_ast",
|
"rustc_ast",
|
||||||
"rustc_attr",
|
"rustc_attr",
|
||||||
"rustc_data_structures",
|
"rustc_data_structures",
|
||||||
|
@ -24,3 +24,4 @@ rustc_span = { path = "../rustc_span" }
|
|||||||
rustc_target = { path = "../rustc_target" }
|
rustc_target = { path = "../rustc_target" }
|
||||||
rustc_transmute = { path = "../rustc_transmute", features = ["rustc"] }
|
rustc_transmute = { path = "../rustc_transmute", features = ["rustc"] }
|
||||||
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||||
|
itertools = "0.10.1"
|
||||||
|
@ -4,6 +4,7 @@ use super::infcx_ext::InferCtxtExt;
|
|||||||
#[cfg(doc)]
|
#[cfg(doc)]
|
||||||
use super::trait_goals::structural_traits::*;
|
use super::trait_goals::structural_traits::*;
|
||||||
use super::{CanonicalResponse, Certainty, EvalCtxt, Goal, MaybeCause, QueryResult};
|
use super::{CanonicalResponse, Certainty, EvalCtxt, Goal, MaybeCause, QueryResult};
|
||||||
|
use itertools::Itertools;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
use rustc_infer::traits::query::NoSolution;
|
use rustc_infer::traits::query::NoSolution;
|
||||||
use rustc_infer::traits::util::elaborate_predicates;
|
use rustc_infer::traits::util::elaborate_predicates;
|
||||||
@ -489,9 +490,9 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are *STILL* multiple candidates, give up
|
// If there are *STILL* multiple candidates that have *different* response
|
||||||
// and report ambiguity.
|
// results, give up and report ambiguity.
|
||||||
if candidates.len() > 1 {
|
if candidates.len() > 1 && !candidates.iter().map(|cand| cand.result).all_equal() {
|
||||||
let certainty = if candidates.iter().all(|x| {
|
let certainty = if candidates.iter().all(|x| {
|
||||||
matches!(x.result.value.certainty, Certainty::Maybe(MaybeCause::Overflow))
|
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)
|
Ok(self.discard_reservation_impl(candidates.pop().unwrap()).result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// known-bug: unknown
|
|
||||||
// compile-flags: -Ztrait-solver=next
|
// compile-flags: -Ztrait-solver=next
|
||||||
|
// check-pass
|
||||||
|
|
||||||
// This tests checks that we update results in the provisional cache when
|
// This tests checks that we update results in the provisional cache when
|
||||||
// we pop a goal from the stack.
|
// we pop a goal from the stack.
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
error[E0283]: type annotations needed: cannot satisfy `Bar<T>: Coinductive`
|
|
||||||
--> $DIR/provisional-result-done.rs:16:25
|
|
||||||
|
|
|
||||||
LL | impl<T> Coinductive for Bar<T>
|
|
||||||
| ^^^^^^
|
|
||||||
|
|
|
||||||
= note: cannot satisfy `Bar<T>: Coinductive`
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0283`.
|
|
Loading…
Reference in New Issue
Block a user