Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3122db7
Implement `SpecOptionPartialEq` for `cmp::Ordering`
scottmcm Jan 18, 2023
da3ecb0
Use proper InferCtxt when probing for associated types in astconv
compiler-errors Jan 22, 2023
800f1f3
Liberate late-bound regions correctly
compiler-errors Jan 25, 2023
b83ab0c
Suggest mutable borrows correctly
compiler-errors Jan 25, 2023
381187d
internally change regions to be covariant
aliemjay Jan 26, 2023
43cb610
update comment on trait objects
aliemjay Jan 27, 2023
e5995e6
Don't merge vtables when full debuginfo is enabled.
michaelwoerister Jan 27, 2023
5bfd90e
Use now solver in evaluate_obligation
compiler-errors Jan 27, 2023
80a1536
recover more unbraced const args
fmease Jan 22, 2023
ff2413d
No need to probe when computing goals
compiler-errors Jan 27, 2023
0654374
Add some comments
compiler-errors Jan 27, 2023
8a0b215
Micro-optimization in consider_assumption
compiler-errors Jan 27, 2023
3e9d1e4
Link to the LLVM issue from a comment on `SpecOptionPartialEq`
scottmcm Jan 28, 2023
7b78b6a
Rollup merge of #107022 - scottmcm:ordering-option-eq, r=m-ou-se
matthiaskrgr Jan 28, 2023
28188d1
Rollup merge of #107100 - compiler-errors:issue-107087, r=lcnr
matthiaskrgr Jan 28, 2023
3b6593a
Rollup merge of #107103 - compiler-errors:new-solver-evaluate_obligat…
matthiaskrgr Jan 28, 2023
260e048
Rollup merge of #107190 - fmease:fix-81698, r=compiler-errors
matthiaskrgr Jan 28, 2023
fa2cd94
Rollup merge of #107306 - compiler-errors:correct-sugg-for-closure-ar…
matthiaskrgr Jan 28, 2023
a5caa98
Rollup merge of #107339 - aliemjay:covariant, r=lcnr
matthiaskrgr Jan 28, 2023
ab769a0
Rollup merge of #107344 - compiler-errors:new-solver-tweaks, r=lcnr
matthiaskrgr Jan 28, 2023
c89bb15
Rollup merge of #107373 - michaelwoerister:dont-merge-vtables-when-de…
matthiaskrgr Jan 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use now solver in evaluate_obligation
  • Loading branch information
compiler-errors committed Jan 27, 2023
commit 5bfd90efd121cace34bccdf6fe47578b2202bdf9
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use rustc_middle::ty;
use rustc_session::config::TraitSolver;

use crate::infer::canonical::OriginalQueryValues;
use crate::infer::InferCtxt;
use crate::solve::{Certainty, Goal, InferCtxtEvalExt, MaybeCause};
use crate::traits::{EvaluationResult, OverflowError, PredicateObligation, SelectionContext};

pub trait InferCtxtExt<'tcx> {
Expand Down Expand Up @@ -77,12 +79,38 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
_ => obligation.param_env.without_const(),
};

let c_pred = self
.canonicalize_query_keep_static(param_env.and(obligation.predicate), &mut _orig_values);
// Run canonical query. If overflow occurs, rerun from scratch but this time
// in standard trait query mode so that overflow is handled appropriately
// within `SelectionContext`.
self.tcx.at(obligation.cause.span()).evaluate_obligation(c_pred)
if self.tcx.sess.opts.unstable_opts.trait_solver != TraitSolver::Next {
let c_pred = self.canonicalize_query_keep_static(
param_env.and(obligation.predicate),
&mut _orig_values,
);
self.tcx.at(obligation.cause.span()).evaluate_obligation(c_pred)
} else {
self.probe(|snapshot| {
if let Ok((_, certainty)) =
self.evaluate_root_goal(Goal::new(self.tcx, param_env, obligation.predicate))
{
match certainty {
Certainty::Yes => {
if self.opaque_types_added_in_snapshot(snapshot) {
Ok(EvaluationResult::EvaluatedToOkModuloOpaqueTypes)
} else if self.region_constraints_added_in_snapshot(snapshot).is_some()
{
Ok(EvaluationResult::EvaluatedToOkModuloRegions)
} else {
Ok(EvaluationResult::EvaluatedToOk)
}
}
Certainty::Maybe(MaybeCause::Ambiguity) => {
Ok(EvaluationResult::EvaluatedToAmbig)
}
Certainty::Maybe(MaybeCause::Overflow) => Err(OverflowError::Canonical),
}
} else {
Ok(EvaluationResult::EvaluatedToErr)
}
})
}
}

// Helper function that canonicalizes and runs the query. If an
Expand All @@ -92,6 +120,9 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
&self,
obligation: &PredicateObligation<'tcx>,
) -> EvaluationResult {
// Run canonical query. If overflow occurs, rerun from scratch but this time
// in standard trait query mode so that overflow is handled appropriately
// within `SelectionContext`.
match self.evaluate_obligation(obligation) {
Ok(result) => result,
Err(OverflowError::Canonical) => {
Expand Down