mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
test -- update tests with new error messages
This commit is contained in:
parent
1bd7b182c5
commit
3805c5416e
@ -15,7 +15,7 @@ fn main() {
|
||||
let mut y = None;
|
||||
x.write_downgrade(|write_mode| {
|
||||
y = Some(x.downgrade(write_mode));
|
||||
//~^ ERROR cannot infer an appropriate lifetime
|
||||
//~^ ERROR cannot infer
|
||||
});
|
||||
y.unwrap();
|
||||
// Adding this line causes a method unification failure instead
|
||||
|
@ -32,9 +32,9 @@ fn b() {
|
||||
|
||||
let mut p = ~[1];
|
||||
|
||||
borrow(p, || {
|
||||
p[0] = 5; //~ ERROR cannot assign to
|
||||
});
|
||||
borrow(
|
||||
p,
|
||||
|| p[0] = 5); //~ ERROR cannot borrow `p` as mutable
|
||||
}
|
||||
|
||||
fn c() {
|
||||
|
@ -21,13 +21,14 @@ impl X {
|
||||
|
||||
fn main() {
|
||||
let mut x = X(Right(main));
|
||||
(&mut x).with(|opt| {
|
||||
match opt {
|
||||
&Right(ref f) => {
|
||||
x = X(Left((0,0))); //~ ERROR cannot assign to `x`
|
||||
(*f)()
|
||||
},
|
||||
_ => fail!()
|
||||
}
|
||||
})
|
||||
(&mut x).with(
|
||||
|opt| { //~ ERROR cannot borrow `x` as mutable more than once at a time
|
||||
match opt {
|
||||
&Right(ref f) => {
|
||||
x = X(Left((0,0)));
|
||||
(*f)()
|
||||
},
|
||||
_ => fail!()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ trait Foo {
|
||||
|
||||
fn test(x: &mut Foo) {
|
||||
let _y = x.f1();
|
||||
x.f2(); //~ ERROR cannot borrow `*x` because it is already borrowed as mutable
|
||||
x.f2(); //~ ERROR cannot borrow `*x` as mutable
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -23,9 +23,10 @@ impl Foo {
|
||||
}
|
||||
|
||||
fn bar(f: &mut Foo) {
|
||||
f.foo(|a| {
|
||||
f.n.insert(*a); //~ ERROR cannot borrow
|
||||
})
|
||||
f.foo(
|
||||
|a| { //~ ERROR closure requires unique access to `f`
|
||||
f.n.insert(*a);
|
||||
})
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -21,7 +21,9 @@ fn box_imm() {
|
||||
info!("v={}", *v);
|
||||
//~^ ERROR cannot move `v` into closure
|
||||
});
|
||||
}
|
||||
|
||||
fn box_imm_explicit() {
|
||||
let v = ~3;
|
||||
let _w = &v;
|
||||
task::spawn(proc() {
|
||||
|
@ -14,11 +14,12 @@ fn borrow(v: &int, f: |x: &int|) {
|
||||
|
||||
fn box_imm() {
|
||||
let mut v = ~3;
|
||||
borrow(v, |w| {
|
||||
v = ~4; //~ ERROR cannot assign to `v` because it is borrowed
|
||||
assert_eq!(*v, 3);
|
||||
assert_eq!(*w, 4);
|
||||
})
|
||||
borrow(v,
|
||||
|w| { //~ ERROR cannot borrow `v` as mutable
|
||||
v = ~4;
|
||||
assert_eq!(*v, 3);
|
||||
assert_eq!(*w, 4);
|
||||
})
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -32,8 +32,8 @@ fn a() {
|
||||
p.impurem();
|
||||
|
||||
// But in this case we do not honor the loan:
|
||||
p.blockm(|| {
|
||||
p.x = 10; //~ ERROR cannot assign
|
||||
p.blockm(|| { //~ ERROR cannot borrow `p` as mutable
|
||||
p.x = 10;
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -23,9 +23,11 @@ fn has_mut_vec_and_does_not_try_to_change_it() {
|
||||
|
||||
fn has_mut_vec_but_tries_to_change_it() {
|
||||
let mut v = ~[1, 2, 3];
|
||||
takes_imm_elt(&v[0], || {
|
||||
v[1] = 4; //~ ERROR cannot assign
|
||||
})
|
||||
takes_imm_elt(
|
||||
&v[0],
|
||||
|| { //~ ERROR cannot borrow `v` as mutable
|
||||
v[1] = 4;
|
||||
})
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -9,10 +9,8 @@
|
||||
// except according to those terms.
|
||||
|
||||
pub fn main() {
|
||||
// FIXME(#2202) - Due to the way that borrowck treats closures,
|
||||
// you get two error reports here.
|
||||
let bar = ~3;
|
||||
let _g = || { //~ ERROR capture of moved value
|
||||
let _h: proc() -> int = proc() *bar; //~ ERROR capture of moved value
|
||||
let _g = || {
|
||||
let _h: proc() -> int = proc() *bar; //~ ERROR cannot move out of captured outer variable
|
||||
};
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ fn borrowed_receiver<'a>(x: &'a Foo) -> &'a () {
|
||||
}
|
||||
|
||||
fn owned_receiver(x: ~Foo) -> &() {
|
||||
x.borrowed() //~ ERROR borrowed value does not live long enough
|
||||
x.borrowed() //~ ERROR `*x` does not live long enough
|
||||
}
|
||||
|
||||
fn mut_owned_receiver(mut x: ~Foo) {
|
||||
|
@ -14,6 +14,6 @@ fn main() {
|
||||
[1, 2, ..tail] => tail,
|
||||
_ => unreachable!()
|
||||
};
|
||||
a[0] = 0; //~ ERROR cannot assign to `a[]` because it is borrowed
|
||||
a[0] = 0; //~ ERROR cannot assign to `a[..]` because it is borrowed
|
||||
t[0];
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ fn a() {
|
||||
let mut vec = ~[~1, ~2, ~3];
|
||||
match vec {
|
||||
[~ref _a] => {
|
||||
vec[0] = ~4; //~ ERROR cannot assign to `(*vec)[]` because it is borrowed
|
||||
vec[0] = ~4; //~ ERROR cannot assign
|
||||
}
|
||||
_ => fail!("foo")
|
||||
}
|
||||
@ -22,7 +22,7 @@ fn b() {
|
||||
let mut vec = ~[~1, ~2, ~3];
|
||||
match vec {
|
||||
[.._b] => {
|
||||
vec[0] = ~4; //~ ERROR cannot assign to `(*vec)[]` because it is borrowed
|
||||
vec[0] = ~4; //~ ERROR cannot assign
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
fn a() -> &int {
|
||||
let vec = ~[1, 2, 3, 4];
|
||||
let tail = match vec {
|
||||
[_a, ..tail] => &tail[0], //~ ERROR borrowed value does not live long enough
|
||||
[_a, ..tail] => &tail[0], //~ ERROR `vec[..]` does not live long enough
|
||||
_ => fail!("foo")
|
||||
};
|
||||
tail
|
||||
|
@ -13,7 +13,7 @@ struct thing<'a, Q> {
|
||||
}
|
||||
|
||||
fn thing<Q>(x: &Q) -> thing<Q> {
|
||||
thing{ x: x } //~ ERROR cannot infer an appropriate lifetime
|
||||
thing{ x: x } //~ ERROR cannot infer
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -11,7 +11,7 @@
|
||||
fn id<T>(t: T) -> T { t }
|
||||
|
||||
fn f<'r, T>(v: &'r T) -> 'r || -> T {
|
||||
id(|| *v) //~ ERROR cannot infer an appropriate lifetime
|
||||
id(|| *v) //~ ERROR cannot infer
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -24,7 +24,7 @@ fn main() {
|
||||
|
||||
let y = {
|
||||
let tmp0 = 3;
|
||||
let tmp1 = &tmp0; //~ ERROR borrowed value does not live long enough
|
||||
let tmp1 = &tmp0; //~ ERROR `tmp0` does not live long enough
|
||||
repeater(tmp1)
|
||||
};
|
||||
assert!(3 == *(y.get()));
|
||||
|
@ -17,13 +17,13 @@ fn touch<A>(_a: &A) {}
|
||||
|
||||
fn f10() {
|
||||
let x = Foo { f: ~"hi", y: 3 };
|
||||
consume(x.f); //~ NOTE `x.f` moved here
|
||||
consume(x.f);
|
||||
touch(&x.y); //~ ERROR use of partially moved value: `x`
|
||||
}
|
||||
|
||||
fn f20() {
|
||||
let x = ~[~"hi"];
|
||||
consume(x[0]); //~ NOTE `(*x)[]` moved here
|
||||
consume(x[0]);
|
||||
touch(&x[0]); //~ ERROR use of partially moved value: `x`
|
||||
}
|
||||
|
||||
|
@ -14,5 +14,5 @@ fn main() {
|
||||
let m = RefCell::new(0);
|
||||
let mut b = m.borrow_mut();
|
||||
let b1 = b.get();
|
||||
let b2 = b.get(); //~ ERROR cannot borrow `b` because it is already borrowed as mutable
|
||||
let b2 = b.get(); //~ ERROR cannot borrow
|
||||
}
|
||||
|
@ -15,6 +15,6 @@ fn main() {
|
||||
let p;
|
||||
{
|
||||
let b = m.borrow();
|
||||
p = b.get(); //~ ERROR borrowed value does not live long enough
|
||||
p = b.get(); //~ ERROR `b` does not live long enough
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ fn env<'a>(_: &'a uint, blk: |p: 'a |||) {
|
||||
|
||||
let mut state = 0;
|
||||
let statep = &mut state;
|
||||
blk(|| *statep = 1); //~ ERROR cannot infer an appropriate lifetime
|
||||
blk(|| *statep = 1); //~ ERROR cannot infer
|
||||
}
|
||||
|
||||
fn no_env_no_for<'a>(_: &'a uint, blk: |p: 'a |||) {
|
||||
@ -40,7 +40,7 @@ fn repeating_loop() {
|
||||
let state = 0;
|
||||
|
||||
loop {
|
||||
closure = || state; //~ ERROR cannot infer an appropriate lifetime
|
||||
closure = || state; //~ ERROR cannot infer
|
||||
break;
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ fn repeating_while() {
|
||||
let state = 0;
|
||||
|
||||
while true {
|
||||
closure = || state; //~ ERROR cannot infer an appropriate lifetime
|
||||
closure = || state; //~ ERROR cannot infer
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
// bounded by the current function call.
|
||||
|
||||
fn foo(a: int) {
|
||||
let _p: &'static int = &a; //~ ERROR borrowed value does not live long enough
|
||||
let _p: &'static int = &a; //~ ERROR `a` does not live long enough
|
||||
}
|
||||
|
||||
fn bar(a: int) {
|
||||
@ -20,7 +20,7 @@ fn bar(a: int) {
|
||||
}
|
||||
|
||||
fn zed<'a>(a: int) -> &'a int {
|
||||
&a //~ ERROR borrowed value does not live long enough
|
||||
&a //~ ERROR `a` does not live long enough
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -14,8 +14,7 @@ struct dog {
|
||||
|
||||
impl dog {
|
||||
pub fn chase_cat(&mut self) {
|
||||
let p: &'static mut uint = &mut self.cats_chased;
|
||||
//~^ ERROR cannot infer an appropriate lifetime
|
||||
let p: &'static mut uint = &mut self.cats_chased; //~ ERROR cannot infer
|
||||
*p += 1u;
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,7 @@ struct dog {
|
||||
impl dog {
|
||||
pub fn chase_cat(&mut self) {
|
||||
let _f = || {
|
||||
let p: &'static mut uint = &mut self.food;
|
||||
//~^ ERROR cannot infer an appropriate lifetime
|
||||
let p: &'static mut uint = &mut self.food; //~ ERROR cannot infer
|
||||
*p = 3u;
|
||||
};
|
||||
}
|
||||
|
@ -17,12 +17,12 @@ struct a_class<'a> { x:&'a int }
|
||||
|
||||
fn a_fn1<'a,'b>(e: an_enum<'a>) -> an_enum<'b> {
|
||||
return e; //~ ERROR mismatched types: expected `an_enum<'b>` but found `an_enum<'a>`
|
||||
//~^ ERROR cannot infer an appropriate lifetime
|
||||
//~^ ERROR cannot infer
|
||||
}
|
||||
|
||||
fn a_fn3<'a,'b>(e: a_class<'a>) -> a_class<'b> {
|
||||
return e; //~ ERROR mismatched types: expected `a_class<'b>` but found `a_class<'a>`
|
||||
//~^ ERROR cannot infer an appropriate lifetime
|
||||
//~^ ERROR cannot infer
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -14,7 +14,7 @@ enum ast<'a> {
|
||||
}
|
||||
|
||||
fn mk_add_bad1<'a,'b>(x: &'a ast<'a>, y: &'b ast<'b>) -> ast<'a> {
|
||||
add(x, y) //~ ERROR cannot infer an appropriate lifetime
|
||||
add(x, y) //~ ERROR cannot infer
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -14,7 +14,7 @@ enum ast<'a> {
|
||||
}
|
||||
|
||||
fn mk_add_bad2<'a>(x: &'a ast<'a>, y: &'a ast<'a>, z: &ast) -> ast {
|
||||
add(x, y) //~ ERROR cannot infer an appropriate lifetime
|
||||
add(x, y) //~ ERROR cannot infer
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -18,6 +18,6 @@ fn main() {
|
||||
|
||||
loop {
|
||||
let x = 1 + *p;
|
||||
p = &x; //~ ERROR borrowed value does not live long enough
|
||||
p = &x; //~ ERROR `x` does not live long enough
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ fn broken() {
|
||||
let mut _y = ~[&mut x];
|
||||
while x < 10 {
|
||||
let mut z = x;
|
||||
_y.push(&mut z); //~ ERROR borrowed value does not live long enough
|
||||
_y.push(&mut z); //~ ERROR `z` does not live long enough
|
||||
x += 1; //~ ERROR cannot assign
|
||||
}
|
||||
}
|
||||
|
@ -20,13 +20,13 @@ fn ordering1<'a, 'b>(x: &'a &'b uint) -> &'a uint {
|
||||
|
||||
fn ordering2<'a, 'b>(x: &'a &'b uint, y: &'a uint) -> &'b uint {
|
||||
// However, it is not safe to assume that 'b <= 'a
|
||||
&*y //~ ERROR cannot infer an appropriate lifetime
|
||||
&*y //~ ERROR cannot infer
|
||||
}
|
||||
|
||||
fn ordering3<'a, 'b>(x: &'a uint, y: &'b uint) -> &'a &'b uint {
|
||||
// Do not infer an ordering from the return value.
|
||||
let z: &'b uint = &*x;
|
||||
//~^ ERROR cannot infer an appropriate lifetime
|
||||
//~^ ERROR cannot infer
|
||||
fail!();
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ fn call1<'a>(x: &'a uint) {
|
||||
let y: uint = 3;
|
||||
let z: &'a & uint = &(&y);
|
||||
//~^ ERROR borrowed value does not live long enough
|
||||
//~^^ ERROR borrowed value does not live long enough
|
||||
//~^^ ERROR `y` does not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -24,7 +24,7 @@ impl<'b, T> Node<'b, T> {
|
||||
fn get<'a>(&'a self) -> &'b T {
|
||||
match self.next {
|
||||
Some(ref next) => next.get(),
|
||||
None => &self.val //~ ERROR cannot infer an appropriate lifetime
|
||||
None => &self.val //~ ERROR cannot infer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,8 +12,7 @@ fn wants_static_fn(_x: 'static ||) {}
|
||||
|
||||
fn main() {
|
||||
let i = 3;
|
||||
wants_static_fn(|| {
|
||||
//~^ ERROR cannot infer an appropriate lifetime due to conflicting requirements
|
||||
wants_static_fn(|| { //~ ERROR cannot infer
|
||||
info!("i={}", i);
|
||||
})
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ mod argparse {
|
||||
|
||||
impl<'a> Flag<'a> {
|
||||
pub fn set_desc(self, s: &str) -> Flag<'a> {
|
||||
Flag { //~ ERROR cannot infer an appropriate lifetime
|
||||
Flag { //~ ERROR cannot infer
|
||||
name: self.name,
|
||||
desc: s,
|
||||
max_count: self.max_count,
|
||||
|
@ -22,7 +22,7 @@ struct not_parameterized2 {
|
||||
|
||||
fn take1(p: parameterized1) -> parameterized1 { p }
|
||||
//~^ ERROR mismatched types
|
||||
//~^^ ERROR cannot infer an appropriate lifetime
|
||||
//~^^ ERROR cannot infer
|
||||
|
||||
fn take3(p: not_parameterized1) -> not_parameterized1 { p }
|
||||
fn take4(p: not_parameterized2) -> not_parameterized2 { p }
|
||||
|
@ -16,7 +16,7 @@ fn with<T>(f: |x: &int| -> T) -> T {
|
||||
|
||||
fn manip<'a>(x: &'a int) -> int {
|
||||
let z = with(|y| { select(x, y) });
|
||||
//~^ ERROR cannot infer an appropriate lifetime
|
||||
//~^ ERROR cannot infer
|
||||
*z
|
||||
}
|
||||
|
||||
|
@ -23,11 +23,11 @@ struct indirect2<'a> {
|
||||
}
|
||||
|
||||
fn take_direct(p: direct) -> direct { p } //~ ERROR mismatched types
|
||||
//~^ ERROR cannot infer an appropriate lifetime
|
||||
//~^ ERROR cannot infer
|
||||
|
||||
fn take_indirect1(p: indirect1) -> indirect1 { p }
|
||||
|
||||
fn take_indirect2(p: indirect2) -> indirect2 { p } //~ ERROR mismatched types
|
||||
//~^ ERROR cannot infer an appropriate lifetime
|
||||
//~^ ERROR cannot infer
|
||||
|
||||
fn main() {}
|
||||
|
@ -32,7 +32,7 @@ impl<'a> set_f<'a> for c<'a> {
|
||||
|
||||
fn set_f_bad(&self, b: @b) {
|
||||
self.f = b; //~ ERROR mismatched types: expected `@@&'a int` but found `@@&int`
|
||||
//~^ ERROR cannot infer an appropriate lifetime
|
||||
//~^ ERROR cannot infer
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,9 +12,10 @@ fn ignore(_f: <'z>|&'z int| -> &'z int) {}
|
||||
|
||||
fn nested() {
|
||||
let y = 3;
|
||||
ignore(|z| {
|
||||
if false { &y } else { z } //~ ERROR borrowed value does not live long enough
|
||||
});
|
||||
ignore(
|
||||
|z| { //~ ERROR `y` does not live long enough
|
||||
if false { &y } else { z }
|
||||
});
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -12,7 +12,7 @@ fn ignore<T>(t: T) {}
|
||||
|
||||
fn nested<'x>(x: &'x int) {
|
||||
let y = 3;
|
||||
let mut ay = &y; //~ ERROR cannot infer an appropriate lifetime
|
||||
let mut ay = &y; //~ ERROR cannot infer
|
||||
|
||||
ignore::< <'z>|&'z int|>(|z| {
|
||||
ay = x;
|
||||
@ -22,7 +22,7 @@ fn nested<'x>(x: &'x int) {
|
||||
|
||||
ignore::< <'z>|&'z int| -> &'z int>(|z| {
|
||||
if false { return x; } //~ ERROR mismatched types
|
||||
//~^ ERROR cannot infer an appropriate lifetime
|
||||
//~^ ERROR cannot infer
|
||||
if false { return ay; }
|
||||
return z;
|
||||
});
|
||||
|
@ -19,7 +19,7 @@ fn with<R>(f: <'a>|x: &'a int| -> R) -> R {
|
||||
fn return_it<'a>() -> &'a int {
|
||||
with(|o| o) //~ ERROR mismatched types
|
||||
//~^ ERROR lifetime of return value does not outlive the function call
|
||||
//~^^ ERROR cannot infer an appropriate lifetime
|
||||
//~^^ ERROR cannot infer
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -22,7 +22,7 @@ fn with<R>(f: |x: &int| -> R) -> R {
|
||||
fn return_it() -> &int {
|
||||
with(|o| o) //~ ERROR mismatched types
|
||||
//~^ ERROR lifetime of return value does not outlive the function call
|
||||
//~^^ ERROR cannot infer an appropriate lifetime
|
||||
//~^^ ERROR cannot infer
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -19,7 +19,7 @@ fn box_it<'r>(x: 'r ||) -> closure_box<'r> {
|
||||
fn main() {
|
||||
let cl_box = {
|
||||
let mut i = 3;
|
||||
box_it(|| i += 1) //~ ERROR cannot infer an appropriate lifetime
|
||||
box_it(|| i += 1) //~ ERROR cannot infer
|
||||
};
|
||||
(cl_box.cl)();
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ impl get_ctxt for Foo<'a> {
|
||||
}
|
||||
|
||||
fn make_gc2<'a,'b>(foo: Foo<'a>) -> @get_ctxt<'b> {
|
||||
return @foo as @get_ctxt; //~ ERROR cannot infer an appropriate lifetime
|
||||
return @foo as @get_ctxt; //~ ERROR cannot infer
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern: cannot infer an appropriate lifetime
|
||||
// error-pattern: cannot infer
|
||||
extern mod sync;
|
||||
use sync::RWLock;
|
||||
fn main() {
|
||||
|
@ -24,7 +24,7 @@ impl Trait<&'static str> for Struct {
|
||||
|
||||
fn main() {
|
||||
let person = ~"Fred";
|
||||
let person: &str = person; //~ ERROR borrowed value does not live long enough
|
||||
let person: &str = person; //~ ERROR `person[..]` does not live long enough
|
||||
let s: ~Trait<&'static str> = ~Struct { person: person };
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,6 @@ fn main() {
|
||||
let mut xs = ~[1, 2, 3, 4];
|
||||
|
||||
for x in xs.mut_iter() {
|
||||
xs.push(1) //~ ERROR cannot borrow `xs` because it is already borrowed as mutable
|
||||
xs.push(1) //~ ERROR cannot borrow `xs`
|
||||
}
|
||||
}
|
||||
|
@ -16,5 +16,6 @@ struct Refs { refs: ~[int], n: int }
|
||||
pub fn main() {
|
||||
let mut e = Refs{refs: ~[], n: 0};
|
||||
let _f: || = || error!("{}", e.n);
|
||||
e.refs.push(1);
|
||||
let x: &[int] = e.refs;
|
||||
assert_eq!(x.len(), 0);
|
||||
}
|
||||
|
@ -18,8 +18,11 @@ fn box_it<'r>(x: 'r ||) -> closure_box<'r> {
|
||||
|
||||
pub fn main() {
|
||||
let mut i = 3;
|
||||
let cl_box = box_it(|| i += 1);
|
||||
assert_eq!(i, 3);
|
||||
(cl_box.cl)();
|
||||
{
|
||||
let cl = || i += 1;
|
||||
let cl_box = box_it(cl);
|
||||
(cl_box.cl)();
|
||||
}
|
||||
assert_eq!(i, 4);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user