Skip to content

Commit 655b726

Browse files
committed
rollup merge of rust-lang#17519 : pcwalton/unboxed-closure-move-syntax
2 parents 1ebf456 + 2257e23 commit 655b726

14 files changed

+82
-81
lines changed

src/liballoc/boxed.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,6 @@ pub trait BoxAny {
9696
/// `Err(Self)` if it isn't.
9797
#[unstable = "naming conventions around accessing innards may change"]
9898
fn downcast<T: 'static>(self) -> Result<Box<T>, Self>;
99-
100-
/// Deprecated; this method has been renamed to `downcast`.
101-
#[deprecated = "use downcast instead"]
102-
fn move<T: 'static>(self) -> Result<Box<T>, Self> {
103-
self.downcast::<T>()
104-
}
10599
}
106100

107101
#[stable]

src/librustc/middle/borrowck/check_loans.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,12 +652,12 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
652652
debug!("check_if_path_is_moved(id={:?}, use_kind={:?}, lp={})",
653653
id, use_kind, lp.repr(self.bccx.tcx));
654654
let base_lp = owned_ptr_base_path_rc(lp);
655-
self.move_data.each_move_of(id, &base_lp, |move, moved_lp| {
655+
self.move_data.each_move_of(id, &base_lp, |the_move, moved_lp| {
656656
self.bccx.report_use_of_moved_value(
657657
span,
658658
use_kind,
659659
&**lp,
660-
move,
660+
the_move,
661661
moved_lp);
662662
false
663663
});

src/librustc/middle/borrowck/graphviz.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> {
108108
let move_index_to_path = |move_index| {
109109
let move_data = &self.analysis_data.move_data.move_data;
110110
let moves = move_data.moves.borrow();
111-
let move = moves.get(move_index);
112-
move_data.path_loan_path(move.path)
111+
let the_move = moves.get(move_index);
112+
move_data.path_loan_path(the_move.path)
113113
};
114114
self.build_set(e, cfgidx, dfcx, move_index_to_path)
115115
}

src/librustc/middle/borrowck/mod.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -409,14 +409,14 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
409409
use_span: Span,
410410
use_kind: MovedValueUseKind,
411411
lp: &LoanPath,
412-
move: &move_data::Move,
412+
the_move: &move_data::Move,
413413
moved_lp: &LoanPath) {
414414
let verb = match use_kind {
415415
MovedInUse => "use",
416416
MovedInCapture => "capture",
417417
};
418418

419-
match move.kind {
419+
match the_move.kind {
420420
move_data::Declared => {
421421
self.tcx.sess.span_err(
422422
use_span,
@@ -435,18 +435,20 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
435435
}
436436
}
437437

438-
match move.kind {
438+
match the_move.kind {
439439
move_data::Declared => {}
440440

441441
move_data::MoveExpr => {
442-
let (expr_ty, expr_span) = match self.tcx.map.find(move.id) {
442+
let (expr_ty, expr_span) = match self.tcx
443+
.map
444+
.find(the_move.id) {
443445
Some(ast_map::NodeExpr(expr)) => {
444446
(ty::expr_ty_adjusted(self.tcx, &*expr), expr.span)
445447
}
446448
r => {
447449
self.tcx.sess.bug(format!("MoveExpr({:?}) maps to \
448450
{:?}, not Expr",
449-
move.id,
451+
the_move.id,
450452
r).as_slice())
451453
}
452454
};
@@ -461,8 +463,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
461463
}
462464

463465
move_data::MovePat => {
464-
let pat_ty = ty::node_id_to_type(self.tcx, move.id);
465-
self.tcx.sess.span_note(self.tcx.map.span(move.id),
466+
let pat_ty = ty::node_id_to_type(self.tcx, the_move.id);
467+
self.tcx.sess.span_note(self.tcx.map.span(the_move.id),
466468
format!("`{}` moved here because it has type `{}`, \
467469
which is moved by default (use `ref` to \
468470
override)",
@@ -471,14 +473,16 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
471473
}
472474

473475
move_data::Captured => {
474-
let (expr_ty, expr_span) = match self.tcx.map.find(move.id) {
476+
let (expr_ty, expr_span) = match self.tcx
477+
.map
478+
.find(the_move.id) {
475479
Some(ast_map::NodeExpr(expr)) => {
476480
(ty::expr_ty_adjusted(self.tcx, &*expr), expr.span)
477481
}
478482
r => {
479483
self.tcx.sess.bug(format!("Captured({:?}) maps to \
480484
{:?}, not Expr",
481-
move.id,
485+
the_move.id,
482486
r).as_slice())
483487
}
484488
};

src/librustc/middle/borrowck/move_data.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,8 @@ impl MoveData {
413413
* killed by scoping. See `doc.rs` for more details.
414414
*/
415415

416-
for (i, move) in self.moves.borrow().iter().enumerate() {
417-
dfcx_moves.add_gen(move.id, i);
416+
for (i, the_move) in self.moves.borrow().iter().enumerate() {
417+
dfcx_moves.add_gen(the_move.id, i);
418418
}
419419

420420
for (i, assignment) in self.var_assignments.borrow().iter().enumerate() {
@@ -577,10 +577,10 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> {
577577
let mut ret = None;
578578
for loan_path_index in self.move_data.path_map.borrow().find(&*loan_path).iter() {
579579
self.dfcx_moves.each_gen_bit(id, |move_index| {
580-
let move = self.move_data.moves.borrow();
581-
let move = move.get(move_index);
582-
if move.path == **loan_path_index {
583-
ret = Some(move.kind);
580+
let the_move = self.move_data.moves.borrow();
581+
let the_move = the_move.get(move_index);
582+
if the_move.path == **loan_path_index {
583+
ret = Some(the_move.kind);
584584
false
585585
} else {
586586
true
@@ -622,13 +622,13 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> {
622622
let mut ret = true;
623623

624624
self.dfcx_moves.each_bit_on_entry(id, |index| {
625-
let move = self.move_data.moves.borrow();
626-
let move = move.get(index);
627-
let moved_path = move.path;
625+
let the_move = self.move_data.moves.borrow();
626+
let the_move = the_move.get(index);
627+
let moved_path = the_move.path;
628628
if base_indices.iter().any(|x| x == &moved_path) {
629629
// Scenario 1 or 2: `loan_path` or some base path of
630630
// `loan_path` was moved.
631-
if !f(move, &*self.move_data.path_loan_path(moved_path)) {
631+
if !f(the_move, &*self.move_data.path_loan_path(moved_path)) {
632632
ret = false;
633633
}
634634
} else {
@@ -637,7 +637,8 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> {
637637
if p == loan_path_index {
638638
// Scenario 3: some extension of `loan_path`
639639
// was moved
640-
f(move, &*self.move_data.path_loan_path(moved_path))
640+
f(the_move,
641+
&*self.move_data.path_loan_path(moved_path))
641642
} else {
642643
true
643644
}

src/libsyntax/parse/parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,7 +2084,7 @@ impl<'a> Parser<'a> {
20842084
ExprBlock(blk));
20852085
},
20862086
token::BINOP(token::OR) | token::OROR => {
2087-
return self.parse_lambda_expr(CaptureByValue);
2087+
return self.parse_lambda_expr(CaptureByRef);
20882088
},
20892089
// FIXME #13626: Should be able to stick in
20902090
// token::SELF_KEYWORD_NAME
@@ -2135,8 +2135,8 @@ impl<'a> Parser<'a> {
21352135
hi = self.last_span.hi;
21362136
}
21372137
_ => {
2138-
if self.eat_keyword(keywords::Ref) {
2139-
return self.parse_lambda_expr(CaptureByRef);
2138+
if self.eat_keyword(keywords::Move) {
2139+
return self.parse_lambda_expr(CaptureByValue);
21402140
}
21412141
if self.eat_keyword(keywords::Proc) {
21422142
let decl = self.parse_proc_decl();

src/libsyntax/parse/token.rs

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -482,40 +482,41 @@ declare_special_idents_and_keywords! {
482482
(25, Loop, "loop");
483483
(26, Match, "match");
484484
(27, Mod, "mod");
485-
(28, Mut, "mut");
486-
(29, Once, "once");
487-
(30, Pub, "pub");
488-
(31, Ref, "ref");
489-
(32, Return, "return");
485+
(28, Move, "move");
486+
(29, Mut, "mut");
487+
(30, Once, "once");
488+
(31, Pub, "pub");
489+
(32, Ref, "ref");
490+
(33, Return, "return");
490491
// Static and Self are also special idents (prefill de-dupes)
491492
(super::STATIC_KEYWORD_NAME_NUM, Static, "static");
492493
(super::SELF_KEYWORD_NAME_NUM, Self, "self");
493-
(33, Struct, "struct");
494+
(34, Struct, "struct");
494495
(super::SUPER_KEYWORD_NAME_NUM, Super, "super");
495-
(34, True, "true");
496-
(35, Trait, "trait");
497-
(36, Type, "type");
498-
(37, Unsafe, "unsafe");
499-
(38, Use, "use");
500-
(39, Virtual, "virtual");
501-
(40, While, "while");
502-
(41, Continue, "continue");
503-
(42, Proc, "proc");
504-
(43, Box, "box");
505-
(44, Const, "const");
506-
(45, Where, "where");
496+
(35, True, "true");
497+
(36, Trait, "trait");
498+
(37, Type, "type");
499+
(38, Unsafe, "unsafe");
500+
(39, Use, "use");
501+
(40, Virtual, "virtual");
502+
(41, While, "while");
503+
(42, Continue, "continue");
504+
(43, Proc, "proc");
505+
(44, Box, "box");
506+
(45, Const, "const");
507+
(46, Where, "where");
507508

508509
'reserved:
509-
(46, Alignof, "alignof");
510-
(47, Be, "be");
511-
(48, Offsetof, "offsetof");
512-
(49, Priv, "priv");
513-
(50, Pure, "pure");
514-
(51, Sizeof, "sizeof");
515-
(52, Typeof, "typeof");
516-
(53, Unsized, "unsized");
517-
(54, Yield, "yield");
518-
(55, Do, "do");
510+
(47, Alignof, "alignof");
511+
(48, Be, "be");
512+
(49, Offsetof, "offsetof");
513+
(50, Priv, "priv");
514+
(51, Pure, "pure");
515+
(52, Sizeof, "sizeof");
516+
(53, Typeof, "typeof");
517+
(54, Unsized, "unsized");
518+
(55, Yield, "yield");
519+
(56, Do, "do");
519520
}
520521
}
521522

src/libsyntax/print/pprust.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,8 +2176,8 @@ impl<'a> State<'a> {
21762176
pub fn print_capture_clause(&mut self, capture_clause: ast::CaptureClause)
21772177
-> IoResult<()> {
21782178
match capture_clause {
2179-
ast::CaptureByValue => Ok(()),
2180-
ast::CaptureByRef => self.word_space("ref"),
2179+
ast::CaptureByValue => self.word_space("move"),
2180+
ast::CaptureByRef => Ok(()),
21812181
}
21822182
}
21832183

src/test/compile-fail/regionck-unboxed-closure-lifetimes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn main() {
1717
{
1818
let c = 1;
1919
let c_ref = &c; //~ ERROR `c` does not live long enough
20-
f = |&mut: a: int, b: int| { a + b + *c_ref };
20+
f = move |&mut: a: int, b: int| { a + b + *c_ref };
2121
}
2222
}
2323

src/test/run-pass/capture-clauses-boxed-closures.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn each<T>(x: &[T], f: |&T|) {
1717
fn main() {
1818
let mut sum = 0u;
1919
let elems = [ 1u, 2, 3, 4, 5 ];
20-
each(elems, ref |val| sum += *val);
20+
each(elems, |val| sum += *val);
2121
assert_eq!(sum, 15);
2222
}
2323

src/test/run-pass/unboxed-closures-all-traits.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ fn c<F:FnOnce(int, int) -> int>(f: F) -> int {
2424

2525
fn main() {
2626
let z: int = 7;
27-
assert_eq!(a(|&: x: int, y| x + y + z), 10);
28-
assert_eq!(b(|&mut: x: int, y| x + y + z), 14);
29-
assert_eq!(c(|: x: int, y| x + y + z), 18);
27+
assert_eq!(a(move |&: x: int, y| x + y + z), 10);
28+
assert_eq!(b(move |&mut: x: int, y| x + y + z), 14);
29+
assert_eq!(c(move |: x: int, y| x + y + z), 18);
3030
}
3131

src/test/run-pass/unboxed-closures-boxed.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
use std::ops::FnMut;
1414

1515
fn make_adder(x: int) -> Box<FnMut<(int,),int>+'static> {
16-
(box |&mut: y: int| -> int { x + y }) as Box<FnMut<(int,),int>+'static>
16+
(box move |&mut: y: int| -> int { x + y }) as
17+
Box<FnMut<(int,),int>+'static>
1718
}
1819

1920
pub fn main() {

src/test/run-pass/unboxed-closures-drop.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,65 +55,65 @@ fn c<F:FnOnce(int, int) -> int>(f: F) -> int {
5555

5656
fn test_fn() {
5757
{
58-
a(|&: a: int, b| { a + b });
58+
a(move |&: a: int, b| { a + b });
5959
}
6060
assert_eq!(drop_count(), 0);
6161

6262
{
6363
let z = &Droppable::new();
64-
a(|&: a: int, b| { z; a + b });
64+
a(move |&: a: int, b| { z; a + b });
6565
assert_eq!(drop_count(), 0);
6666
}
6767
assert_eq!(drop_count(), 1);
6868

6969
{
7070
let z = &Droppable::new();
7171
let zz = &Droppable::new();
72-
a(|&: a: int, b| { z; zz; a + b });
72+
a(move |&: a: int, b| { z; zz; a + b });
7373
assert_eq!(drop_count(), 1);
7474
}
7575
assert_eq!(drop_count(), 3);
7676
}
7777

7878
fn test_fn_mut() {
7979
{
80-
b(|&mut: a: int, b| { a + b });
80+
b(move |&mut: a: int, b| { a + b });
8181
}
8282
assert_eq!(drop_count(), 3);
8383

8484
{
8585
let z = &Droppable::new();
86-
b(|&mut: a: int, b| { z; a + b });
86+
b(move |&mut: a: int, b| { z; a + b });
8787
assert_eq!(drop_count(), 3);
8888
}
8989
assert_eq!(drop_count(), 4);
9090

9191
{
9292
let z = &Droppable::new();
9393
let zz = &Droppable::new();
94-
b(|&mut: a: int, b| { z; zz; a + b });
94+
b(move |&mut: a: int, b| { z; zz; a + b });
9595
assert_eq!(drop_count(), 4);
9696
}
9797
assert_eq!(drop_count(), 6);
9898
}
9999

100100
fn test_fn_once() {
101101
{
102-
c(|: a: int, b| { a + b });
102+
c(move |: a: int, b| { a + b });
103103
}
104104
assert_eq!(drop_count(), 6);
105105

106106
{
107107
let z = Droppable::new();
108-
c(|: a: int, b| { z; a + b });
108+
c(move |: a: int, b| { z; a + b });
109109
assert_eq!(drop_count(), 7);
110110
}
111111
assert_eq!(drop_count(), 7);
112112

113113
{
114114
let z = Droppable::new();
115115
let zz = Droppable::new();
116-
c(|: a: int, b| { z; zz; a + b });
116+
c(move |: a: int, b| { z; zz; a + b });
117117
assert_eq!(drop_count(), 9);
118118
}
119119
assert_eq!(drop_count(), 9);

src/test/run-pass/unboxed-closures-single-word-env.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ fn c<F:FnOnce(int, int) -> int>(f: F) -> int {
2727

2828
fn main() {
2929
let z = 10;
30-
assert_eq!(a(|&: x: int, y| x + y + z), 13);
31-
assert_eq!(b(|&mut: x: int, y| x + y + z), 17);
32-
assert_eq!(c(|: x: int, y| x + y + z), 21);
30+
assert_eq!(a(move |&: x: int, y| x + y + z), 13);
31+
assert_eq!(b(move |&mut: x: int, y| x + y + z), 17);
32+
assert_eq!(c(move |: x: int, y| x + y + z), 21);
3333
}
3434

0 commit comments

Comments
 (0)