Update some comments

This commit is contained in:
Oli Scherer 2023-04-06 10:02:33 +00:00
parent ad424e65d8
commit 87f9f99f9c

View file

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