about summary refs log tree commit diff
diff options
context:
space:
mode:
authorlcnr <rust@lcnr.de>2023-11-24 15:20:02 +0100
committerlcnr <rust@lcnr.de>2023-11-24 15:22:10 +0100
commit42a9b0d7abe12968f7c0c6f0f3ca4deb0b12973e (patch)
tree6263053526687e3510e5f2796616a329fde5b4f6
parent7bd385dc371a85219c4261f0cb5ba7c83b7e0c5e (diff)
downloadrust-42a9b0d7abe12968f7c0c6f0f3ca4deb0b12973e.tar.gz
rust-42a9b0d7abe12968f7c0c6f0f3ca4deb0b12973e.zip
EvalCtxt::commit_if_ok don't inherit nested goals
-rw-r--r--compiler/rustc_trait_selection/src/solve/eval_ctxt/commit_if_ok.rs6
-rw-r--r--compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs7
-rw-r--r--compiler/rustc_trait_selection/src/solve/mod.rs5
3 files changed, 9 insertions, 9 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt/commit_if_ok.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt/commit_if_ok.rs
index c47152c601c..67b6801059a 100644
--- a/compiler/rustc_trait_selection/src/solve/eval_ctxt/commit_if_ok.rs
+++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt/commit_if_ok.rs
@@ -1,4 +1,4 @@
-use super::EvalCtxt;
+use super::{EvalCtxt, NestedGoals};
 use crate::solve::inspect;
 use rustc_middle::traits::query::NoSolution;
 
@@ -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(),
         };
@@ -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 {
diff --git a/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs b/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs
index 23ce0a301ce..e9d7e6675b4 100644
--- a/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs
+++ b/compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs
@@ -108,7 +108,7 @@ 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() }
     }
@@ -116,6 +116,11 @@ impl NestedGoals<'_> {
     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)]
diff --git a/compiler/rustc_trait_selection/src/solve/mod.rs b/compiler/rustc_trait_selection/src/solve/mod.rs
index 65d061ab3f4..0cf4799f86d 100644
--- a/compiler/rustc_trait_selection/src/solve/mod.rs
+++ b/compiler/rustc_trait_selection/src/solve/mod.rs
@@ -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(