fixup the refactoring errors in 156246

This commit is contained in:
Jana Dönszelmann
2026-06-24 14:53:00 +02:00
parent 40557f6225
commit c200d2fa56
5 changed files with 32 additions and 62 deletions

View File

@@ -462,7 +462,7 @@ where
Ok(i) => Ok(i),
Err(NoSolutionOrRerunNonErased::NoSolution(NoSolution)) => Err(NoSolution),
Err(NoSolutionOrRerunNonErased::RerunNonErased(_)) => {
// check th t the opaque_accesses state mirrors the result we got.
// Check that the opaque_accesses state mirrors the result we got.
assert!(opaque_accesses.should_bail().is_err());
Err(NoSolution)
}
@@ -1442,7 +1442,7 @@ where
uv: ty::UnevaluatedConst<I>,
) -> Result<Option<I::Const>, RerunNonErased> {
if self.typing_mode().is_erased_not_coherence() {
self.opaque_accesses.rerun_always(RerunReason::EvaluateConst)?;
match self.opaque_accesses.rerun_always(RerunReason::EvaluateConst)? {}
}
Ok(self.delegate.evaluate_const(param_env, uv))
@@ -1515,7 +1515,7 @@ where
symbol: I::Symbol,
) -> Result<bool, RerunNonErased> {
if self.typing_mode().is_erased_not_coherence() {
self.opaque_accesses.rerun_always(RerunReason::MayUseUnstableFeature)?;
match self.opaque_accesses.rerun_always(RerunReason::MayUseUnstableFeature)? {}
}
Ok(may_use_unstable_feature(&**self.delegate, param_env, symbol))

View File

@@ -98,10 +98,8 @@ where
outer.opaque_accesses.update(nested.opaque_accesses)?;
let r = match r.map_err_to_rerun()? {
Ok(i) => Ok(i),
Err(NoSolution) => Err(NoSolution),
};
// Unwrap is unreachable, we would have returned on the line above.
let r = r.map_err_to_rerun().unwrap();
if !nested.inspect.is_noop() {
let probe_kind = probe_kind(&r);

View File

@@ -81,15 +81,10 @@ where
None
},
|ecx| {
ecx.probe(|&result| ProbeKind::RigidAlias { result })
.enter(|this| {
this.structurally_instantiate_normalizes_to_term(
goal,
goal.predicate.alias,
);
this.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
})
.map_err(Into::into)
ecx.probe(|&result| ProbeKind::RigidAlias { result }).enter(|this| {
this.structurally_instantiate_normalizes_to_term(goal, goal.predicate.alias);
this.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
})
},
)
}
@@ -351,11 +346,9 @@ where
GoalSource::Misc,
goal.with(cx, PredicateKind::Ambiguous),
)?;
return ecx
.evaluate_added_goals_and_make_canonical_response(
Certainty::Yes,
)
.map_err(Into::into);
return ecx.evaluate_added_goals_and_make_canonical_response(
Certainty::Yes,
);
}
// Outside of coherence, we treat the associated item as rigid instead.
ty::TypingMode::Typeck { .. }
@@ -367,11 +360,9 @@ where
goal,
goal.predicate.alias,
);
return ecx
.evaluate_added_goals_and_make_canonical_response(
Certainty::Yes,
)
.map_err(Into::into);
return ecx.evaluate_added_goals_and_make_canonical_response(
Certainty::Yes,
);
}
};
}
@@ -401,10 +392,10 @@ where
// This is not the case here and we only prefer adding an ambiguous
// nested goal for consistency.
ecx.add_goal(GoalSource::Misc, goal.with(cx, PredicateKind::Ambiguous))?;
return then(ecx, Certainty::Yes).map_err(Into::into);
return then(ecx, Certainty::Yes);
} else {
ecx.structurally_instantiate_normalizes_to_term(goal, goal.predicate.alias);
return then(ecx, Certainty::Yes).map_err(Into::into);
return then(ecx, Certainty::Yes);
}
} else {
return error_response(ecx, cx.delay_bug("missing item"));
@@ -472,7 +463,7 @@ where
};
ecx.instantiate_normalizes_to_term(goal, term)?;
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes).map_err(Into::into)
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
})
}
@@ -572,7 +563,6 @@ where
pred,
[(GoalSource::ImplWhereBound, goal.with(cx, output_is_sized_pred))],
)
.map_err(Into::into)
}
fn consider_builtin_async_fn_trait_candidates(
@@ -759,8 +749,9 @@ where
// and opaque types: If the `self_ty` is `Sized`, then the metadata is `()`.
// FIXME(ptr_metadata): This impl overlaps with the other impls and shouldn't
// exist. Instead, `Pointee<Metadata = ()>` should be a supertrait of `Sized`.
let alias_bound_result =
ecx.probe_builtin_trait_candidate(BuiltinImplSource::Misc).enter(|ecx| {
let alias_bound_result = ecx
.probe_builtin_trait_candidate(BuiltinImplSource::Misc)
.enter(|ecx| {
let sized_predicate = ty::TraitRef::new(
cx,
cx.require_trait_lang_item(SolverTraitLangItem::Sized),
@@ -769,12 +760,8 @@ where
ecx.add_goal(GoalSource::Misc, goal.with(cx, sized_predicate))?;
ecx.instantiate_normalizes_to_term(goal, Ty::new_unit(cx).into())?;
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
});
let alias_bound_result = match alias_bound_result.map_err_to_rerun()? {
Ok(i) => Ok(i),
Err(NoSolution) => Err(NoSolution),
};
})
.map_err_to_rerun()?;
// In case the dummy alias-bound candidate does not apply, we instead treat this projection
// as rigid.
@@ -900,7 +887,6 @@ where
// but that's already proven by the generator being WF.
[],
)
.map_err(Into::into)
}
fn consider_builtin_fused_iterator_candidate(

View File

@@ -4,7 +4,7 @@ use std::marker::PhantomData;
use rustc_type_ir::data_structures::ensure_sufficient_stack;
use rustc_type_ir::search_graph::{self, PathKind};
use rustc_type_ir::solve::{
AccessedOpaques, CanonicalInput, Certainty, NoSolution, NoSolutionOrRerunNonErased, QueryResult,
AccessedOpaques, CanonicalInput, Certainty, NoSolution, QueryResult, RerunResultExt,
};
use rustc_type_ir::{Interner, MayBeErased, TypingMode};
@@ -141,17 +141,8 @@ where
) -> (QueryResult<I>, AccessedOpaques<I>) {
ensure_sufficient_stack(|| {
EvalCtxt::enter_canonical(cx, search_graph, input, inspect, |ecx, goal| {
let result = ecx.compute_goal(goal);
// if we're in `RerunNonErased`, don't even bother with inspect,
// and immediately return
let result = match result {
Ok(i) => Ok(i),
Err(NoSolutionOrRerunNonErased::NoSolution(NoSolution)) => Err(NoSolution),
Err(NoSolutionOrRerunNonErased::RerunNonErased(e)) => {
return Err(e.into());
}
};
// if we're in `RerunNonErased`, don't even bother with inspect, and immediately return
let result = ecx.compute_goal(goal).map_err_to_rerun()?;
ecx.inspect.query_result(result);
result.map_err(Into::into)

View File

@@ -119,7 +119,7 @@ where
.map(|pred| goal.with(cx, pred)),
)?;
then(ecx, maximal_certainty).map_err(Into::into)
then(ecx, maximal_certainty)
})
}
@@ -399,7 +399,6 @@ where
pred,
[(GoalSource::ImplWhereBound, goal.with(cx, output_is_sized_pred))],
)
.map_err(Into::into)
}
fn consider_builtin_async_fn_trait_candidates(
@@ -450,7 +449,6 @@ where
.chain(nested_preds.into_iter().map(|pred| goal.with(cx, pred)))
.map(|goal| (GoalSource::ImplWhereBound, goal)),
)
.map_err(Into::into)
}
fn consider_builtin_async_fn_kind_helper_candidate(
@@ -696,7 +694,7 @@ where
goal.predicate.trait_ref.args.type_at(1),
assume,
)?;
ecx.evaluate_added_goals_and_make_canonical_response(certainty).map_err(Into::into)
ecx.evaluate_added_goals_and_make_canonical_response(certainty)
},
)
}
@@ -1085,7 +1083,6 @@ where
ecx.try_evaluate_added_goals()
},
)
.map_err(Into::into)
})
.is_ok()
};
@@ -1124,11 +1121,9 @@ where
return Err(NoSolution.into());
};
if matching_projections.next().is_some() {
return ecx
.evaluate_added_goals_and_make_canonical_response(
Certainty::AMBIGUOUS,
)
.map_err(Into::into);
return ecx.evaluate_added_goals_and_make_canonical_response(
Certainty::AMBIGUOUS,
);
}
ecx.enter_forall_with_assumptions(
target_projection,
@@ -1156,7 +1151,7 @@ where
Goal::new(ecx.cx(), param_env, ty::OutlivesPredicate(a_region, b_region)),
)?;
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes).map_err(Into::into)
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
})
}