about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-02-07 14:08:38 +0000
committerbors <bors@rust-lang.org>2015-02-07 14:08:38 +0000
commit8661b3dc0fbb9e21b94266ba62e23cebb8f0603f (patch)
tree7b140bc2081a78ce5de68e6dc57ff3b8ced62fb0 /src/libsyntax
parent80627cd3cc4099b76cb2fb26ebe2f2f8a6c2335e (diff)
parent4583272bf5054e84c4c59ba3b9334a52cfcf5208 (diff)
downloadrust-8661b3dc0fbb9e21b94266ba62e23cebb8f0603f.tar.gz
rust-8661b3dc0fbb9e21b94266ba62e23cebb8f0603f.zip
Auto merge of #21971 - pnkfelix:fsk-restrict-fixdsz-array-moves, r=nikomatsakis
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]
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index 7e1bf7a2230..71259ff5d9a 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -924,13 +924,13 @@ impl TokenTree {
                 let v = [TtToken(sp, token::Dollar),
                          TtToken(sp, token::Ident(token::str_to_ident(var.as_str()),
                                                   token::Plain))];
-                v[index]
+                v[index].clone()
             }
             (&TtToken(sp, token::MatchNt(name, kind, name_st, kind_st)), _) => {
                 let v = [TtToken(sp, token::SubstNt(name, name_st)),
                          TtToken(sp, token::Colon),
                          TtToken(sp, token::Ident(kind, kind_st))];
-                v[index]
+                v[index].clone()
             }
             (&TtSequence(_, ref seq), _) => {
                 seq.tts[index].clone()