@@ -179,7 +179,7 @@ impl<'tcx> ConstToPat<'tcx> {
179
179
}
180
180
181
181
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 ( ) ) {
183
183
if let ty:: Adt ( def, ..) = non_sm_ty. kind ( ) {
184
184
if def. is_union ( ) {
185
185
let err = UnionPattern { span : self . span } ;
@@ -244,7 +244,7 @@ impl<'tcx> ConstToPat<'tcx> {
244
244
245
245
// Always check for `PartialEq`, even if we emitted other lints. (But not if there were
246
246
// 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 ( ) ) {
248
248
self . tcx ( ) . emit_spanned_lint (
249
249
lint:: builtin:: MATCH_WITHOUT_PARTIAL_EQ ,
250
250
self . id ,
@@ -258,7 +258,7 @@ impl<'tcx> ConstToPat<'tcx> {
258
258
}
259
259
260
260
#[ 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 {
262
262
// double-check there even *is* a semantic `PartialEq` to dispatch to.
263
263
//
264
264
// (If there isn't, then we can safely issue a hard
@@ -273,8 +273,13 @@ impl<'tcx> ConstToPat<'tcx> {
273
273
ty:: TraitRef :: new ( self . tcx ( ) , partial_eq_trait_id, [ ty, ty] ) ,
274
274
) ;
275
275
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)
278
283
}
279
284
280
285
fn field_pats (
0 commit comments