Skip to content

Commit 57d39a2

Browse files
committed
---
yaml --- r: 59043 b: refs/heads/incoming c: f6743fe h: refs/heads/master i: 59041: b7ffe26 59039: 0539200 v: v3
1 parent 383afef commit 57d39a2

22 files changed

+110
-48
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: 4400bbd72a18b5f034a5c43c29af87e1e453c2cb
9+
refs/heads/incoming: f6743fea70e99efc33f6890770da8c0f91723311
1010
refs/heads/dist-snap: 00dbbd01c2aee72982b3e0f9511ae1d4428c3ba9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/libcore/condition.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
use prelude::*;
1414
use task;
15-
use local_data::{local_data_pop, local_data_set};
15+
use task::local_data::{local_data_pop, local_data_set};
1616

1717
// helper for transmutation, shown below.
1818
type RustClosure = (int, int);
@@ -24,14 +24,14 @@ pub struct Handler<T, U> {
2424

2525
pub struct Condition<'self, T, U> {
2626
name: &'static str,
27-
key: local_data::LocalDataKey<'self, Handler<T, U>>
27+
key: task::local_data::LocalDataKey<'self, Handler<T, U>>
2828
}
2929

3030
pub impl<'self, T, U> Condition<'self, T, U> {
3131
fn trap(&'self self, h: &'self fn(T) -> U) -> Trap<'self, T, U> {
3232
unsafe {
3333
let p : *RustClosure = ::cast::transmute(&h);
34-
let prev = local_data::local_data_get(self.key);
34+
let prev = task::local_data::local_data_get(self.key);
3535
let h = @Handler { handle: *p, prev: prev };
3636
Trap { cond: self, handler: h }
3737
}

branches/incoming/src/libcore/core.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ pub mod trie;
215215
pub mod task;
216216
pub mod comm;
217217
pub mod pipes;
218-
pub mod local_data;
219218

220219

221220
/* Runtime and platform support */

branches/incoming/src/libcore/os.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ fn overridden_arg_key(_v: @OverriddenArgs) {}
12081208
12091209
pub fn args() -> ~[~str] {
12101210
unsafe {
1211-
match local_data::local_data_get(overridden_arg_key) {
1211+
match task::local_data::local_data_get(overridden_arg_key) {
12121212
None => real_args(),
12131213
Some(args) => copy args.val
12141214
}
@@ -1218,7 +1218,7 @@ pub fn args() -> ~[~str] {
12181218
pub fn set_args(new_args: ~[~str]) {
12191219
unsafe {
12201220
let overridden_args = @OverriddenArgs { val: copy new_args };
1221-
local_data::local_data_set(overridden_arg_key, overridden_args);
1221+
task::local_data::local_data_set(overridden_arg_key, overridden_args);
12221222
}
12231223
}
12241224

branches/incoming/src/libcore/prelude.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ pub use io;
8181
pub use iter;
8282
pub use old_iter;
8383
pub use libc;
84-
pub use local_data;
8584
pub use num;
8685
pub use ops;
8786
pub use option;

branches/incoming/src/libcore/rand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,13 +836,13 @@ fn tls_rng_state(_v: @@mut IsaacRng) {}
836836
pub fn task_rng() -> @@mut IsaacRng {
837837
let r : Option<@@mut IsaacRng>;
838838
unsafe {
839-
r = local_data::local_data_get(tls_rng_state);
839+
r = task::local_data::local_data_get(tls_rng_state);
840840
}
841841
match r {
842842
None => {
843843
unsafe {
844844
let rng = @@mut IsaacRng::new_seeded(seed());
845-
local_data::local_data_set(tls_rng_state, rng);
845+
task::local_data::local_data_set(tls_rng_state, rng);
846846
rng
847847
}
848848
}

branches/incoming/src/libcore/rt/local_services.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ mod test {
198198
199199
#[test]
200200
fn tls() {
201-
use local_data::*;
201+
use task::local_data::*;
202202
do run_in_newsched_task() {
203203
unsafe {
204204
fn key(_x: @~str) { }

branches/incoming/src/libcore/task/local_data_priv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use cmp::Eq;
1515
use libc;
1616
use prelude::*;
1717
use task::rt;
18-
use local_data::LocalDataKey;
18+
use task::local_data::LocalDataKey;
1919

2020
use super::rt::rust_task;
2121
use rt::local_services::LocalStorage;

branches/incoming/src/libcore/task/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ use unstable::finally::Finally;
4747
#[cfg(test)] use comm::SharedChan;
4848

4949
mod local_data_priv;
50+
pub mod local_data;
5051
pub mod rt;
5152
pub mod spawn;
5253

branches/incoming/src/librustc/middle/check_match.rs

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -822,43 +822,65 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt,
822822
}
823823
}
824824
825-
// Now check to ensure that any move binding is not behind an @ or &.
826-
// This is always illegal.
825+
// Now check to ensure that any move binding is not behind an
826+
// @ or &, or within a struct with a destructor. This is
827+
// always illegal.
827828
let vt = visit::mk_vt(@visit::Visitor {
828-
visit_pat: |pat, behind_bad_pointer: bool, v| {
829+
visit_pat: |pat, (behind_bad_pointer, behind_dtor_struct): (bool, bool), v| {
829830
match pat.node {
830831
pat_ident(_, _, sub) => {
831832
debug!("(check legality of move) checking pat \
832-
ident with behind_bad_pointer %?",
833-
behind_bad_pointer);
833+
ident with behind_bad_pointer %? and behind_dtor_struct %?",
834+
behind_bad_pointer, behind_dtor_struct);
834835
835-
if behind_bad_pointer &&
836+
if behind_bad_pointer || behind_dtor_struct &&
836837
cx.moves_map.contains(&pat.id)
837838
{
838-
cx.tcx.sess.span_err(
839-
pat.span,
840-
"by-move pattern \
841-
bindings may not occur \
842-
behind @ or & bindings");
839+
let msg = if behind_bad_pointer {
840+
"by-move pattern bindings may not occur behind @ or & bindings"
841+
} else {
842+
"cannot bind by-move within struct (it has a destructor)"
843+
};
844+
cx.tcx.sess.span_err(pat.span, msg);
843845
}
844846
845847
match sub {
846848
None => {}
847849
Some(subpat) => {
848-
(v.visit_pat)(subpat, behind_bad_pointer, v);
850+
(v.visit_pat)(subpat,
851+
(behind_bad_pointer, behind_dtor_struct),
852+
v);
849853
}
850854
}
851855
}
852856
853857
pat_box(subpat) | pat_region(subpat) => {
854-
(v.visit_pat)(subpat, true, v);
858+
(v.visit_pat)(subpat, (true, behind_dtor_struct), v);
855859
}
856860
857-
_ => visit::visit_pat(pat, behind_bad_pointer, v)
861+
pat_struct(_, ref fields, _) => {
862+
let behind_dtor_struct = behind_dtor_struct ||
863+
(match cx.tcx.def_map.find(&pat.id) {
864+
Some(&def_struct(id)) => {
865+
ty::has_dtor(cx.tcx, id)
866+
}
867+
_ => false
868+
});
869+
debug!("(check legality of move) checking pat \
870+
struct with behind_bad_pointer %? and behind_dtor_struct %?",
871+
behind_bad_pointer, behind_dtor_struct);
872+
873+
for fields.each |fld| {
874+
(v.visit_pat)(fld.pat, (behind_bad_pointer,
875+
behind_dtor_struct), v)
876+
}
877+
}
878+
879+
_ => visit::visit_pat(pat, (behind_bad_pointer, behind_dtor_struct), v)
858880
}
859881
},
860-
.. *visit::default_visitor::<bool>()
882+
.. *visit::default_visitor::<(bool, bool)>()
861883
});
862-
(vt.visit_pat)(*pat, false, vt);
884+
(vt.visit_pat)(*pat, (false, false), vt);
863885
}
864886
}

branches/incoming/src/librustc/middle/typeck/check/_match.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,6 @@ pub fn check_struct_pat(pcx: &pat_ctxt, pat_id: ast::node_id, span: span,
340340
}
341341
}
342342

343-
// Forbid pattern-matching structs with destructors.
344-
if ty::has_dtor(tcx, class_id) {
345-
tcx.sess.span_err(span, "deconstructing struct not allowed in pattern \
346-
(it has a destructor)");
347-
}
348-
349343
check_struct_pat_fields(pcx, span, path, fields, class_fields, class_id,
350344
substitutions, etc);
351345
}

branches/incoming/src/librustdoc/extract.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use astsrv;
1414
use doc::ItemUtils;
1515
use doc;
1616

17-
use core::local_data::local_data_get;
17+
use core::task::local_data::local_data_get;
1818
use syntax::ast;
1919
use syntax;
2020

branches/incoming/src/libstd/rl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ fn complete_key(_v: @CompletionCb) {}
6969

7070
/// Bind to the main completion callback
7171
pub unsafe fn complete(cb: CompletionCb) {
72-
local_data::local_data_set(complete_key, @(cb));
72+
task::local_data::local_data_set(complete_key, @(cb));
7373

7474
extern fn callback(line: *c_char, completions: *()) {
7575
unsafe {
76-
let cb = *local_data::local_data_get(complete_key)
76+
let cb = *task::local_data::local_data_get(complete_key)
7777
.get();
7878

7979
do cb(str::raw::from_c_str(line)) |suggestion| {

branches/incoming/src/libstd/sort.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,11 +1211,11 @@ mod big_tests {
12111211
#[unsafe_destructor]
12121212
impl<'self> Drop for LVal<'self> {
12131213
fn finalize(&self) {
1214-
let x = unsafe { local_data::local_data_get(self.key) };
1214+
let x = unsafe { task::local_data::local_data_get(self.key) };
12151215
match x {
12161216
Some(@y) => {
12171217
unsafe {
1218-
local_data::local_data_set(self.key, @(y+1));
1218+
task::local_data::local_data_set(self.key, @(y+1));
12191219
}
12201220
}
12211221
_ => fail!(~"Expected key to work"),

branches/incoming/src/libstd/sort_stage0.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,11 +1202,11 @@ mod big_tests {
12021202
#[unsafe_destructor]
12031203
impl<'self> Drop for LVal<'self> {
12041204
fn finalize(&self) {
1205-
let x = unsafe { local_data::local_data_get(self.key) };
1205+
let x = unsafe { task::local_data::local_data_get(self.key) };
12061206
match x {
12071207
Some(@y) => {
12081208
unsafe {
1209-
local_data::local_data_set(self.key, @(y+1));
1209+
task::local_data::local_data_set(self.key, @(y+1));
12101210
}
12111211
}
12121212
_ => fail!(~"Expected key to work"),

branches/incoming/src/libsyntax/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<S:Encoder> Encodable<S> for ident {
7474
fn encode(&self, s: &mut S) {
7575
unsafe {
7676
let intr =
77-
match local_data::local_data_get(interner_key!()) {
77+
match task::local_data::local_data_get(interner_key!()) {
7878
None => fail!(~"encode: TLS interner not set up"),
7979
Some(intr) => intr
8080
};
@@ -87,7 +87,7 @@ impl<S:Encoder> Encodable<S> for ident {
8787
impl<D:Decoder> Decodable<D> for ident {
8888
fn decode(d: &mut D) -> ident {
8989
let intr = match unsafe {
90-
local_data::local_data_get(interner_key!())
90+
task::local_data::local_data_get(interner_key!())
9191
} {
9292
None => fail!(~"decode: TLS interner not set up"),
9393
Some(intr) => intr

branches/incoming/src/libsyntax/parse/token.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ pub fn mk_fresh_ident_interner() -> @ident_interner {
462462
interner: interner::Interner::prefill(init_vec)
463463
};
464464
unsafe {
465-
local_data::local_data_set(interner_key!(), @rv);
465+
task::local_data::local_data_set(interner_key!(), @rv);
466466
}
467467
rv
468468
}
@@ -471,7 +471,7 @@ pub fn mk_fresh_ident_interner() -> @ident_interner {
471471
// fresh one.
472472
pub fn mk_ident_interner() -> @ident_interner {
473473
unsafe {
474-
match local_data::local_data_get(interner_key!()) {
474+
match task::local_data::local_data_get(interner_key!()) {
475475
Some(interner) => *interner,
476476
None => {
477477
mk_fresh_ident_interner()

branches/incoming/src/test/compile-fail/core-tls-store-pointer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
// Testing that we can't store a borrowed pointer it task-local storage
1212

13-
use core::local_data::*;
13+
use core::task::local_data::*;
1414

1515
fn key(_x: @&int) { }
1616

1717
fn main() {
1818
unsafe {
1919
local_data_set(key, @&0); //~ ERROR does not fulfill `'static`
2020
}
21-
}
21+
}

branches/incoming/src/test/compile-fail/disallowed-deconstructing-destructing-struct.rs renamed to branches/incoming/src/test/compile-fail/disallowed-deconstructing-destructing-struct-let.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// xfail-test
12
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
23
// file at the top-level directory of this distribution and at
34
// http://rust-lang.org/COPYRIGHT.
@@ -19,7 +20,7 @@ impl Drop for X {
1920
}
2021

2122
fn unwrap(x: X) -> ~str {
22-
let X { x: y } = x; //~ ERROR deconstructing struct not allowed in pattern
23+
let X { x: y } = x; //~ ERROR cannot bind by-move within struct
2324
y
2425
}
2526

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct X {
12+
x: ~str,
13+
}
14+
15+
impl Drop for X {
16+
fn finalize(&self) {
17+
error!("value: %s", self.x);
18+
}
19+
}
20+
21+
fn main() {
22+
let x = X { x: ~"hello" };
23+
24+
match x {
25+
X { x: y } => error!("contents: %s", y)
26+
//~^ ERROR cannot bind by-move within struct
27+
}
28+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[deriving(Eq)]
12+
struct A { x: uint }
13+
14+
impl Drop for A {
15+
fn finalize(&self) {}
16+
}
17+
18+
fn main() {}

0 commit comments

Comments
 (0)