Add -Ztrait-solver=next-coherence

This commit is contained in:
Michael Goulet 2023-05-31 01:02:40 +00:00
parent e0acff796a
commit b637048a89
5 changed files with 14 additions and 0 deletions

View File

@ -2337,6 +2337,14 @@ pub fn next_trait_solver_globally(self) -> bool {
self.sess.opts.unstable_opts.trait_solver == rustc_session::config::TraitSolver::Next
}
pub fn next_trait_solver_in_coherence(self) -> bool {
matches!(
self.sess.opts.unstable_opts.trait_solver,
rustc_session::config::TraitSolver::Next
| rustc_session::config::TraitSolver::NextCoherence
)
}
pub fn lower_impl_trait_in_trait_to_assoc_ty(self) -> bool {
self.sess.opts.unstable_opts.lower_impl_trait_in_trait_to_assoc_ty
}

View File

@ -610,6 +610,8 @@ pub enum TraitSolver {
Chalk,
/// Experimental trait solver in `rustc_trait_selection::solve`
Next,
/// Use the new trait solver during coherence
NextCoherence,
}
pub enum Input {

View File

@ -986,6 +986,7 @@ pub(crate) fn parse_trait_solver(slot: &mut TraitSolver, v: Option<&str>) -> boo
Some("classic") => *slot = TraitSolver::Classic,
Some("chalk") => *slot = TraitSolver::Chalk,
Some("next") => *slot = TraitSolver::Next,
Some("next-coherence") => *slot = TraitSolver::NextCoherence,
// default trait solver is subject to change..
Some("default") => *slot = TraitSolver::Classic,
_ => return false,

View File

@ -182,6 +182,7 @@ fn overlap<'tcx>(
.with_opaque_type_inference(DefiningAnchor::Bubble)
.skip_leak_check(skip_leak_check.is_yes())
.intercrate(true)
.with_next_trait_solver(tcx.next_trait_solver_in_coherence())
.build();
let selcx = &mut SelectionContext::new(&infcx);
if track_ambiguity_causes.is_yes() {

View File

@ -35,6 +35,7 @@ impl<'tcx> TraitEngineExt<'tcx> for dyn TraitEngine<'tcx> {
fn new(tcx: TyCtxt<'tcx>) -> Box<Self> {
match tcx.sess.opts.unstable_opts.trait_solver {
TraitSolver::Classic => Box::new(FulfillmentContext::new()),
TraitSolver::NextCoherence => Box::new(FulfillmentContext::new()),
TraitSolver::Chalk => Box::new(ChalkFulfillmentContext::new()),
TraitSolver::Next => Box::new(NextFulfillmentCtxt::new()),
}
@ -43,6 +44,7 @@ fn new(tcx: TyCtxt<'tcx>) -> Box<Self> {
fn new_in_snapshot(tcx: TyCtxt<'tcx>) -> Box<Self> {
match tcx.sess.opts.unstable_opts.trait_solver {
TraitSolver::Classic => Box::new(FulfillmentContext::new_in_snapshot()),
TraitSolver::NextCoherence => Box::new(FulfillmentContext::new_in_snapshot()),
TraitSolver::Chalk => Box::new(ChalkFulfillmentContext::new_in_snapshot()),
TraitSolver::Next => Box::new(NextFulfillmentCtxt::new()),
}