Implement a dummy drop-in-favor-of for the new solver
This commit is contained in:
parent
8c67ecd124
commit
8987e68247
@ -3,7 +3,7 @@
|
||||
use super::assembly::{self, Candidate, CandidateSource};
|
||||
use super::infcx_ext::InferCtxtExt;
|
||||
use super::trait_goals::structural_traits;
|
||||
use super::{Certainty, EvalCtxt, Goal, QueryResult};
|
||||
use super::{Certainty, EvalCtxt, Goal, MaybeCause, QueryResult};
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::DefId;
|
||||
@ -182,11 +182,17 @@ fn merge_project_candidates(
|
||||
// If there are *STILL* multiple candidates, give up
|
||||
// and report ambiguity.
|
||||
i += 1;
|
||||
if i > 1 {
|
||||
debug!("multiple matches, ambig");
|
||||
// FIXME: return overflow if all candidates overflow, otherwise return ambiguity.
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
|
||||
if candidates.len() > 1 {
|
||||
let certainty = if candidates.iter().all(|x| {
|
||||
matches!(x.result.value.certainty, Certainty::Maybe(MaybeCause::Overflow))
|
||||
}) {
|
||||
Certainty::Maybe(MaybeCause::Overflow)
|
||||
} else {
|
||||
Certainty::AMBIGUOUS
|
||||
};
|
||||
return self.make_canonical_response(certainty);
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,7 +209,7 @@ fn project_candidate_should_be_dropped_in_favor_of(
|
||||
(CandidateSource::Impl(_), _)
|
||||
| (CandidateSource::ParamEnv(_), _)
|
||||
| (CandidateSource::BuiltinImpl, _)
|
||||
| (CandidateSource::AliasBound, _) => unimplemented!(),
|
||||
| (CandidateSource::AliasBound, _) => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -452,7 +458,8 @@ fn consider_builtin_pointee_candidate(
|
||||
[ty::GenericArg::from(goal.predicate.self_ty())],
|
||||
));
|
||||
|
||||
let is_sized_certainty = ecx.evaluate_goal(goal.with(tcx, sized_predicate))?.1;
|
||||
let (_, is_sized_certainty) =
|
||||
ecx.evaluate_goal(goal.with(tcx, sized_predicate))?;
|
||||
return ecx.eq_term_and_make_canonical_response(
|
||||
goal,
|
||||
is_sized_certainty,
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
use super::assembly::{self, Candidate, CandidateSource};
|
||||
use super::infcx_ext::InferCtxtExt;
|
||||
use super::{CanonicalResponse, Certainty, EvalCtxt, Goal, QueryResult};
|
||||
use super::{CanonicalResponse, Certainty, EvalCtxt, Goal, MaybeCause, QueryResult};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_infer::infer::InferCtxt;
|
||||
use rustc_infer::traits::query::NoSolution;
|
||||
@ -511,11 +511,17 @@ pub(super) fn merge_trait_candidates_discard_reservation_impls(
|
||||
// If there are *STILL* multiple candidates, give up
|
||||
// and report ambiguity.
|
||||
i += 1;
|
||||
if i > 1 {
|
||||
debug!("multiple matches, ambig");
|
||||
// FIXME: return overflow if all candidates overflow, otherwise return ambiguity.
|
||||
unimplemented!();
|
||||
}
|
||||
}
|
||||
|
||||
if candidates.len() > 1 {
|
||||
let certainty = if candidates.iter().all(|x| {
|
||||
matches!(x.result.value.certainty, Certainty::Maybe(MaybeCause::Overflow))
|
||||
}) {
|
||||
Certainty::Maybe(MaybeCause::Overflow)
|
||||
} else {
|
||||
Certainty::AMBIGUOUS
|
||||
};
|
||||
return self.make_canonical_response(certainty);
|
||||
}
|
||||
}
|
||||
|
||||
@ -532,17 +538,18 @@ fn trait_candidate_should_be_dropped_in_favor_of(
|
||||
(CandidateSource::Impl(_), _)
|
||||
| (CandidateSource::ParamEnv(_), _)
|
||||
| (CandidateSource::AliasBound, _)
|
||||
| (CandidateSource::BuiltinImpl, _) => unimplemented!(),
|
||||
| (CandidateSource::BuiltinImpl, _) => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn discard_reservation_impl(&self, candidate: Candidate<'tcx>) -> Candidate<'tcx> {
|
||||
fn discard_reservation_impl(&self, mut candidate: Candidate<'tcx>) -> Candidate<'tcx> {
|
||||
if let CandidateSource::Impl(def_id) = candidate.source {
|
||||
if let ty::ImplPolarity::Reservation = self.tcx().impl_polarity(def_id) {
|
||||
debug!("Selected reservation impl");
|
||||
// FIXME: reduce candidate to ambiguous
|
||||
// FIXME: replace `var_values` with identity, yeet external constraints.
|
||||
unimplemented!()
|
||||
// We assemble all candidates inside of a probe so by
|
||||
// making a new canonical response here our result will
|
||||
// have no constraints.
|
||||
candidate.result = self.make_canonical_response(Certainty::AMBIGUOUS).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,5 @@
|
||||
// known-bug: unknown
|
||||
// compile-flags: -Ztrait-solver=next
|
||||
// failure-status: 101
|
||||
// normalize-stderr-test "note: .*\n\n" -> ""
|
||||
// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
|
||||
// rustc-env:RUST_BACKTRACE=0
|
||||
|
||||
// This tests checks that we update results in the provisional cache when
|
||||
// we pop a goal from the stack.
|
||||
|
@ -1,6 +1,11 @@
|
||||
error: the compiler unexpectedly panicked. this is a bug.
|
||||
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`
|
||||
|
||||
query stack during panic:
|
||||
#0 [check_well_formed] checking that `<impl at $DIR/provisional-result-done.rs:20:1: 20:31>` is well-formed
|
||||
#1 [check_mod_type_wf] checking that types are well-formed in top-level module
|
||||
end of query stack
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0283`.
|
||||
|
22
tests/ui/traits/new-solver/temporary-ambiguity.rs
Normal file
22
tests/ui/traits/new-solver/temporary-ambiguity.rs
Normal file
@ -0,0 +1,22 @@
|
||||
// compile-flags: -Ztrait-solver=next
|
||||
// check-pass
|
||||
|
||||
// Checks that we don't explode when we assemble >1 candidate for a goal.
|
||||
|
||||
struct Wrapper<T>(T);
|
||||
|
||||
trait Foo {}
|
||||
|
||||
impl Foo for Wrapper<i32> {}
|
||||
|
||||
impl Foo for Wrapper<()> {}
|
||||
|
||||
fn needs_foo(_: impl Foo) {}
|
||||
|
||||
fn main() {
|
||||
let mut x = Default::default();
|
||||
let w = Wrapper(x);
|
||||
needs_foo(w);
|
||||
x = 1;
|
||||
drop(x);
|
||||
}
|
Loading…
Reference in New Issue
Block a user