Convert ret to return

This commit is contained in:
Brian Anderson 2012-08-01 17:30:05 -07:00
parent dc499f193e
commit b355936b4d
456 changed files with 3875 additions and 3798 deletions

View file

@ -2,7 +2,7 @@
// Tests that a function with a ! annotation always actually fails
fn bad_bang(i: uint) -> ! {
ret 7u;
return 7u;
//~^ ERROR expected `_|_` but found `uint`
}

View file

@ -1,9 +1,9 @@
fn to_lambda1(f: fn@(uint) -> uint) -> fn@(uint) -> uint {
ret f;
return f;
}
fn to_lambda2(b: fn(uint) -> uint) -> fn@(uint) -> uint {
ret to_lambda1({|x| b(x)}); //~ ERROR value may contain borrowed pointers
return to_lambda1({|x| b(x)}); //~ ERROR value may contain borrowed pointers
}
fn main() {

View file

@ -3,9 +3,9 @@
fn coerce(b: fn()) -> extern fn() {
fn lol(f: extern fn(fn()) -> extern fn(),
g: fn()) -> extern fn() { ret f(g); }
fn fn_id(f: extern fn()) -> extern fn() { ret f }
ret lol(fn_id, b);
g: fn()) -> extern fn() { return f(g); }
fn fn_id(f: extern fn()) -> extern fn() { return f }
return lol(fn_id, b);
//~^ ERROR mismatched types: expected `extern fn(fn()) -> extern fn()`
}

View file

@ -1,6 +1,6 @@
// error-pattern: stack closure type can only appear
fn lol(f: fn()) -> fn() { ret f; }
fn lol(f: fn()) -> fn() { return f; }
fn main() {
let i = 8;
let f = lol(fn&() { log(error, i); });

View file

@ -1,6 +1,6 @@
fn foo(x: *~int) -> ~int {
let y <- *x; //~ ERROR dereference of unsafe pointer requires unsafe function or block
ret y;
return y;
}
fn main() {

View file

@ -1,7 +1,7 @@
fn want_slice(v: &[int]) -> int {
let mut sum = 0;
for vec::each(v) |i| { sum += i; }
ret sum;
return sum;
}
fn has_mut_vec(+v: @~[mut int]) -> int {

View file

@ -5,7 +5,7 @@ class foo { let x: int; new(x: int) { self.x = x; } drop { } }
fn to_lambda2(b: foo) -> fn@(uint) -> uint {
// test case where copy clause specifies a value that is not used
// in fn@ body, but value is illegal to copy:
ret fn@(u: uint, copy b) -> uint { 22u };
return fn@(u: uint, copy b) -> uint { 22u };
}
fn main() {

View file

@ -4,5 +4,5 @@
fn main() {
let bar: int = 5;
fn foo() -> int { ret bar; }
fn foo() -> int { return bar; }
}

View file

@ -27,11 +27,11 @@ class cat : noisy {
if self.how_hungry > 0 {
error!{"OM NOM NOM"};
self.how_hungry -= 2;
ret true;
return true;
}
else {
error!{"Not hungry!"};
ret false;
return false;
}
}
}

View file

@ -2,7 +2,7 @@
// xfail-test
// error-pattern:Unsatisfied precondition
pure fn less_than(x: int, y: int) -> bool { ret x < y; }
pure fn less_than(x: int, y: int) -> bool { return x < y; }
type ordered_range = {low: int, high: int} : less_than(*.low, *.high);

View file

@ -5,5 +5,5 @@
fn f(caller: str) { log(debug, caller); }
fn main() { ret f("main"); debug!{"Paul is dead"}; }
fn main() { return f("main"); debug!{"Paul is dead"}; }

View file

@ -13,7 +13,7 @@ fn bitv_to_str(enclosing: fn_info, v: ~bitv::bitv) -> str {
for enclosing.vars.each_value |val| {
if v.get(val) { s += "foo"; }
}
ret s;
return s;
}
fn main() { debug!{"OK"}; }

View file

@ -9,7 +9,7 @@ mod y {
}
fn bar(x: x::foo) -> y::foo {
ret x;
return x;
//~^ ERROR mismatched types: expected `y::foo` but found `x::foo`
}

View file

@ -4,7 +4,7 @@ type T1 = uint;
type T2 = int;
fn bar(x: T1) -> T2 {
ret x;
return x;
//~^ ERROR mismatched types: expected `T2` but found `T1`
}

View file

@ -3,7 +3,7 @@
import core::task::task;
fn bar(x: uint) -> task {
ret x;
return x;
//~^ ERROR mismatched types: expected `core::task::task`
}

View file

@ -1,7 +1,7 @@
trait foo<T> { }
fn bar(x: foo<uint>) -> foo<int> {
ret (x as foo::<int>);
return (x as foo::<int>);
//~^ ERROR mismatched types: expected `foo<int>` but found `foo<uint>`
}

View file

@ -6,7 +6,7 @@ mod circ1 {
export f2;
export common;
fn f1() { debug!{"f1"}; }
fn common() -> uint { ret 0u; }
fn common() -> uint { return 0u; }
}
mod circ2 {
@ -15,7 +15,7 @@ mod circ2 {
export f2;
export common;
fn f2() { debug!{"f2"}; }
fn common() -> uint { ret 1u; }
fn common() -> uint { return 1u; }
}
mod test {

View file

@ -7,8 +7,8 @@ mod foo {
fn bar(v: t) -> bool {
alt v {
a { ret true; }
b { ret false; }
a { return true; }
b { return false; }
}
}
}

View file

@ -2,6 +2,6 @@
fn main() {
#macro[[#apply[f, [x, ...]], f(x, ...)]];
fn add(a: int, b: int) -> int { ret a + b; }
fn add(a: int, b: int) -> int { return a + b; }
assert (apply!{add, [y, 15]} == 16); //~ ERROR unresolved name: y
}

View file

@ -3,6 +3,6 @@ fn fail_len(v: ~[const int]) -> uint {
for v.each |x| { i += 1u; }
//~^ WARNING unreachable statement
//~^^ ERROR the type of this value must be known
ret i;
return i;
}
fn main() {}

View file

@ -15,7 +15,7 @@ fn siphash(k0 : u64, k1 : u64) -> siphash {
let v0 = st.v0,
v1 = st.v1;
ret v0 ^ v1;
return v0 ^ v1;
}
impl of siphash for sipstate {
@ -25,7 +25,7 @@ fn siphash(k0 : u64, k1 : u64) -> siphash {
self.v1 = k1 ^ 0x646f72616e646f6d; //~ ERROR attempted dynamic environment-capture
//~^ ERROR unresolved name: k1
}
fn result() -> u64 { ret mk_result(self); }
fn result() -> u64 { return mk_result(self); }
}
}

View file

@ -1,6 +1,6 @@
fn g() -> ! { fail; }
fn f() -> ! {
ret 42i; //~ ERROR expected `_|_` but found `int`
return 42i; //~ ERROR expected `_|_` but found `int`
g(); //~ WARNING unreachable statement
}
fn main() { }

View file

@ -1,5 +1,5 @@
fn f() -> ! {
ret 42i; //~ ERROR expected `_|_` but found `int`
return 42i; //~ ERROR expected `_|_` but found `int`
fail; //~ WARNING unreachable statement
}
fn main() { }

View file

@ -5,7 +5,7 @@ fn f2(x: fn()) { x(); }
fn main() {
let i = 0;
let ctr = fn@ () -> int { f2(|| i = i + 1 ); ret i; };
let ctr = fn@ () -> int { f2(|| i = i + 1 ); return i; };
log(error, ctr());
log(error, ctr());
log(error, ctr());

View file

@ -2,7 +2,7 @@
// Make sure we can't write to upvars from fn@s
fn main() {
let i = 0;
let ctr = fn@ () -> int { i = i + 1; ret i; };
let ctr = fn@ () -> int { i = i + 1; return i; };
log(error, ctr());
log(error, ctr());
log(error, ctr());

View file

@ -8,7 +8,7 @@ fn foo() -> int {
log(debug, x); //~ ERROR use of possibly uninitialized variable: `x`
ret 17;
return 17;
}
fn main() { log(debug, foo()); }

View file

@ -8,7 +8,7 @@ fn foo() -> int {
log(debug, x); //~ ERROR use of possibly uninitialized variable: `x`
ret 17;
return 17;
}
fn main() { log(debug, foo()); }

View file

@ -1,8 +1,8 @@
// -*- rust -*-
// error-pattern: not all control paths return a value
fn god_exists(a: int) -> bool { ret god_exists(a); }
fn god_exists(a: int) -> bool { return god_exists(a); }
fn f(a: int) -> int { if god_exists(a) { ret 5; }; }
fn f(a: int) -> int { if god_exists(a) { return 5; }; }
fn main() { f(12); }

View file

@ -1,7 +1,7 @@
fn main() {
let j = fn@() -> int {
let i: int;
ret i; //~ ERROR use of possibly uninitialized variable: `i`
return i; //~ ERROR use of possibly uninitialized variable: `i`
};
j();
}

View file

@ -1,7 +1,7 @@
fn main() {
let f = fn@() -> int {
let i: int;
ret i; //~ ERROR use of possibly uninitialized variable: `i`
return i; //~ ERROR use of possibly uninitialized variable: `i`
};
log(error, f());
}

View file

@ -1,7 +1,7 @@
// error-pattern: not all control paths return a value
fn f() -> int {
// Make sure typestate doesn't interpret this alt expression
// Make sure typestate doesn't interpreturn this alt expression
// as the function result
alt check true { true { } };
}

View file

@ -1,6 +1,6 @@
fn f() -> int {
let x: int;
ret x; //~ ERROR use of possibly uninitialized variable: `x`
return x; //~ ERROR use of possibly uninitialized variable: `x`
}
fn main() { f(); }

View file

@ -1,7 +1,7 @@
fn f() -> int {
let mut x: int;
while 1 == 1 { x = 10; }
ret x; //~ ERROR use of possibly uninitialized variable: `x`
return x; //~ ERROR use of possibly uninitialized variable: `x`
}
fn main() { f(); }

View file

@ -4,7 +4,7 @@ fn forever() -> ! {
loop {
break;
}
ret 42i; //~ ERROR expected `_|_` but found `int`
return 42i; //~ ERROR expected `_|_` but found `int`
}
fn main() {

View file

@ -2,7 +2,7 @@
fn main() {
#macro[[#mylambda[x, body],
{
fn f(x: int) -> int { ret body }
fn f(x: int) -> int { return body }
f
}]];

View file

@ -1,6 +1,6 @@
// error-pattern:attempt to use a type argument out of scope
fn hd<U>(v: ~[U]) -> U {
fn hd1(w: [U]) -> U { ret w[0]; }
fn hd1(w: [U]) -> U { return w[0]; }
ret hd1(v);
return hd1(v);
}

View file

@ -8,6 +8,6 @@ import option::some;
enum bar { t1((), option<~[int]>), t2, }
fn foo(t: bar) -> int { alt t { t1(_, some(x)) { ret x * 3; } _ { fail; } } }
fn foo(t: bar) -> int { alt t { t1(_, some(x)) { return x * 3; } _ { fail; } } }
fn main() { }

View file

@ -1,7 +1,7 @@
pure fn range(from: uint, to: uint, f: fn(uint) -> bool) {
let mut i = from;
while i < to {
if !f(i) {ret;} // Note: legal to call argument, even if it is not pure.
if !f(i) {return;} // Note: legal to call argument, even if it is not pure.
i += 1u;
}
}

View file

@ -7,21 +7,21 @@ trait a_trait { fn foo() -> &self/int; }
class a_class { let x:&self/int; new(x:&self/int) { self.x = x; } }
fn a_fn1(e: an_enum/&a) -> an_enum/&b {
ret e; //~ ERROR mismatched types: expected `an_enum/&b` but found `an_enum/&a`
return e; //~ ERROR mismatched types: expected `an_enum/&b` but found `an_enum/&a`
}
fn a_fn2(e: a_trait/&a) -> a_trait/&b {
ret e; //~ ERROR mismatched types: expected `a_trait/&b` but found `a_trait/&a`
return e; //~ ERROR mismatched types: expected `a_trait/&b` but found `a_trait/&a`
}
fn a_fn3(e: a_class/&a) -> a_class/&b {
ret e; //~ ERROR mismatched types: expected `a_class/&b` but found `a_class/&a`
return e; //~ ERROR mismatched types: expected `a_class/&b` but found `a_class/&a`
}
fn a_fn4(e: int/&a) -> int/&b {
//~^ ERROR region parameters are not allowed on this type
//~^^ ERROR region parameters are not allowed on this type
ret e;
return e;
}
fn main() { }

View file

@ -20,12 +20,12 @@ fn compute(x: &ast) -> uint {
fn map_nums(x: &ast, f: fn(uint) -> uint) -> &ast {
alt *x {
num(x) {
ret &num(f(x)); //~ ERROR illegal borrow
return &num(f(x)); //~ ERROR illegal borrow
}
add(x, y) {
let m_x = map_nums(x, f);
let m_y = map_nums(y, f);
ret &add(m_x, m_y); //~ ERROR illegal borrow
return &add(m_x, m_y); //~ ERROR illegal borrow
}
}
}

View file

@ -13,7 +13,7 @@ impl of get_ctxt for has_ctxt {
fn make_gc() -> get_ctxt {
let ctxt = { v: 22u };
let hc = { c: &ctxt };
ret hc as get_ctxt; //~ ERROR mismatched types: expected `get_ctxt/&`
return hc as get_ctxt; //~ ERROR mismatched types: expected `get_ctxt/&`
}
fn main() {

View file

@ -3,11 +3,11 @@ trait get_ctxt {
}
fn make_gc1(gc: get_ctxt/&a) -> get_ctxt/&b {
ret gc; //~ ERROR mismatched types: expected `get_ctxt/&b` but found `get_ctxt/&a`
return gc; //~ ERROR mismatched types: expected `get_ctxt/&b` but found `get_ctxt/&a`
}
fn make_gc2(gc: get_ctxt/&a) -> get_ctxt/&b {
ret gc as get_ctxt; //~ ERROR mismatched types: expected `get_ctxt/&b` but found `get_ctxt/&a`
return gc as get_ctxt; //~ ERROR mismatched types: expected `get_ctxt/&b` but found `get_ctxt/&a`
}
fn main() {

View file

@ -1,13 +1,13 @@
type point = {x: int, y: int};
fn x_coord(p: &point) -> &int {
ret &p.x;
return &p.x;
}
fn foo(p: @point) -> &int {
let xc = x_coord(p); //~ ERROR illegal borrow
assert *xc == 3;
ret xc;
return xc;
}
fn main() {}

View file

@ -3,8 +3,8 @@ fn ignore<T>(_t: T) {}
fn nested() {
let y = 3;
ignore(fn&(z: &z/int) -> &z/int {
if false { ret &y; } //~ ERROR illegal borrow
ret z;
if false { return &y; } //~ ERROR illegal borrow
return z;
});
}

View file

@ -11,9 +11,9 @@ fn nested(x: &x/int) {
});
ignore(fn&(z: &z/int) -> &z/int {
if false { ret x; } //~ ERROR mismatched types
if false { ret ay; } //~ ERROR mismatched types
ret z;
if false { return x; } //~ ERROR mismatched types
if false { return ay; } //~ ERROR mismatched types
return z;
});
}

View file

@ -1,5 +1,5 @@
fn f(_x : &a/int) -> &a/int {
ret &3; //~ ERROR illegal borrow
return &3; //~ ERROR illegal borrow
}
fn main() {

View file

@ -9,18 +9,18 @@ fn nested(x: &x/int) { // (1)
z: &z/int) -> &z/int) // A fresh region `z` (3)
-> &x/int {
if false { ret z(x, x, x); } //~ ERROR mismatched types: expected `&y/int` but found `&x/int`
if false { ret z(x, x, y); } //~ ERROR mismatched types: expected `&y/int` but found `&x/int`
if false { return z(x, x, x); } //~ ERROR mismatched types: expected `&y/int` but found `&x/int`
if false { return z(x, x, y); } //~ ERROR mismatched types: expected `&y/int` but found `&x/int`
//~^ ERROR mismatched types: expected `&x/int` but found `&y/int`
if false { ret z(x, y, x); }
if false { ret z(x, y, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int`
if false { ret z(y, x, x); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int`
if false { return z(x, y, x); }
if false { return z(x, y, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int`
if false { return z(y, x, x); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int`
//~^ ERROR mismatched types: expected `&y/int` but found `&x/int`
if false { ret z(y, x, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int`
if false { return z(y, x, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int`
//~^ ERROR mismatched types: expected `&y/int` but found `&x/int`
//~^^ ERROR mismatched types: expected `&x/int` but found `&y/int`
if false { ret z(y, y, x); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int`
if false { ret z(y, y, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int`
if false { return z(y, y, x); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int`
if false { return z(y, y, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int`
//~^ ERROR mismatched types: expected `&x/int` but found `&y/int`
fail;
}

View file

@ -1,7 +1,7 @@
// error-pattern: `ret;` in function returning non-nil
// error-pattern: `return;` in function returning non-nil
fn f() { ret; }
fn f() { return; }
fn g() -> int { ret; }
fn g() -> int { return; }
fn main() { f(); g(); }

View file

@ -1,8 +1,8 @@
fn test(f: fn@(uint) -> uint) -> uint {
ret f(22u);
return f(22u);
}
fn main() {
let f = fn~(x: uint) -> uint { ret 4u; };
let f = fn~(x: uint) -> uint { return 4u; };
log(debug, test(f)); //~ ERROR expected `fn@(uint) -> uint`
}

View file

@ -1,7 +1,7 @@
// error-pattern: mismatched types
fn f() -> int { ret g(); }
fn f() -> int { return g(); }
fn g() -> uint { ret 0u; }
fn g() -> uint { return 0u; }
fn main() { let y = f(); }

View file

@ -8,7 +8,7 @@ enum box_impl<T> = {
};
impl<T:copy> of box_trait<T> for box_impl<T> {
fn get() -> T { ret self.f; }
fn get() -> T { return self.f; }
fn set(t: T) { self.f = t; }
}

View file

@ -2,7 +2,7 @@
fn f(p: *u8) {
*p = 0u8; //~ ERROR dereference of unsafe pointer requires unsafe function or block
ret;
return;
}
fn main() {

View file

@ -15,7 +15,7 @@ fn f(p: *rec) -> int {
// are prohibited by various checks, such as that the enum is
// instantiable and so forth).
ret p.f; //~ ERROR attempted access of field `f` on type `*rec`
return p.f; //~ ERROR attempted access of field `f` on type `*rec`
}
fn main() {

View file

@ -1,6 +1,6 @@
// -*- rust -*-
unsafe fn f() { ret; }
unsafe fn f() { return; }
fn main() {
f(); //~ ERROR access to unsafe function requires unsafe function or block

View file

@ -1,7 +1,7 @@
// -*- rust -*-
fn f(p: *u8) -> u8 {
ret *p; //~ ERROR dereference of unsafe pointer requires unsafe function or block
return *p; //~ ERROR dereference of unsafe pointer requires unsafe function or block
}
fn main() {

View file

@ -1,6 +1,6 @@
// -*- rust -*-
unsafe fn f() { ret; }
unsafe fn f() { return; }
fn main() {
let x = f; //~ ERROR access to unsafe function requires unsafe function or block

View file

@ -11,7 +11,7 @@ mod bar {
mod c {
import foo::point;
import foo::square;
fn cc(p: point) -> str { ret 2 * (p.x + p.y); }
fn cc(p: point) -> str { return 2 * (p.x + p.y); }
}
}

View file

@ -7,7 +7,7 @@ fn concat<T: copy>(v: ~[const ~[const T]]) -> ~[T] {
r += inner;
});
ret r;
return r;
}
fn main() {}

View file

@ -1,3 +1,3 @@
// error-pattern: mismatched types
fn mk_int() -> uint { let i: int = 3; ret i; }
fn mk_int() -> uint { let i: int = 3; return i; }
fn main() { }