Restrictions on moves into and out-from fixed-length arrays. #21930
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Restrictions on moves into and out-from fixed-length arrays.
(There was only one use of this "feature" in the compiler source.)
Note 1: the change to the error message in
tests/compile-fail/borrowck-use-in-index-lvalue.rs
, where we now report that*w
is uninitialized (rather thanw
), was unintended fallout from the implementation strategy used here. The change appears harmless to me, but I welcome advice on how to bring back the old message, which was slightly cleaner (i.e. less unintelligible) since that the syntactic form*w
does not actually appear in the source text.Note 2: the move out-from restriction to only apply to
expr[i]
, and not destructuring bind (e.g.f([a, b, c]: Array) { ... }
) since the latter is compatible with nonzeroing drop, AFAICT.borrowck::gather_loans::gather_moves
, and welcome suggestions on ways to do it without accessing theast_map
, but preferably also without changing theexpr_use_visitor
API.)This addresses RFC PR 533: rust-lang/rfcs#533 (which is not yet merged).
[breaking-change]