@@ -385,11 +385,11 @@ impl<'tcx> ConstToPat<'tcx> {
385385 self . behind_reference . set ( old) ;
386386 val
387387 }
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 .
393393 ty:: Adt ( _, _) if !self . type_marked_structural ( * pointee_ty) => {
394394 if self . behind_reference . get ( ) {
395395 if !self . saw_const_match_error . get ( )
@@ -427,10 +427,6 @@ impl<'tcx> ConstToPat<'tcx> {
427427 PatKind :: Wild
428428 } else {
429429 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.
434430 let subpattern = self . recur ( tcx. deref_mir_constant ( self . param_env . and ( cv) ) , false ) ?;
435431 self . behind_reference . set ( old) ;
436432 PatKind :: Deref { subpattern }
0 commit comments