Skip to content

Commit c83af2f

Browse files
committed
---
yaml --- r: 4471 b: refs/heads/master c: b54e7e4 h: refs/heads/master i: 4469: f3df1bc 4467: f14ba6d 4463: a0cd462 v: v3
1 parent ea0c9de commit c83af2f

File tree

11 files changed

+40
-7
lines changed

11 files changed

+40
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 3dda9aabf217d59881970f847b06338d417f6f6f
2+
refs/heads/master: b54e7e45069a84e9e9ee6ef3431f733d96d93586

trunk/src/comp/metadata/tydecode.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,9 @@ fn parse_ty_fn(st: @pstate, sd: str_def) ->
381381
mode = ty::mo_alias(true);
382382
st.pos += 1u;
383383
}
384+
} else if peek(st) as char == '-' {
385+
mode = ty::mo_move;
386+
st.pos += 1u;
384387
}
385388
inputs += ~[{mode: mode, ty: parse_ty(st, sd)}];
386389
}

trunk/src/comp/metadata/tyencode.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ fn enc_ty_fn(w: &ioivec::writer, cx: &@ctxt, args: &ty::arg[], out: &ty::t,
208208
w.write_char('&');
209209
if mut { w.write_char('m'); }
210210
}
211+
ty::mo_move. {
212+
w.write_char('-');
213+
}
211214
ty::mo_val. { }
212215
}
213216
enc_ty(w, cx, arg.ty);

trunk/src/comp/middle/trans.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ fn type_of_explicit_args(cx: &@crate_ctxt, sp: &span, inputs: &ty::arg[]) ->
9595
let t: TypeRef = type_of_inner(cx, sp, arg.ty);
9696
t = alt arg.mode {
9797
ty::mo_alias(_) { T_ptr(t) }
98+
ty::mo_move. { T_ptr(t) }
9899
_ { t }
99100
};
100101
atys += ~[t];

trunk/src/comp/middle/ty.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export mk_iter_body_fn;
9595
export mode;
9696
export mo_val;
9797
export mo_alias;
98+
export mo_move;
9899
export mt;
99100
export node_type_table;
100101
export pat_ty;
@@ -187,7 +188,7 @@ export walk_ty;
187188
export occurs_check_fails;
188189

189190
// Data types
190-
tag mode { mo_val; mo_alias(bool); }
191+
tag mode { mo_val; mo_alias(bool); mo_move; }
191192

192193
type arg = {mode: mode, ty: t};
193194

trunk/src/comp/middle/typeck.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import middle::ty::field;
2121
import middle::ty::method;
2222
import middle::ty::mo_val;
2323
import middle::ty::mo_alias;
24+
import middle::ty::mo_move;
2425
import middle::ty::node_type_table;
2526
import middle::ty::pat_ty;
2627
import middle::ty::ty_param_substs_opt_and_ty;
@@ -204,12 +205,11 @@ fn instantiate_path(fcx: &@fn_ctxt, pth: &ast::path,
204205
}
205206

206207
fn ast_mode_to_mode(mode: ast::mode) -> ty::mode {
207-
let ty_mode;
208208
alt mode {
209-
ast::val. { ty_mode = mo_val; }
210-
ast::alias(mut) { ty_mode = mo_alias(mut); }
209+
ast::val. { mo_val }
210+
ast::alias(mut) { mo_alias(mut) }
211+
ast::move. { mo_move }
211212
}
212-
ret ty_mode;
213213
}
214214

215215

trunk/src/comp/syntax/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ fn unop_to_str(op: unop) -> str {
249249
}
250250
}
251251
252-
tag mode { val; alias(bool); }
252+
tag mode { val; alias(bool); move; }
253253
254254
type stmt = spanned[stmt_];
255255

trunk/src/comp/syntax/parse/parser.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,8 @@ fn parse_arg(p: &parser) -> ast::arg {
597597
expect(p, token::COLON);
598598
if eat(p, token::BINOP(token::AND)) {
599599
m = ast::alias(eat_word(p, "mutable"));
600+
} else if eat(p, token::BINOP(token::MINUS)) {
601+
m = ast::move;
600602
}
601603
let t: @ast::ty = parse_ty(p);
602604
ret {mode: m, ty: t, ident: i, id: p.get_id()};

trunk/src/comp/syntax/print/pprust.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,7 @@ fn print_alias(s: &ps, m: ast::mode) {
11911191
alt m {
11921192
ast::alias(true) { word_space(s, "&mutable"); }
11931193
ast::alias(false) { word(s.s, "&"); }
1194+
ast::move. { word(s.s, "-"); }
11941195
ast::val. { }
11951196
}
11961197
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// xfail-stage0
2+
// xfail-stage1
3+
// xfail-stage2
4+
// xfail-stage3
5+
// error-pattern: Unsatisfied precondition constraint
6+
fn test(foo: -int) {
7+
assert (foo == 10);
8+
}
9+
10+
fn main() {
11+
let x = 10;
12+
test(x);
13+
log x;
14+
}

trunk/src/test/run-pass/move-arg.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn test(foo: -int) {
2+
assert (foo == 10);
3+
}
4+
5+
fn main() {
6+
let x = 10;
7+
test(x);
8+
}

0 commit comments

Comments
 (0)