@@ -385,11 +385,11 @@ impl<'tcx> ConstToPat<'tcx> {
385
385
self . behind_reference . set ( old) ;
386
386
val
387
387
}
388
- // Backwards compatibility hack: support references to non-structural types.
389
- // We'll lower
390
- // this pattern to a `PartialEq::eq` comparison and `PartialEq::eq` takes a
391
- // reference. This makes the rest of the matching logic simpler as it doesn't have
392
- // to figure out how to get a reference again .
388
+ // Backwards compatibility hack: support references to non-structural types,
389
+ // but hard error if we aren't behind a double reference. We could just use
390
+ // the fallback code path below, but that would allow *more* of this fishy
391
+ // code to compile, as then it only goes through the future incompat lint
392
+ // instead of a hard error .
393
393
ty:: Adt ( _, _) if !self . type_marked_structural ( * pointee_ty) => {
394
394
if self . behind_reference . get ( ) {
395
395
if !self . saw_const_match_error . get ( )
@@ -427,10 +427,6 @@ impl<'tcx> ConstToPat<'tcx> {
427
427
PatKind :: Wild
428
428
} else {
429
429
let old = self . behind_reference . replace ( true ) ;
430
- // In case there are structural-match violations somewhere in this subpattern,
431
- // we fall back to a const pattern. If we do not do this, we may end up with
432
- // a !structural-match constant that is not of reference type, which makes it
433
- // very hard to invoke `PartialEq::eq` on it as a fallback.
434
430
let subpattern = self . recur ( tcx. deref_mir_constant ( self . param_env . and ( cv) ) , false ) ?;
435
431
self . behind_reference . set ( old) ;
436
432
PatKind :: Deref { subpattern }
0 commit comments