This commit is contained in:
lcnr 2025-09-26 16:37:03 +02:00
parent d6fe533418
commit c2e39c2f20
2 changed files with 13 additions and 7 deletions

View file

@ -2192,6 +2192,15 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
&self,
trait_predicate: Option<ty::Predicate<'tcx>>,
) -> bool {
// This function is what hacky and doesn't perfectly do what we want it to.
// It's not soundness critical and we should be able to freely improve this
// in the future.
//
// Some concrete edge cases include the fact that `goal_may_hold_opaque_types_jank`
// also fails if there are any constraints opaques which are never used as a self
// type. We also allow where-bounds which are currently ambiguous but end up
// constraining an opaque later on.
// Check whether the trait candidate would not be applicable if the
// opaque type were rigid.
if let Some(predicate) = trait_predicate {

View file

@ -87,14 +87,11 @@ impl<'tcx> InferCtxt<'tcx> {
{
// While we ignore region constraints and pending obligations,
// we do return constrained opaque types to avoid unconstrained
// inference variables in the response. This is still slightly
// insufficient as ambiguous `Projection` obligations have the
// same issue.
// inference variables in the response. This is important as we want
// to check that opaques in deref steps stay unconstrained.
//
// FIXME(-Znext-solver): We could alternatively extend the `var_values`
// each time we call `make_query_response_ignoring_pending_obligations`
// and equate inference variables created inside of the query this way.
// This is what we do for `CanonicalState` and is probably a bit nicer.
// This doesn't handle the more general case for non-opaques as
// ambiguous `Projection` obligations have same the issue.
let opaque_types = if self.next_trait_solver() {
self.inner
.borrow_mut()