Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
01d6c04
Link to Option/Result for `Iterator::sum/product`
clubby789 Jan 4, 2023
ed63201
replace usage of `evaluate_goal` with a new `add_goal`
BoxyUwU Mar 16, 2023
ee31e5f
review nits
BoxyUwU Mar 17, 2023
ea08d3a
add assert
BoxyUwU Mar 17, 2023
ce14a1e
add comments
BoxyUwU Mar 17, 2023
e06c62c
UNACEPTABLE
BoxyUwU Mar 17, 2023
aa8de17
fix let else unformatting
BoxyUwU Mar 17, 2023
e624ef4
replace chain with two `add_goal`
BoxyUwU Mar 17, 2023
9df35a5
fix bad assertion
BoxyUwU Mar 17, 2023
b85bc19
move `compute_goal` and `evaluate_x` methods to inner module
BoxyUwU Mar 17, 2023
69a82f7
add myself to mailmap
aDotInTheVoid Mar 19, 2023
9f80c75
Walk un-shifted nested `impl Trait` in trait when setting up default …
compiler-errors Mar 16, 2023
239ec6c
drive-by: Fix a comment in TyCtxt::fold_regions and remove an unused …
compiler-errors Mar 17, 2023
5b4fa5b
fix typo
lcnr Mar 20, 2023
8e4e55e
Support aggregate expressions
cbeuw Mar 20, 2023
e24f5ac
Fix off-by-one in mir syntax doc
cbeuw Mar 20, 2023
f404f33
Use builtin_index instead of match
cbeuw Mar 20, 2023
f321144
Add example for `Option::product` and `Result::product`
clubby789 Jan 4, 2023
cbb8066
Avoid ICE of attempt to add with overflow in emitter
chenyukang Mar 20, 2023
5058cc8
not *all* retags might be explicit in Runtime MIR
RalfJung Mar 20, 2023
720cc40
Enforce non-lifetime-binders in supertrait preds are not object safe
compiler-errors Mar 7, 2023
76534b5
Rollup merge of #106434 - clubby789:document-sum-result, r=the8472
matthiaskrgr Mar 21, 2023
5f3afc7
Rollup merge of #108842 - compiler-errors:non_lifetime_binders-object…
matthiaskrgr Mar 21, 2023
20d3000
Rollup merge of #108896 - BoxyUwU:new_solver_add_goal_fn, r=lcnr
matthiaskrgr Mar 21, 2023
7c4ea5e
Rollup merge of #109240 - compiler-errors:dont-binder-twice, r=oli-obk
matthiaskrgr Mar 21, 2023
5cbee82
Rollup merge of #109385 - lcnr:typo, r=Dylan-DPC
matthiaskrgr Mar 21, 2023
18d8690
Rollup merge of #109386 - aDotInTheVoid:mailmap, r=WaffleLapkin
matthiaskrgr Mar 21, 2023
a9f7860
Rollup merge of #109390 - cbeuw:aggregate-lit, r=oli-obk
matthiaskrgr Mar 21, 2023
0271c1c
Rollup merge of #109403 - chenyukang:yukang/fix-109396, r=estebank
matthiaskrgr Mar 21, 2023
7939ee6
Rollup merge of #109408 - RalfJung:retags, r=compiler-errors
matthiaskrgr Mar 21, 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
review nits
  • Loading branch information
BoxyUwU committed Mar 17, 2023
commit ee31e5fc57499cd7a97b7e0564425324b0186688
6 changes: 6 additions & 0 deletions compiler/rustc_trait_selection/src/solve/eval_ctxt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ pub struct EvalCtxt<'a, 'tcx> {
pub(super) nested_goals: NestedGoals<'tcx>,
}

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub(super) enum IsNormalizesToHack {
Yes,
No,
}

#[derive(Debug, Clone)]
pub(super) struct NestedGoals<'tcx> {
pub(super) projection_eq_hack_goal: Option<Goal<'tcx, ty::ProjectionPredicate<'tcx>>>,
Expand Down
26 changes: 12 additions & 14 deletions compiler/rustc_trait_selection/src/solve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ mod trait_goals;
pub use eval_ctxt::EvalCtxt;
pub use fulfill::FulfillmentCtxt;

use self::eval_ctxt::NestedGoals;
use self::eval_ctxt::{IsNormalizesToHack, NestedGoals};

trait CanonicalResponseExt {
fn has_no_inference_or_external_constraints(&self) -> bool;
Expand Down Expand Up @@ -86,7 +86,7 @@ impl<'tcx> InferCtxtEvalExt<'tcx> for InferCtxt<'tcx> {
var_values: CanonicalVarValues::dummy(),
nested_goals: NestedGoals::new(),
}
.evaluate_goal(false, goal);
.evaluate_goal(IsNormalizesToHack::No, goal);

assert!(search_graph.is_empty());
result
Expand Down Expand Up @@ -130,7 +130,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
/// been constrained and the certainty of the result.
fn evaluate_goal(
&mut self,
is_projection_eq_hack_goal: bool,
is_normalizes_to_hack: IsNormalizesToHack,
goal: Goal<'tcx, ty::Predicate<'tcx>>,
) -> Result<(bool, Certainty), NoSolution> {
let (orig_values, canonical_goal) = self.canonicalize_goal(goal);
Expand All @@ -153,7 +153,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
// solver cycle.
if cfg!(debug_assertions)
&& has_changed
&& !is_projection_eq_hack_goal
&& is_normalizes_to_hack == IsNormalizesToHack::No
&& !self.search_graph.in_cycle()
{
debug!("rerunning goal to check result is stable");
Expand Down Expand Up @@ -223,11 +223,8 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
} else {
let kind = self.infcx.instantiate_binder_with_placeholders(kind);
let goal = goal.with(self.tcx(), ty::Binder::dummy(kind));
// `false` is fine to use as if this were a projection goal from the hack there would not be
// a binder as the real projection goal that is the parent of the hack goal would have already
// had its binder replaced with placeholders.
let (_, certainty) = self.evaluate_goal(false, goal)?;
self.evaluate_added_goals_and_make_canonical_response(certainty)
self.add_goal(goal);
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
}
}

Expand Down Expand Up @@ -436,7 +433,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {

if let Some(goal) = goals.projection_eq_hack_goal.take() {
let (_, certainty) = match this.evaluate_goal(
true,
IsNormalizesToHack::Yes,
goal.with(this.tcx(), ty::Binder::dummy(goal.predicate)),
) {
Ok(r) => r,
Expand Down Expand Up @@ -480,10 +477,11 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
}

for nested_goal in goals.goals.drain(..) {
let (changed, certainty) = match this.evaluate_goal(false, nested_goal) {
Ok(result) => result,
Err(NoSolution) => return Some(Err(NoSolution)),
};
let (changed, certainty) =
match this.evaluate_goal(IsNormalizesToHack::No, nested_goal) {
Ok(result) => result,
Err(NoSolution) => return Some(Err(NoSolution)),
};

if changed {
has_changed = Ok(());
Expand Down