Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EvalCtxt::commit_if_ok don't inherit nested goals #118243

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::EvalCtxt;
use super::{EvalCtxt, NestedGoals};
use crate::solve::inspect;
use rustc_middle::traits::query::NoSolution;

Expand All @@ -14,7 +14,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
predefined_opaques_in_body: self.predefined_opaques_in_body,
max_input_universe: self.max_input_universe,
search_graph: self.search_graph,
nested_goals: self.nested_goals.clone(),
nested_goals: NestedGoals::new(),
tainted: self.tainted,
inspect: self.inspect.new_probe(),
};
Expand All @@ -32,7 +32,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
tainted,
inspect,
} = nested_ecx;
self.nested_goals = nested_goals;
self.nested_goals.extend(nested_goals);
self.tainted = tainted;
self.inspect.integrate_snapshot(inspect);
} else {
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,19 @@ pub(super) struct NestedGoals<'tcx> {
pub(super) goals: Vec<Goal<'tcx, ty::Predicate<'tcx>>>,
}

impl NestedGoals<'_> {
impl<'tcx> NestedGoals<'tcx> {
pub(super) fn new() -> Self {
Self { normalizes_to_hack_goal: None, goals: Vec::new() }
}

pub(super) fn is_empty(&self) -> bool {
self.normalizes_to_hack_goal.is_none() && self.goals.is_empty()
}

pub(super) fn extend(&mut self, other: NestedGoals<'tcx>) {
assert_eq!(other.normalizes_to_hack_goal, None);
self.goals.extend(other.goals)
}
}

#[derive(PartialEq, Eq, Debug, Hash, HashStable, Clone, Copy)]
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_trait_selection/src/solve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,6 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
}
}

// FIXME(@lcnr): If the normalization of the alias adds an inference constraint which
// causes a previously added goal to fail, then we treat the alias as rigid.
//
// These feels like a potential issue, I should look into writing some tests here
// and then probably changing `commit_if_ok` to not inherit the parent goals.
match self.commit_if_ok(|this| {
let normalized_ty = this.next_ty_infer();
let normalizes_to_goal = Goal::new(
Expand Down