This commit is contained in:
Niko Matsakis 2021-08-27 17:13:41 -04:00
parent f34909d68f
commit c4dba5a64e

View File

@ -262,12 +262,14 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
| Res::Def(DefKind::AssocConst, _) => { | Res::Def(DefKind::AssocConst, _) => {
// Named constants have to be equated with the value // Named constants have to be equated with the value
// being matched, so that's a read of the value being matched. // being matched, so that's a read of the value being matched.
//
// FIXME: We don't actually reads for ZSTs.
needs_to_be_read = true; needs_to_be_read = true;
} }
_ => { _ => {
// Otherwise, this is a struct/enum variant, and so it's // Otherwise, this is a struct/enum variant, and so it's
// only a read if we need to read the discriminant. // only a read if we need to read the discriminant.
needs_to_be_read = is_multivariant_adt(place.place.ty()); needs_to_be_read |= is_multivariant_adt(place.place.ty());
} }
} }
} }
@ -279,9 +281,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
// perform some reads). // perform some reads).
let place_ty = place.place.ty(); let place_ty = place.place.ty();
if is_multivariant_adt(place_ty) { needs_to_be_read |= is_multivariant_adt(place_ty);
needs_to_be_read = true;
}
} }
PatKind::Lit(_) | PatKind::Range(..) => { PatKind::Lit(_) | PatKind::Range(..) => {
// If the PatKind is a Lit or a Range then we want // If the PatKind is a Lit or a Range then we want