@@ -179,7 +179,7 @@ impl<'tcx> ConstToPat<'tcx> {
179179 }
180180
181181 if let Some ( non_sm_ty) = structural {
182- if !self . type_may_have_partial_eq_impl ( cv. ty ( ) ) {
182+ if !self . type_has_partial_eq_impl ( cv. ty ( ) ) {
183183 if let ty:: Adt ( def, ..) = non_sm_ty. kind ( ) {
184184 if def. is_union ( ) {
185185 let err = UnionPattern { span : self . span } ;
@@ -244,7 +244,7 @@ impl<'tcx> ConstToPat<'tcx> {
244244
245245 // Always check for `PartialEq`, even if we emitted other lints. (But not if there were
246246 // any errors.) This ensures it shows up in cargo's future-compat reports as well.
247- if !self . type_may_have_partial_eq_impl ( cv. ty ( ) ) {
247+ if !self . type_has_partial_eq_impl ( cv. ty ( ) ) {
248248 self . tcx ( ) . emit_spanned_lint (
249249 lint:: builtin:: MATCH_WITHOUT_PARTIAL_EQ ,
250250 self . id ,
@@ -258,7 +258,7 @@ impl<'tcx> ConstToPat<'tcx> {
258258 }
259259
260260 #[ instrument( level = "trace" , skip( self ) , ret) ]
261- fn type_may_have_partial_eq_impl ( & self , ty : Ty < ' tcx > ) -> bool {
261+ fn type_has_partial_eq_impl ( & self , ty : Ty < ' tcx > ) -> bool {
262262 // double-check there even *is* a semantic `PartialEq` to dispatch to.
263263 //
264264 // (If there isn't, then we can safely issue a hard
@@ -273,8 +273,13 @@ impl<'tcx> ConstToPat<'tcx> {
273273 ty:: TraitRef :: new ( self . tcx ( ) , partial_eq_trait_id, [ ty, ty] ) ,
274274 ) ;
275275
276- // FIXME: should this call a `predicate_must_hold` variant instead?
277- self . infcx . predicate_may_hold ( & partial_eq_obligation)
276+ // This *could* conservatively fail when outlives obligations are required.
277+ // However, we anyway require all `PartialEq` to be derived, so that shouldn't be possible.
278+ // If this ever becomes a problem, we need to somehow leave a note in the MIR body
279+ // asking borrowck to precisely check that the relevant types actually *do*
280+ // implement `PartialEq`, even if we don't end up calling `PartialEq::eq`
281+ // in the generated code.
282+ self . infcx . predicate_must_hold_considering_regions ( & partial_eq_obligation)
278283 }
279284
280285 fn field_pats (
0 commit comments