1
Fork 0

Auto merge of #112636 - clubby789:no-capture-array-ref, r=cjgillot

Don't capture `&[T; N]` when contents isn't read

Fixes the check in #111831
Fixes #112607, although I decided to test the root cause rather than including the example in the issue as a test.
cc `@BoxyUwU`
This commit is contained in:
bors 2023-06-18 15:48:08 +00:00
commit 939786223f
3 changed files with 66 additions and 19 deletions

View file

@ -443,7 +443,7 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
if matches!((lhs, wild, rhs), (&[], Some(_), &[]))
// Arrays have a statically known size, so
// there is no need to read their length
|| discr_place.place.base_ty.is_array()
|| place.place.ty().peel_refs().is_array()
{
} else {
needs_to_be_read = true;