Skip to content

leak check ignoring region constraints from normalization is sus #305

Open

Description

@lcnr

see rust-lang/rust#163928

//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver
//@ check-pass

// When proving `C::Val<'a>: for<'b> PartialEq<C::Val<'b>>` there are
// two candidates:
// - `C::Val<'a>: PartialEq<C::Val<'a>>`
// - `for<'b> C::Val<'a>: PartialEq<C::Val<'b>>`
//
// The first candidate results in an `'!b == 'a` constraint while the
// second one has no region constraints. The constraint of the first
// candidate means the canonical response has an entry for `'b` in its
// `var_values`. This previously caused us to not prefer the second
// constraint.
//
// Now, actually, the first candidate should just result in a leak check
// failure, but doesn't. That's a separate issue though :>
trait Cursor {
    type Val<'a>: PartialEq + for<'b> PartialEq<Self::Val<'b>>;
}
impl<C: Cursor> Cursor for &C {
    // for<'b> C::Val<'a>: PartialEq<C::Val<'b>>
    // -  C::Val<'a>: PartialEq<C::Val<'a>>`
    // -  for<'b> C::Val<'a>: PartialEq<C::Val<'b>>
    type Val<'a> = C::Val<'a>;
}
fn main() {}

We should not ignore the '!b == 'a constraint we get from the Projection(C::Val<'a>[non-rigid], C::Val<'!b>[rigid]) goal in the outer C::Val<'a>: for<'b> PartialEq<C::Val<'b>> goal.

this makes it observable when exactly we're normalizing C::Val<'a>[non-rigid]. This can in theory even result in ICE. Related to rust-lang/rust#155749 where we already propagate constraints from AliasRelate out to the caller. I assume this can result in HIR typeck vs MIR typeck mismatches and ICE.

Activity

  1. added 2 commits that reference this issue on Oct 30, 2026
  2. added a commit that references this issue on Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions