Skip to content

Commit

Permalink
Add -Ztrait-solver=next-coherence
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Jun 6, 2023
1 parent e0acff7 commit b637048
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2337,6 +2337,14 @@ impl<'tcx> TyCtxt<'tcx> {
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
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,7 @@ mod parse {
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,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_trait_selection/src/traits/coherence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_trait_selection/src/traits/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
}
Expand All @@ -43,6 +44,7 @@ impl<'tcx> TraitEngineExt<'tcx> for dyn TraitEngine<'tcx> {
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()),
}
Expand Down

0 comments on commit b637048

Please sign in to comment.