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 crate::traits::{specialization_graph, translate_substs};
|
|||||||
use super::assembly::{self, Candidate, CandidateSource};
|
use super::assembly::{self, Candidate, CandidateSource};
|
||||||
use super::infcx_ext::InferCtxtExt;
|
use super::infcx_ext::InferCtxtExt;
|
||||||
use super::trait_goals::structural_traits;
|
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_errors::ErrorGuaranteed;
|
||||||
use rustc_hir::def::DefKind;
|
use rustc_hir::def::DefKind;
|
||||||
use rustc_hir::def_id::DefId;
|
use rustc_hir::def_id::DefId;
|
||||||
@ -182,11 +182,17 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||||||
// If there are *STILL* multiple candidates, give up
|
// If there are *STILL* multiple candidates, give up
|
||||||
// and report ambiguity.
|
// and report ambiguity.
|
||||||
i += 1;
|
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 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||||||
(CandidateSource::Impl(_), _)
|
(CandidateSource::Impl(_), _)
|
||||||
| (CandidateSource::ParamEnv(_), _)
|
| (CandidateSource::ParamEnv(_), _)
|
||||||
| (CandidateSource::BuiltinImpl, _)
|
| (CandidateSource::BuiltinImpl, _)
|
||||||
| (CandidateSource::AliasBound, _) => unimplemented!(),
|
| (CandidateSource::AliasBound, _) => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -452,7 +458,8 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
|
|||||||
[ty::GenericArg::from(goal.predicate.self_ty())],
|
[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(
|
return ecx.eq_term_and_make_canonical_response(
|
||||||
goal,
|
goal,
|
||||||
is_sized_certainty,
|
is_sized_certainty,
|
||||||
|
@ -4,7 +4,7 @@ use std::iter;
|
|||||||
|
|
||||||
use super::assembly::{self, Candidate, CandidateSource};
|
use super::assembly::{self, Candidate, CandidateSource};
|
||||||
use super::infcx_ext::InferCtxtExt;
|
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_hir::def_id::DefId;
|
||||||
use rustc_infer::infer::InferCtxt;
|
use rustc_infer::infer::InferCtxt;
|
||||||
use rustc_infer::traits::query::NoSolution;
|
use rustc_infer::traits::query::NoSolution;
|
||||||
@ -511,11 +511,17 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||||||
// If there are *STILL* multiple candidates, give up
|
// If there are *STILL* multiple candidates, give up
|
||||||
// and report ambiguity.
|
// and report ambiguity.
|
||||||
i += 1;
|
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 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
|
|||||||
(CandidateSource::Impl(_), _)
|
(CandidateSource::Impl(_), _)
|
||||||
| (CandidateSource::ParamEnv(_), _)
|
| (CandidateSource::ParamEnv(_), _)
|
||||||
| (CandidateSource::AliasBound, _)
|
| (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 CandidateSource::Impl(def_id) = candidate.source {
|
||||||
if let ty::ImplPolarity::Reservation = self.tcx().impl_polarity(def_id) {
|
if let ty::ImplPolarity::Reservation = self.tcx().impl_polarity(def_id) {
|
||||||
debug!("Selected reservation impl");
|
debug!("Selected reservation impl");
|
||||||
// FIXME: reduce candidate to ambiguous
|
// We assemble all candidates inside of a probe so by
|
||||||
// FIXME: replace `var_values` with identity, yeet external constraints.
|
// making a new canonical response here our result will
|
||||||
unimplemented!()
|
// have no constraints.
|
||||||
|
candidate.result = self.make_canonical_response(Certainty::AMBIGUOUS).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
// known-bug: unknown
|
// known-bug: unknown
|
||||||
// compile-flags: -Ztrait-solver=next
|
// 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
|
// 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,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:
|
error: aborting due to previous error
|
||||||
#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
|
For more information about this error, try `rustc --explain E0283`.
|
||||||
end of query stack
|
|
||||||
|
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…
x
Reference in New Issue
Block a user