@@ -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* accept a type that isn't actually `PartialEq`, because region bounds get
277
+ // ignored. However that should be pretty much impossible since consts that do not depend on
278
+ // generics can only mention the `'static` lifetime, and how would one have a type that's
279
+ // `PartialEq` for some lifetime but *not* for `'static`? If this ever becomes a problem
280
+ // we'll need to leave some sort of trace of this requirement in the MIR so that borrowck
281
+ // can ensure that the type really implements `PartialEq`.
282
+ self . infcx . predicate_must_hold_modulo_regions ( & partial_eq_obligation)
278
283
}
279
284
280
285
fn field_pats (
0 commit comments