Skip to content

Commit 18bb23f

Browse files
committed
---
yaml --- r: 40642 b: refs/heads/dist-snap c: 1282fc8 h: refs/heads/master v: v3
1 parent 6400dff commit 18bb23f

File tree

19 files changed

+144
-88
lines changed

19 files changed

+144
-88
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
99
refs/heads/incoming: e90142e536c150df0d9b4b2f11352152177509b5
10-
refs/heads/dist-snap: a05ba09d904b366f467479cb022c76f287befa43
10+
refs/heads/dist-snap: 1282fc80740b5c462a094c45f65cb1ce0c1d7756
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libcore/path.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ impl PosixPath : GenericPath {
502502
let mut v = copy self.components;
503503
let mut ss = str::split_nonempty(s, |c| windows::is_sep(c as u8));
504504
unsafe { v.push_all_move(move ss); }
505-
PosixPath { components: move v, ..self }
505+
PosixPath { components: move v, ..copy self }
506506
}
507507

508508
pure fn pop() -> PosixPath {
@@ -707,7 +707,7 @@ impl WindowsPath : GenericPath {
707707
let mut v = copy self.components;
708708
let mut ss = str::split_nonempty(s, |c| windows::is_sep(c as u8));
709709
unsafe { v.push_all_move(move ss); }
710-
return WindowsPath { components: move v, ..self }
710+
return WindowsPath { components: move v, ..copy self }
711711
}
712712

713713
pure fn pop() -> WindowsPath {

branches/dist-snap/src/libcore/task/mod.rs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -215,25 +215,25 @@ pub type TaskOpts = {
215215
// the run function move them in.
216216

217217
// FIXME (#3724): Replace the 'consumed' bit with move mode on self
218-
pub enum TaskBuilder = {
218+
pub struct TaskBuilder {
219219
opts: TaskOpts,
220220
gen_body: fn@(v: fn~()) -> fn~(),
221221
can_not_copy: Option<util::NonCopyable>,
222222
mut consumed: bool,
223-
};
223+
}
224224

225225
/**
226226
* Generate the base configuration for spawning a task, off of which more
227227
* configuration methods can be chained.
228228
* For example, task().unlinked().spawn is equivalent to spawn_unlinked.
229229
*/
230230
pub fn task() -> TaskBuilder {
231-
TaskBuilder({
231+
TaskBuilder {
232232
opts: default_task_opts(),
233233
gen_body: |body| move body, // Identity function
234234
can_not_copy: None,
235235
mut consumed: false,
236-
})
236+
}
237237
}
238238

239239
#[doc(hidden)] // FIXME #3538
@@ -244,7 +244,7 @@ priv impl TaskBuilder {
244244
}
245245
self.consumed = true;
246246
let notify_chan = replace(&mut self.opts.notify_chan, None);
247-
TaskBuilder({
247+
TaskBuilder {
248248
opts: {
249249
linked: self.opts.linked,
250250
supervised: self.opts.supervised,
@@ -254,7 +254,7 @@ priv impl TaskBuilder {
254254
gen_body: self.gen_body,
255255
can_not_copy: None,
256256
mut consumed: false
257-
})
257+
}
258258
}
259259
}
260260

@@ -265,16 +265,16 @@ impl TaskBuilder {
265265
*/
266266
fn unlinked() -> TaskBuilder {
267267
let notify_chan = replace(&mut self.opts.notify_chan, None);
268-
TaskBuilder({
268+
TaskBuilder {
269269
opts: {
270270
linked: false,
271271
supervised: self.opts.supervised,
272272
mut notify_chan: move notify_chan,
273273
sched: self.opts.sched
274274
},
275275
can_not_copy: None,
276-
.. *self.consume()
277-
})
276+
.. self.consume()
277+
}
278278
}
279279
/**
280280
* Unidirectionally link the child task's failure with the parent's. The
@@ -283,33 +283,33 @@ impl TaskBuilder {
283283
*/
284284
fn supervised() -> TaskBuilder {
285285
let notify_chan = replace(&mut self.opts.notify_chan, None);
286-
TaskBuilder({
286+
TaskBuilder {
287287
opts: {
288288
linked: false,
289289
supervised: true,
290290
mut notify_chan: move notify_chan,
291291
sched: self.opts.sched
292292
},
293293
can_not_copy: None,
294-
.. *self.consume()
295-
})
294+
.. self.consume()
295+
}
296296
}
297297
/**
298298
* Link the child task's and parent task's failures. If either fails, the
299299
* other will be killed.
300300
*/
301301
fn linked() -> TaskBuilder {
302302
let notify_chan = replace(&mut self.opts.notify_chan, None);
303-
TaskBuilder({
303+
TaskBuilder {
304304
opts: {
305305
linked: true,
306306
supervised: false,
307307
mut notify_chan: move notify_chan,
308308
sched: self.opts.sched
309309
},
310310
can_not_copy: None,
311-
.. *self.consume()
312-
})
311+
.. self.consume()
312+
}
313313
}
314314

315315
/**
@@ -345,30 +345,30 @@ impl TaskBuilder {
345345
blk(move notify_pipe_po);
346346
347347
// Reconfigure self to use a notify channel.
348-
TaskBuilder({
348+
TaskBuilder {
349349
opts: {
350350
linked: self.opts.linked,
351351
supervised: self.opts.supervised,
352352
mut notify_chan: Some(move notify_pipe_ch),
353353
sched: self.opts.sched
354354
},
355355
can_not_copy: None,
356-
.. *self.consume()
357-
})
356+
.. self.consume()
357+
}
358358
}
359359
/// Configure a custom scheduler mode for the task.
360360
fn sched_mode(mode: SchedMode) -> TaskBuilder {
361361
let notify_chan = replace(&mut self.opts.notify_chan, None);
362-
TaskBuilder({
362+
TaskBuilder {
363363
opts: {
364364
linked: self.opts.linked,
365365
supervised: self.opts.supervised,
366366
mut notify_chan: move notify_chan,
367367
sched: Some({ mode: mode, foreign_stack_size: None})
368368
},
369369
can_not_copy: None,
370-
.. *self.consume()
371-
})
370+
.. self.consume()
371+
}
372372
}
373373
374374
/**
@@ -386,7 +386,7 @@ impl TaskBuilder {
386386
fn add_wrapper(wrapper: fn@(v: fn~()) -> fn~()) -> TaskBuilder {
387387
let prev_gen_body = self.gen_body;
388388
let notify_chan = replace(&mut self.opts.notify_chan, None);
389-
TaskBuilder({
389+
TaskBuilder {
390390
opts: {
391391
linked: self.opts.linked,
392392
supervised: self.opts.supervised,
@@ -399,8 +399,8 @@ impl TaskBuilder {
399399
gen_body: |move prev_gen_body,
400400
body| { wrapper(prev_gen_body(move body)) },
401401
can_not_copy: None,
402-
.. *self.consume()
403-
})
402+
.. self.consume()
403+
}
404404
}
405405
406406
/**
@@ -782,11 +782,11 @@ fn test_spawn_linked_sup_fail_up() { // child fails; parent fails
782782
};
783783

784784
let b0 = task();
785-
let b1 = TaskBuilder({
785+
let b1 = TaskBuilder {
786786
opts: move opts,
787787
can_not_copy: None,
788788
.. *b0
789-
});
789+
};
790790
do b1.spawn { fail; }
791791
comm::recv(po); // We should get punted awake
792792
}
@@ -802,11 +802,11 @@ fn test_spawn_linked_sup_fail_down() { // parent fails; child fails
802802
};
803803

804804
let b0 = task();
805-
let b1 = TaskBuilder({
805+
let b1 = TaskBuilder {
806806
opts: move opts,
807807
can_not_copy: None,
808808
.. *b0
809-
});
809+
};
810810
do b1.spawn { loop { task::yield(); } }
811811
fail; // *both* mechanisms would be wrong if this didn't kill the child...
812812
}

branches/dist-snap/src/librustc/middle/borrowck/check_loans.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
// 3. assignments do not affect things loaned out as immutable
1818
// 4. moves to dnot affect things loaned out in any way
1919

20+
use middle::ty::{CopyValue, MoveValue, ReadValue};
21+
2022
use dvec::DVec;
2123

2224
export check_loans;
@@ -624,6 +626,12 @@ fn check_loans_in_expr(expr: @ast::expr,
624626

625627
self.check_for_conflicting_loans(expr.id);
626628

629+
// If this is a move, check it.
630+
match self.tcx().value_modes.find(expr.id) {
631+
Some(MoveValue) => self.check_move_out(expr),
632+
Some(ReadValue) | Some(CopyValue) | None => {}
633+
}
634+
627635
match expr.node {
628636
ast::expr_path(*) if self.bccx.last_use_map.contains_key(expr.id) => {
629637
self.check_last_use(expr);

branches/dist-snap/src/librustc/middle/mode.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use syntax::ast::{expr_addr_of, expr_assign_op, expr_binary, expr_call};
99
use syntax::ast::{expr_copy, expr_field, expr_index, expr_method_call};
1010
use syntax::ast::{expr_path, expr_swap, expr_unary, node_id, sty_uniq};
1111
use syntax::ast::{sty_value};
12-
use syntax::ast::{box, uniq, deref, not, neg, expr_paren};
12+
use syntax::ast::{box, uniq, deref, not, neg, expr_match, expr_paren};
1313
use syntax::visit;
1414
use syntax::visit::vt;
1515

@@ -158,6 +158,21 @@ fn compute_modes_for_expr(expr: @expr,
158158
compute_modes_for_expr(arg, cx, v);
159159
record_mode_for_expr(expr, cx);
160160
}
161+
expr_match(head, ref arms) => {
162+
let by_move_bindings_present =
163+
pat_util::arms_have_by_move_bindings(cx.tcx.def_map, *arms);
164+
if by_move_bindings_present {
165+
// Propagate the current mode flag downward.
166+
visit::visit_expr(expr, cx, v);
167+
} else {
168+
// We aren't moving into any pattern, so this is just a read.
169+
let head_cx = VisitContext { mode: ReadValue, ..cx };
170+
compute_modes_for_expr(head, head_cx, v);
171+
for arms.each |arm| {
172+
(v.visit_arm)(*arm, cx, v);
173+
}
174+
}
175+
}
161176
_ => {
162177
// XXX: Spell out every expression above so when we add them we
163178
// don't forget to update this file.

branches/dist-snap/src/librustc/middle/pat_util.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::map::HashMap;
1919
export pat_binding_ids, pat_bindings, pat_id_map, PatIdMap;
2020
export pat_is_variant_or_struct, pat_is_binding, pat_is_binding_or_wild;
2121
export pat_is_const;
22+
export arms_have_by_move_bindings;
2223

2324
type PatIdMap = std::map::HashMap<ident, node_id>;
2425

@@ -91,3 +92,22 @@ fn pat_binding_ids(dm: resolve::DefMap, pat: @pat) -> ~[node_id] {
9192
pat_bindings(dm, pat, |_bm, b_id, _sp, _pt| found.push(b_id) );
9293
return found;
9394
}
95+
96+
fn arms_have_by_move_bindings(dm: resolve::DefMap, +arms: &[arm]) -> bool {
97+
for arms.each |arm| {
98+
for arm.pats.each |pat| {
99+
let mut found = false;
100+
do pat_bindings(dm, *pat) |binding_mode, _node_id, _span, _path| {
101+
match binding_mode {
102+
bind_by_move => found = true,
103+
bind_by_implicit_ref |
104+
bind_by_ref(*) |
105+
bind_by_value => {}
106+
}
107+
}
108+
if found { return true; }
109+
}
110+
}
111+
return false;
112+
}
113+

branches/dist-snap/src/librustdoc/attr_pass.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ of the natural-language documentation for a crate.
1818

1919
use doc::ItemUtils;
2020
use extract::to_str;
21+
use fold::Fold;
2122
use syntax::ast;
2223
use syntax::ast_map;
2324
use std::map::HashMap;
@@ -33,14 +34,14 @@ fn run(
3334
srv: astsrv::Srv,
3435
+doc: doc::Doc
3536
) -> doc::Doc {
36-
let fold = fold::Fold({
37+
let fold = Fold {
3738
fold_crate: fold_crate,
3839
fold_item: fold_item,
3940
fold_enum: fold_enum,
4041
fold_trait: fold_trait,
4142
fold_impl: fold_impl,
42-
.. *fold::default_any_fold(srv)
43-
});
43+
.. fold::default_any_fold(srv)
44+
};
4445
(fold.fold_doc)(&fold, doc)
4546
}
4647

branches/dist-snap/src/librustdoc/desc_to_brief_pass.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ is interpreted as the brief description.
1616
*/
1717

1818
use doc::ItemUtils;
19+
use fold::Fold;
1920

2021
pub fn mk_pass() -> Pass {
2122
{
@@ -28,12 +29,12 @@ fn run(
2829
_srv: astsrv::Srv,
2930
+doc: doc::Doc
3031
) -> doc::Doc {
31-
let fold = fold::Fold({
32+
let fold = Fold {
3233
fold_item: fold_item,
3334
fold_trait: fold_trait,
3435
fold_impl: fold_impl,
35-
.. *fold::default_any_fold(())
36-
});
36+
.. fold::default_any_fold(())
37+
};
3738
(fold.fold_doc)(&fold, doc)
3839
}
3940

0 commit comments

Comments
 (0)