-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Restrictions on moves into and out-from fixed-length arrays. #21971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bors
merged 5 commits into
rust-lang:master
from
pnkfelix:fsk-restrict-fixdsz-array-moves
Feb 7, 2015
Merged
Restrictions on moves into and out-from fixed-length arrays. #21971
bors
merged 5 commits into
rust-lang:master
from
pnkfelix:fsk-restrict-fixdsz-array-moves
Feb 7, 2015
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r? @pcwalton (rust_highfive has picked a reviewer for you, use r? to override) |
@pnkfelix r+ modulo nits. |
31c7fff
to
0e60c27
Compare
@bors r=nikomatsakis 0e60c27 |
⌛ Testing commit 0e60c27 with merge d347b18... |
💔 Test failed - auto-win-32-nopt-t |
No longer legal: `fn foo(a: [D; 5]) { drop(a); a[2] = D::new(); }`; one must first initialize the entirety of `a` before assigning to its individual elements. No longer legal: `fn foo(arr: [D; 5]) -> D { arr[2] }`, unless `D` implements `Copy`. This "move out-from" restriction only affects `expr[i]`, and not destructuring (e.g. `f([a, b, c]: Array) { ... }`). uses mem_categorization to distinguish destructuring-bind from array indexing. See discussion on RFC PR 533. [breaking-change]
Note that the change to the error message in borrowck-use-in-index-lvalue.rs, where we report that `*w` is uninitialized rather than `w`, 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). ---- drive-by: revise compile-fail/borrowck-vec-pattern-move-tail to make it really clear that there is a conflict that must be signaled. (A hypothetical future version of Rust might be able to accept the prior version of the code, since the previously updated index was not actually aliased.)
0e60c27
to
4583272
Compare
bors
added a commit
that referenced
this pull request
Feb 7, 2015
…komatsakis Revised version of PR #21930. 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 than w), 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. [breaking-change]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Revised version of PR #21930.
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.[breaking-change]