Skip to content

Commit 193e668

Browse files
Rollup merge of #118243 - lcnr:commit-if-ok, r=compiler-errors
EvalCtxt::commit_if_ok don't inherit nested goals we use it to check whether an alias is rigid, so we want to avoid considering an alias rigid simply because the inference constraints from normalizing it caused another nested goal fail r? `@compiler-errors`
2 parents 9c1b029 + 42a9b0d commit 193e668

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

Diff for: compiler/rustc_trait_selection/src/solve/eval_ctxt/commit_if_ok.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::EvalCtxt;
1+
use super::{EvalCtxt, NestedGoals};
22
use crate::solve::inspect;
33
use rustc_middle::traits::query::NoSolution;
44

@@ -14,7 +14,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
1414
predefined_opaques_in_body: self.predefined_opaques_in_body,
1515
max_input_universe: self.max_input_universe,
1616
search_graph: self.search_graph,
17-
nested_goals: self.nested_goals.clone(),
17+
nested_goals: NestedGoals::new(),
1818
tainted: self.tainted,
1919
inspect: self.inspect.new_probe(),
2020
};
@@ -32,7 +32,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
3232
tainted,
3333
inspect,
3434
} = nested_ecx;
35-
self.nested_goals = nested_goals;
35+
self.nested_goals.extend(nested_goals);
3636
self.tainted = tainted;
3737
self.inspect.integrate_snapshot(inspect);
3838
} else {

Diff for: compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,19 @@ pub(super) struct NestedGoals<'tcx> {
108108
pub(super) goals: Vec<Goal<'tcx, ty::Predicate<'tcx>>>,
109109
}
110110

111-
impl NestedGoals<'_> {
111+
impl<'tcx> NestedGoals<'tcx> {
112112
pub(super) fn new() -> Self {
113113
Self { normalizes_to_hack_goal: None, goals: Vec::new() }
114114
}
115115

116116
pub(super) fn is_empty(&self) -> bool {
117117
self.normalizes_to_hack_goal.is_none() && self.goals.is_empty()
118118
}
119+
120+
pub(super) fn extend(&mut self, other: NestedGoals<'tcx>) {
121+
assert_eq!(other.normalizes_to_hack_goal, None);
122+
self.goals.extend(other.goals)
123+
}
119124
}
120125

121126
#[derive(PartialEq, Eq, Debug, Hash, HashStable, Clone, Copy)]

Diff for: compiler/rustc_trait_selection/src/solve/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,6 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
334334
}
335335
}
336336

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

0 commit comments

Comments
 (0)