The following should trigger a warning that we can only match on PartialEq consts, but it doesn't: (example by @lcnr, then slightly tweaked) ```rust use std::marker::PhantomData; struct Inv<'a>(PhantomData<*mut &'a ()>); // This type is only sometimes `PartialEq`. impl PartialEq for Inv<'static> { fn eq(&self, _: &Inv<'static>) -> bool { true } } impl<'a> Inv<'a> { // The value `None` makes this have structural equality for any type `Self`. const NOT_STATIC: Option<Self> = None; } fn foo<'a>(x: Option<Inv<'a>>) { match x { Inv::<'a>::NOT_STATIC => (), Some(_) => panic!() } // Enabling the next line confirms that the type does // indeed not implement `PartialEq`. //x == Inv::<'a>::NOT_STATIC; } fn main() { foo(None) } ``` Here is [another example](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=183a1d779e2b26eabec2dc43ee31a40f) of the same issue. The problem is that we call `predicate_must_hold_modulo_regions` [here](https://github.com/rust-lang/rust/blob/9f58cf43c78e77b59479da2beaea0265f529280e/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs#L257), but only borrowck knows the actual lifetimes and borrowck has no idea that this trait obligation even exists. We should leave some sort of trace in MIR that there is a PartialEq obligations to ensure borrowck can check this with the right lifetimes.