]> git.lizzy.rs Git - rust.git/commitdiff
test: Fix rustdoc and tests.
authorPatrick Walton <pcwalton@mimiga.net>
Tue, 17 Sep 2013 06:37:54 +0000 (23:37 -0700)
committerPatrick Walton <pcwalton@mimiga.net>
Tue, 24 Sep 2013 01:23:22 +0000 (18:23 -0700)
102 files changed:
doc/tutorial.md
src/libextra/c_vec.rs
src/librustc/driver/driver.rs
src/libstd/unstable/finally.rs
src/libsyntax/ext/base.rs
src/libsyntax/ext/expand.rs
src/libsyntax/fold.rs
src/test/auxiliary/cci_nested_lib.rs
src/test/auxiliary/issue4516_ty_param_lib.rs [deleted file]
src/test/bench/task-perf-alloc-unwind.rs
src/test/compile-fail/borrowck-addr-of-upvar.rs [deleted file]
src/test/compile-fail/borrowck-move-by-capture.rs
src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs
src/test/compile-fail/do2.rs
src/test/compile-fail/fn-variance-2.rs [deleted file]
src/test/compile-fail/fn-variance-3.rs [deleted file]
src/test/compile-fail/issue-1451.rs
src/test/compile-fail/issue-1896-1.rs [deleted file]
src/test/compile-fail/issue-2074.rs
src/test/compile-fail/issue-897.rs
src/test/compile-fail/kindck-owned.rs [deleted file]
src/test/compile-fail/lambda-mutate-nested.rs [deleted file]
src/test/compile-fail/lambda-mutate.rs [deleted file]
src/test/compile-fail/liveness-init-in-called-fn-expr.rs
src/test/compile-fail/liveness-init-in-fn-expr.rs
src/test/compile-fail/regions-fn-subtyping.rs
src/test/compile-fail/regions-fns.rs
src/test/compile-fail/regions-infer-at-fn-not-param.rs
src/test/compile-fail/regions-infer-contravariance-due-to-ret.rs
src/test/compile-fail/regions-infer-covariance-due-to-arg.rs
src/test/compile-fail/regions-infer-invariance-due-to-mutability-3.rs
src/test/compile-fail/regions-infer-invariance-due-to-mutability-4.rs
src/test/compile-fail/regions-infer-not-param.rs
src/test/compile-fail/sendfn-is-not-a-lambda.rs [deleted file]
src/test/debug-info/lexical-scope-in-managed-closure.rs [deleted file]
src/test/debug-info/var-captured-in-managed-closure.rs [deleted file]
src/test/pretty/block-arg-disambig.rs [deleted file]
src/test/pretty/do1.rs
src/test/pretty/fn-types.rs
src/test/run-fail/unwind-box-fn.rs [deleted file]
src/test/run-fail/unwind-closure.rs [deleted file]
src/test/run-fail/unwind-lambda.rs
src/test/run-pass/alignment-gep-tup-like-1.rs
src/test/run-pass/alignment-gep-tup-like-2.rs
src/test/run-pass/block-arg-call-as.rs
src/test/run-pass/block-arg-used-as-lambda.rs [deleted file]
src/test/run-pass/borrowck-move-by-capture-ok.rs
src/test/run-pass/call-closure-from-overloaded-op.rs
src/test/run-pass/cap-clause-move.rs
src/test/run-pass/close-over-big-then-small-data.rs
src/test/run-pass/cycle-collection2.rs
src/test/run-pass/cycle-collection4.rs [deleted file]
src/test/run-pass/cycle-collection5.rs [deleted file]
src/test/run-pass/do-no-args.rs
src/test/run-pass/do1.rs
src/test/run-pass/do2.rs
src/test/run-pass/do3.rs
src/test/run-pass/expr-block-fn.rs
src/test/run-pass/expr-block-generic-box1.rs
src/test/run-pass/expr-block-generic-box2.rs
src/test/run-pass/expr-block-generic-unique1.rs
src/test/run-pass/expr-block-generic-unique2.rs
src/test/run-pass/expr-block-generic.rs
src/test/run-pass/expr-if-generic-box1.rs
src/test/run-pass/expr-if-generic-box2.rs
src/test/run-pass/expr-if-generic.rs
src/test/run-pass/expr-match-generic-box1.rs
src/test/run-pass/expr-match-generic-box2.rs
src/test/run-pass/expr-match-generic-unique1.rs
src/test/run-pass/expr-match-generic-unique2.rs
src/test/run-pass/expr-match-generic.rs
src/test/run-pass/fixed-point-bind-box.rs [deleted file]
src/test/run-pass/fixed-point-bind-unique.rs [deleted file]
src/test/run-pass/fn-assign-managed-to-bare-1.rs [deleted file]
src/test/run-pass/fn-assign-managed-to-bare-2.rs [deleted file]
src/test/run-pass/fn-bare-coerce-to-shared.rs [deleted file]
src/test/run-pass/fn-coerce-field.rs
src/test/run-pass/fn-type-infer.rs
src/test/run-pass/fun-call-variants.rs
src/test/run-pass/hashmap-memory.rs
src/test/run-pass/infer-with-expected.rs [deleted file]
src/test/run-pass/issue-1516.rs
src/test/run-pass/issue-2185.rs
src/test/run-pass/issue-2633.rs
src/test/run-pass/issue-3052.rs
src/test/run-pass/issue-3429.rs
src/test/run-pass/issue-4929.rs [deleted file]
src/test/run-pass/issue-5783.rs [deleted file]
src/test/run-pass/issue4516_ty_param.rs [deleted file]
src/test/run-pass/lambda-infer-unresolved.rs
src/test/run-pass/lambda-no-leak.rs [deleted file]
src/test/run-pass/last-use-in-cap-clause.rs
src/test/run-pass/last-use-is-capture.rs
src/test/run-pass/monomorphize-trait-in-fn-at.rs [deleted file]
src/test/run-pass/move-nullary-fn.rs
src/test/run-pass/newlambdas-ret-infer.rs
src/test/run-pass/newlambdas-ret-infer2.rs
src/test/run-pass/newlambdas.rs
src/test/run-pass/propagate-expected-type-through-block.rs [deleted file]
src/test/run-pass/reflect-visit-data.rs
src/test/run-pass/regions-fn-subtyping.rs
src/test/run-pass/unused-move-capture.rs

index dd552f45f4e2034d37dfc7d1cc82c9e435cfa037..a8d384226a3507b90d715728aa929740305c7e3e 100644 (file)
@@ -1469,34 +1469,6 @@ cannot be stored in data structures or returned from
 functions. Despite these limitations, stack closures are used
 pervasively in Rust code.
 
-## Managed closures
-
-When you need to store a closure in a data structure, a stack closure
-will not do, since the compiler will refuse to let you store it. For
-this purpose, Rust provides a type of closure that has an arbitrary
-lifetime, written `@fn` (boxed closure, analogous to the `@` pointer
-type described earlier). This type of closure *is* first-class.
-
-A managed closure does not directly access its environment, but merely
-copies out the values that it closes over into a private data
-structure. This means that it can not assign to these variables, and
-cannot observe updates to them.
-
-This code creates a closure that adds a given string to its argument,
-returns it from a function, and then calls it:
-
-~~~~
-fn mk_appender(suffix: ~str) -> @fn(~str) -> ~str {
-    // The compiler knows that we intend this closure to be of type @fn
-    return |s| s + suffix;
-}
-
-fn main() {
-    let shout = mk_appender(~"!");
-    println(shout(~"hey ho, let's go"));
-}
-~~~~
-
 ## Owned closures
 
 Owned closures, written `~fn` in analogy to the `~` pointer type,
index 99bb67ad89c3745643dc68ab25aedb67b83d745c..bd3ce20742ed19e26382382585b7ebec9862afff 100644 (file)
@@ -162,8 +162,11 @@ struct LibcFree {
     }
 
     impl Runnable for LibcFree {
+        #[fixed_stack_segment]
         fn run(~self) {
-            libc::free(self.mem)
+            unsafe {
+                libc::free(self.mem)
+            }
         }
     }
 
index ae1133e1880603a96d79e549f54a96893e71530a..c9a5ca2c61c40ac8362fa5788267e0c6990a922f 100644 (file)
@@ -1065,8 +1065,12 @@ fn test_switch_implies_cfg_test() {
               Err(f) => fail!("test_switch_implies_cfg_test: %s", f.to_err_msg())
             };
         let sessopts = build_session_options(
-            @"rustc", matches, diagnostic::emit);
-        let sess = build_session(sessopts, diagnostic::emit);
+            @"rustc",
+            matches,
+            @diagnostic::DefaultEmitter as @diagnostic::Emitter);
+        let sess = build_session(sessopts,
+                                 @diagnostic::DefaultEmitter as
+                                    @diagnostic::Emitter);
         let cfg = build_configuration(sess);
         assert!((attr::contains_name(cfg, "test")));
     }
@@ -1083,8 +1087,12 @@ fn test_switch_implies_cfg_test_unless_cfg_test() {
               }
             };
         let sessopts = build_session_options(
-            @"rustc", matches, diagnostic::emit);
-        let sess = build_session(sessopts, diagnostic::emit);
+            @"rustc",
+            matches,
+            @diagnostic::DefaultEmitter as @diagnostic::Emitter);
+        let sess = build_session(sessopts,
+                                 @diagnostic::DefaultEmitter as
+                                    @diagnostic::Emitter);
         let cfg = build_configuration(sess);
         let mut test_items = cfg.iter().filter(|m| "test" == m.name());
         assert!(test_items.next().is_some());
index d98c13083dee8f48fbc88a7ef535f6f5068079ae..ba5986aa4ab9db3fa81bf6e371879c235f32421e 100644 (file)
@@ -118,14 +118,3 @@ fn spawn_with_finalizer(f: ~fn()) {
     spawn_with_finalizer(owned);
 }
 
-#[test]
-fn test_managed() {
-    let i = @mut 10;
-    let managed: @fn() -> int = || {
-        let r = *i;
-        *i += 10;
-        r
-    };
-    assert_eq!(do managed.finally {}, 10);
-    assert_eq!(*i, 20);
-}
index 63816072c291486251a1e27548f19a67206fbcb6..48eb9a350f1357c4abcce7a52ff79ca10d1ccedb 100644 (file)
@@ -217,7 +217,8 @@ fn builtin_item_tt_no_ctxt(f: SyntaxExpanderTTItemFunNoCtxt) -> @Transformer {
                             }));
     syntax_expanders.insert(intern(&"macro_rules"),
                             @SE(IdentTT(@SyntaxExpanderTTItem {
-                                expander: SyntaxExpanderTTItemExpanderWithContext(ext::tt::macro_rules::add_new_extension),
+                                expander: SyntaxExpanderTTItemExpanderWithContext(
+                                    ext::tt::macro_rules::add_new_extension),
                                 span: None,
                             } as @SyntaxExpanderTTItemTrait,
                             None)));
index 60aa7cc5f9292bc9f1956d308042018cfe1d419b..004a889fb4df77632d7cdec207c3c2112e0edaed 100644 (file)
@@ -772,7 +772,7 @@ fn fold_ident(&self, id: ast::Ident) -> ast::Ident {
 
 // given a mutable list of renames, return a tree-folder that applies those
 // renames.
-fn renames_to_fold(renames: @mut ~[(ast::Ident,ast::Name)]) -> @ast_fold {
+pub fn renames_to_fold(renames: @mut ~[(ast::Ident,ast::Name)]) -> @ast_fold {
     @IdentRenamer {
         renames: renames,
     } as @ast_fold
@@ -1524,7 +1524,7 @@ fn make_dummy_attr(s: @str) -> ast::Attribute {
         let ident_str = @"x";
         let tts = string_to_tts(ident_str);
         let fm = fresh_mark();
-        let marked_once = fold::fold_tts(tts,new_mark_folder(fm) as @fold::ast_fold);
+        let marked_once = fold::fold_tts(tts,new_mark_folder(fm));
         assert_eq!(marked_once.len(),1);
         let marked_once_ctxt =
             match marked_once[0] {
index 66fe125aef4cf7c6b0adf9dd4660c4341233c526..a25f267c45891832cc18a25d12a725607ba25fe6 100644 (file)
@@ -869,7 +869,7 @@ mod test {
     use parse::token;
     use print::pprust;
     use super::*;
-    
+
     // this version doesn't care about getting comments or docstrings in.
     fn fake_print_crate(s: @pprust::ps, crate: &ast::Crate) {
         pprust::print_mod(s, &crate.module, crate.attrs);
@@ -879,7 +879,7 @@ fn fake_print_crate(s: @pprust::ps, crate: &ast::Crate) {
     struct ToZzIdentFolder;
 
     impl ast_fold for ToZzIdentFolder {
-        fn fold_ident(&self, _: ident) -> ident {
+        fn fold_ident(&self, _: ast::Ident) -> ast::Ident {
             token::str_to_ident("zz")
         }
     }
@@ -921,16 +921,5 @@ macro_rules! assert_pred (
                                     token::get_ident_interner()),
                      ~"zz!zz((zz$zz:zz$(zz $zz:zz)zz+=>(zz$(zz$zz$zz)+)))");
     }
-
-    // and in cast expressions... this appears to be an existing bug.
-    #[test] fn ident_transformation_in_types () {
-        let zz_fold = ToZzIdentFolder;
-        let ast = string_to_crate(@"fn a() {let z = 13 as int;}");
-        assert_pred!(matches_codepattern,
-                     "matches_codepattern",
-                     pprust::to_str(&zz_fold.fold_crate(ast),fake_print_crate,
-                                    token::get_ident_interner()),
-                     ~"fn zz(){let zz=13 as zz;}");
-    }
 }
 
index c9809438d94622020cd6798cdab3c2f50b3559c2..350bd09826fad67c7d66950fd6ee060e63a8289c 100644 (file)
@@ -14,7 +14,7 @@ pub struct Entry<A,B> {
 }
 
 pub struct alist<A,B> {
-    eq_fn: @fn(A,A) -> bool,
+    eq_fn: extern "Rust" fn(A,A) -> bool,
     data: @mut ~[Entry<A,B>]
 }
 
diff --git a/src/test/auxiliary/issue4516_ty_param_lib.rs b/src/test/auxiliary/issue4516_ty_param_lib.rs
deleted file mode 100644 (file)
index cd90c9b..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-pub fn to_closure<A:'static + Clone>(x: A) -> @fn() -> A {
-    let result: @fn() -> A = || x.clone();
-    result
-}
index f383f7a101fcca9cb8d0a35ada3c35124828889a..991c102e9f0b0387d2ff42457726d7849c5068fa 100644 (file)
@@ -46,7 +46,6 @@ fn run(repeat: int, depth: int) {
 struct State {
     box: @nillist,
     unique: ~nillist,
-    fn_box: @fn() -> @nillist,
     tuple: (@nillist, ~nillist),
     vec: ~[@nillist],
     res: r
@@ -79,19 +78,15 @@ fn recurse_or_fail(depth: int, st: Option<State>) {
             State {
                 box: @Nil,
                 unique: ~Nil,
-                fn_box: || @Nil::<()>,
                 tuple: (@Nil, ~Nil),
                 vec: ~[@Nil],
                 res: r(@Nil)
             }
           }
           Some(st) => {
-            let fn_box = st.fn_box;
-
             State {
                 box: @Cons((), st.box),
                 unique: ~Cons((), @*st.unique),
-                fn_box: || @Cons((), fn_box()),
                 tuple: (@Cons((), st.tuple.first()),
                         ~Cons((), @*st.tuple.second())),
                 vec: st.vec + &[@Cons((), *st.vec.last())],
diff --git a/src/test/compile-fail/borrowck-addr-of-upvar.rs b/src/test/compile-fail/borrowck-addr-of-upvar.rs
deleted file mode 100644 (file)
index 83baedc..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn foo(x: @int) -> @fn() -> &'static int {
-    let result: @fn() -> &'static int = || &*x;  //~ ERROR cannot root
-    result
-}
-
-fn bar(x: @int) -> @fn() -> &int {
-    let result: @fn() -> &int = || &*x; //~ ERROR cannot root
-    result
-}
-
-fn zed(x: @int) -> @fn() -> int {
-    let result: @fn() -> int = || *&*x;
-    result
-}
-
-fn main() {
-}
index ecb18993d9300a1db9266e29c42b48d313ddc973..5994b9e85d5ae97e6a3021fb012c384f6ada4d62 100644 (file)
@@ -1,13 +1,13 @@
 pub fn main() {
     let foo = ~3;
     let _pfoo = &foo;
-    let _f: @fn() -> int = || *foo + 5;
+    let _f: ~fn() -> int = || *foo + 5;
     //~^ ERROR cannot move `foo`
 
     // 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: @fn() -> int = || *bar; //~ ERROR capture of moved value
+        let _h: ~fn() -> int = || *bar; //~ ERROR capture of moved value
     };
 }
index b38cb89548807b04502a6e1de1fe2a60b2f5c040..525f8f4a932b17a50ffd96978e6531d79d6d31e7 100644 (file)
@@ -9,10 +9,10 @@
 // except according to those terms.
 
 struct X {
-    field: @fn:Send(),
+    field: ~fn:Send(),
 }
 
-fn foo(blk: @fn:()) -> X {
+fn foo(blk: ~fn:()) -> X {
     return X { field: blk }; //~ ERROR expected bounds `Send` but found no bounds
 }
 
index 4466c07518fece94f3f2bc948591a722837121b8..1bffdaa682cdcd5c1ee13f78c9dd7f99074abf4e 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn f(f: @fn(int) -> bool) -> bool { f(10i) }
+fn f(f: &fn(int) -> bool) -> bool { f(10i) }
 
 fn main() {
     assert!(do f() |i| { i == 10i } == 10i);
diff --git a/src/test/compile-fail/fn-variance-2.rs b/src/test/compile-fail/fn-variance-2.rs
deleted file mode 100644 (file)
index ab55919..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn reproduce<T>(t: T) -> @fn() -> T {
-    let result: @fn() -> T = || t;
-    result
-}
-
-fn main() {
-    // type of x is the variable X,
-    // with the lower bound @mut int
-    let x = @mut 3;
-
-    // type of r is @fn() -> X
-    let r = reproduce(x);
-
-    // Requires that X be a subtype of
-    // @mut int.
-    let f: @mut int = r();
-
-    // Bad.
-    let h: @int = r(); //~ ERROR (values differ in mutability)
-}
diff --git a/src/test/compile-fail/fn-variance-3.rs b/src/test/compile-fail/fn-variance-3.rs
deleted file mode 100644 (file)
index e42c6b6..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn mk_identity<T>() -> @fn(T) -> T {
-    let result: @fn(t: T) -> T = |t| t;
-    result
-}
-
-fn main() {
-    // type of r is @fn(X) -> X
-    // for some fresh X
-    let r = mk_identity();
-
-    // @mut int <: X
-    r(@mut 3);
-
-    // @int <: X
-    //
-    // Here the type check fails because @const is gone and there is no
-    // supertype.
-    r(@3);  //~ ERROR mismatched types
-
-    // Here the type check succeeds.
-    *r(@mut 3) = 4;
-}
index a295e8eb7edb01ac0cee3df173d8c09c3274498a..0d8acaa44647bcaf14e29b56033ec4398645bf3b 100644 (file)
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 // xfail-test
-struct T { f: @fn() };
-struct S { f: @fn() };
+struct T { f: extern "Rust" fn() };
+struct S { f: extern "Rust" fn() };
 
 fn fooS(t: S) {
 }
@@ -22,11 +22,11 @@ fn bar() {
 }
 
 fn main() {
-    let x: @fn() = bar;
+    let x: extern "Rust" fn() = bar;
     fooS(S {f: x});
     fooS(S {f: bar});
 
-    let x: @fn() = bar;
+    let x: extern "Rust" fn() = bar;
     fooT(T {f: x});
     fooT(T {f: bar});
 }
diff --git a/src/test/compile-fail/issue-1896-1.rs b/src/test/compile-fail/issue-1896-1.rs
deleted file mode 100644 (file)
index 4750f68..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test that we require managed closures to be rooted when borrowed.
-
-struct boxedFn<'self> { theFn: &'self fn() -> uint }
-
-fn createClosure (closedUint: uint) -> boxedFn {
-    let theFn: @fn() -> uint = || closedUint;
-    boxedFn {theFn: theFn} //~ ERROR cannot root
-}
-
-fn main () {
-    let aFn: boxedFn = createClosure(10);
-
-    let myInt: uint = (aFn.theFn)();
-
-    assert_eq!(myInt, 10);
-}
index 40c2772f2347f0ced90dd3e179d1700632fc99a0..7815fca16c69bd72898cd336f5822f0af744bd0c 100644 (file)
 
 // xfail-test
 fn main() {
-    let one: @fn() -> uint = || {
+    let one: &fn() -> uint = || {
         enum r { a };
         a as uint
     };
-    let two = @fn() -> uint = || {
+    let two = &fn() -> uint = || {
         enum r { a };
         a as uint
     };
index 103156175a3fd0d8447568173f6cb8b0be90310f..8df73aef6109dfd9be3967192e4fff000e479911 100644 (file)
@@ -1,3 +1,5 @@
+// xfail-test
+
 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
diff --git a/src/test/compile-fail/kindck-owned.rs b/src/test/compile-fail/kindck-owned.rs
deleted file mode 100644 (file)
index 2dfdb26..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn copy1<T:Clone>(t: T) -> @fn() -> T {
-    let result: @fn() -> T = || t.clone();  //~ ERROR does not fulfill `'static`
-    result
-}
-
-fn copy2<T:Clone + 'static>(t: T) -> @fn() -> T {
-    let result: @fn() -> T = || t.clone();
-    result
-}
-
-fn main() {
-    let x = &3;
-    copy2(&x); //~ ERROR does not fulfill `'static`
-
-    copy2(@3);
-    copy2(@&x); //~ ERROR value may contain borrowed pointers
-    //~^ ERROR does not fulfill `'static`
-}
diff --git a/src/test/compile-fail/lambda-mutate-nested.rs b/src/test/compile-fail/lambda-mutate-nested.rs
deleted file mode 100644 (file)
index bfd1e12..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Make sure that nesting a block within a @fn doesn't let us
-// mutate upvars from a @fn.
-fn f2(x: &fn()) { x(); }
-
-fn main() {
-    let i = 0;
-    let ctr: @fn() -> int = || { f2(|| i = i + 1 ); i };
-    //~^ ERROR cannot assign
-    error!(ctr());
-    error!(ctr());
-    error!(ctr());
-    error!(ctr());
-    error!(ctr());
-    error!(i);
-}
diff --git a/src/test/compile-fail/lambda-mutate.rs b/src/test/compile-fail/lambda-mutate.rs
deleted file mode 100644 (file)
index a848d86..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Make sure we can't write to upvars from @fns
-fn main() {
-    let i = 0;
-    let ctr: @fn() -> int = || { i = i + 1; i };
-    //~^ ERROR cannot assign
-    error!(ctr());
-    error!(ctr());
-    error!(ctr());
-    error!(ctr());
-    error!(ctr());
-    error!(i);
-}
index 1fddea8096607570f5252b1eda7c458b6166a7a9..7054cb0d901ce54a9cf3d27ed224c1545e7bea0e 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn main() {
-    let j: @fn() -> int = || {
+    let j: &fn() -> int = || {
         let i: int;
         i //~ ERROR use of possibly uninitialized variable: `i`
     };
index b7a715d29583ae6ebc5531fe7e17eb868a32ef37..b6c7895235b1009755f573ef98f536f1bffa223d 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn main() {
-    let f: @fn() -> int = || {
+    let f: &fn() -> int = || {
         let i: int;
         i //~ ERROR use of possibly uninitialized variable: `i`
     };
index face9c742141d97e441f05c082f7d262ebcdcc58..5928d31a66860479ad0b0523a4cb8e946c8cbf96 100644 (file)
@@ -8,8 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn of<T>() -> @fn(T) { fail!(); }
-fn subtype<T>(x: @fn(T)) { fail!(); }
+fn of<T>() -> &fn(T) { fail!(); }
+fn subtype<T>(x: &fn(T)) { fail!(); }
 
 fn test_fn<'x,'y,'z,T>(_x: &'x T, _y: &'y T, _z: &'z T) {
     // Here, x, y, and z are free.  Other letters
@@ -40,18 +40,6 @@ fn test_fn<'x,'y,'z,T>(_x: &'x T, _y: &'y T, _z: &'z T) {
 
     subtype::<&fn<'x,'y>(&'x T, &'y T)>(
         of::<&fn<'a,'b>(&'a T, &'b T)>()); //~ ERROR mismatched types
-
-    subtype::<&fn<'x,'a>(&'x T) -> @fn(&'a T)>(
-        of::<&fn<'x,'a>(&'x T) -> @fn(&'a T)>());
-
-    subtype::<&fn<'a>(&'a T) -> @fn(&'a T)>(
-        of::<&fn<'a,'b>(&'a T) -> @fn(&'b T)>()); //~ ERROR mismatched types
-
-    subtype::<&fn<'a>(&'a T) -> @fn(&'a T)>(
-        of::<&fn<'x,'b>(&'x T) -> @fn(&'b T)>()); //~ ERROR mismatched types
-
-    subtype::<&fn<'a,'b>(&'a T) -> @fn(&'b T)>(
-        of::<&fn<'a>(&'a T) -> @fn(&'a T)>());
 }
 
 fn main() {}
index 4f6cbdfdd6556bbb6e08622405b97fe0bc124588..715261d816a4e3f6998ec6d0fd36e35921b9259c 100644 (file)
@@ -12,7 +12,7 @@
 // we reported errors in this case:
 
 fn not_ok<'b>(a: &uint, b: &'b uint) {
-    let mut g: @fn(x: &uint) = |x: &'b uint| {};
+    let mut g: &fn(x: &uint) = |x: &'b uint| {};
     //~^ ERROR mismatched types
     g(a);
 }
index 488d1f3940d6e6655a1a28348f4616dc5752ed5a..3ddae976ce317409f9ebc6223f519e695baa02c1 100644 (file)
@@ -13,11 +13,11 @@ struct parameterized1<'self> {
 }
 
 struct not_parameterized1 {
-    g: @fn()
+    g: &'static fn()
 }
 
 struct not_parameterized2 {
-    g: @fn()
+    g: &'static fn()
 }
 
 fn take1(p: parameterized1) -> parameterized1 { p }
index 15f40a9173582d68b9c3a0d5f5d85406b591f61e..3fcc5184b4a7c8404df6c416ffc032249090ba4b 100644 (file)
@@ -14,7 +14,7 @@
 // the normal case.
 
 struct contravariant<'self> {
-    f: @fn() -> &'self int
+    f: &'static fn() -> &'self int
 }
 
 fn to_same_lifetime<'r>(bi: contravariant<'r>) {
index c33ca2dab2ee004ea5b6fa7fc66c4a7be5bb155a..4b26e6b60216372277337a5e10f8133b174a1339 100644 (file)
@@ -13,7 +13,7 @@
 // You can upcast to a *larger region* but not a smaller one.
 
 struct covariant<'self> {
-    f: @fn(x: &'self int) -> int
+    f: &'static fn(x: &'self int) -> int
 }
 
 fn to_same_lifetime<'r>(bi: covariant<'r>) {
index 92447c1ef8d4571f13c83d5a9be5420c83c21b21..6e322b170e8c33e48481b586fa9d4338105f6559 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 struct invariant<'self> {
-    f: @fn(x: @mut &'self int)
+    f: &'static fn(x: @mut &'self int)
 }
 
 fn to_same_lifetime<'r>(bi: invariant<'r>) {
index 61adba3aec13457c063c80f5abf4c3b29309a070..380e9b27ff9c700ae1edce8abe343dfe999460fa 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 struct invariant<'self> {
-    f: @fn() -> @mut &'self int
+    f: &'static fn() -> @mut &'self int
 }
 
 fn to_same_lifetime<'r>(bi: invariant<'r>) {
index fa853b82d9ebd05badc774ea2ec771542ff4c419..47c1f7a5757dea49dcf1a0bc0ef2caf7504401fd 100644 (file)
@@ -14,12 +14,12 @@ struct direct<'self> {
 
 struct indirect1 {
     // Here the lifetime parameter of direct is bound by the fn()
-    g: @fn(direct)
+    g: &'static fn(direct)
 }
 
 struct indirect2<'self> {
     // But here it is set to 'self
-    g: @fn(direct<'self>)
+    g: &'static fn(direct<'self>)
 }
 
 fn take_direct(p: direct) -> direct { p } //~ ERROR mismatched types
diff --git a/src/test/compile-fail/sendfn-is-not-a-lambda.rs b/src/test/compile-fail/sendfn-is-not-a-lambda.rs
deleted file mode 100644 (file)
index 609439d..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn test(f: @fn(uint) -> uint) -> uint {
-    return f(22u);
-}
-
-fn main() {
-    let f: ~fn(x: uint) -> uint = |x| 4u;
-    info!(test(f)); //~ ERROR expected @ closure, found ~ closure
-}
diff --git a/src/test/debug-info/lexical-scope-in-managed-closure.rs b/src/test/debug-info/lexical-scope-in-managed-closure.rs
deleted file mode 100644 (file)
index 96da78a..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// compile-flags:-Z extra-debug-info
-// debugger:rbreak zzz
-// debugger:run
-
-// debugger:finish
-// debugger:print x
-// check:$1 = false
-// debugger:continue
-
-// debugger:finish
-// debugger:print x
-// check:$2 = false
-// debugger:continue
-
-// debugger:finish
-// debugger:print x
-// check:$3 = 1000
-// debugger:continue
-
-// debugger:finish
-// debugger:print x
-// check:$4 = 2.5
-// debugger:continue
-
-// debugger:finish
-// debugger:print x
-// check:$5 = true
-// debugger:continue
-
-// debugger:finish
-// debugger:print x
-// check:$6 = false
-// debugger:continue
-
-fn main() {
-
-    let x = false;
-
-    zzz();
-    sentinel();
-
-    let managed_closure: @fn(int) = |x| {
-        zzz();
-        sentinel();
-
-        let x = 2.5;
-
-        zzz();
-        sentinel();
-
-        let x = true;
-
-        zzz();
-        sentinel();
-    };
-
-    zzz();
-    sentinel();
-
-    managed_closure(1000);
-
-    zzz();
-    sentinel();
-}
-
-fn zzz() {()}
-fn sentinel() {()}
diff --git a/src/test/debug-info/var-captured-in-managed-closure.rs b/src/test/debug-info/var-captured-in-managed-closure.rs
deleted file mode 100644 (file)
index b20f403..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// compile-flags:-Z extra-debug-info
-// debugger:rbreak zzz
-// debugger:run
-// debugger:finish
-
-// debugger:print constant
-// check:$1 = 1
-// debugger:print a_struct
-// check:$2 = {a = -2, b = 3.5, c = 4}
-// debugger:print *owned
-// check:$3 = 5
-// debugger:print managed->val
-// check:$4 = 6
-
-#[allow(unused_variable)];
-
-struct Struct {
-    a: int,
-    b: float,
-    c: uint
-}
-
-fn main() {
-    let constant = 1;
-
-    let a_struct = Struct {
-        a: -2,
-        b: 3.5,
-        c: 4
-    };
-
-    let owned = ~5;
-    let managed = @6;
-
-    let closure: @fn() = || {
-        zzz();
-        do_something(&constant, &a_struct.a, owned, managed);
-    };
-
-    closure();
-}
-
-fn do_something(_: &int, _:&int, _:&int, _:&int) {
-}
-
-fn zzz() {()}
diff --git a/src/test/pretty/block-arg-disambig.rs b/src/test/pretty/block-arg-disambig.rs
deleted file mode 100644 (file)
index c0f173a..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn blk1(_b: &fn()) -> @fn() { return || { }; }
-fn test1() { (do blk1 { info!("hi"); })(); }
index 6f9aa28f11a939739c0678e59a70ac7ce74f662e..751aedb39a3a8a00ddb2f0cb72d538ac701f5c9d 100644 (file)
@@ -10,6 +10,6 @@
 
 // pp-exact
 
-fn f(f: @fn(int)) { f(10) }
+fn f(f: &fn(int)) { f(10) }
 
 fn main() { do f |i| { assert!(i == 10) } }
index 0545e9ed166f26fb1f48350d602606b67989f804..b000c9f9137ae51447e544d65e1f2173aa48389b 100644 (file)
@@ -12,6 +12,5 @@
 
 fn from_foreign_fn(_x: extern "Rust" fn()) { }
 fn from_stack_closure(_x: &fn()) { }
-fn from_box_closure(_x: @fn()) { }
 fn from_unique_closure(_x: ~fn()) { }
 fn main() { }
diff --git a/src/test/run-fail/unwind-box-fn.rs b/src/test/run-fail/unwind-box-fn.rs
deleted file mode 100644 (file)
index a94f904..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// error-pattern:fail
-
-fn failfn() {
-    fail!();
-}
-
-fn main() {
-    let y = ~0;
-    let x: @@fn() = @|| {
-        error!(y.clone());
-    };
-    failfn();
-    error!(x);
-}
diff --git a/src/test/run-fail/unwind-closure.rs b/src/test/run-fail/unwind-closure.rs
deleted file mode 100644 (file)
index 5ea71c9..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// error-pattern:fail
-
-fn f(_a: @int) {
-    fail!();
-}
-
-fn main() {
-    let b = @0;
-    let g: @fn() = || f(b);
-    g();
-}
index 74d6ab00802e0e8a84e4b5d371bac80e1e260fc2..65d9fce5ff5dc8acf74499eeef0a9f1641083c16 100644 (file)
@@ -14,7 +14,7 @@ fn main() {
     let cheese = ~"roquefort";
     let carrots = @~"crunchy";
 
-    let result: @fn(@~str, &fn(~str)) = (|tasties, macerate| {
+    let result: &'static fn(@~str, &fn(~str)) = (|tasties, macerate| {
         macerate((*tasties).clone());
     });
     result(carrots, |food| {
index a821e4647c12831c2019a507ff151a1c38764065..4352c139b620bdf8bedfb7ebb0edfd98ecdb789a 100644 (file)
@@ -12,13 +12,30 @@ struct pair<A,B> {
     a: A, b: B
 }
 
-fn f<A:Clone + 'static>(a: A, b: u16) -> @fn() -> (A, u16) {
-    let result: @fn() -> (A, u16) = || (a.clone(), b);
-    result
+trait Invokable<A> {
+    fn f(&self) -> (A, u16);
+}
+
+struct Invoker<A> {
+    a: A,
+    b: u16,
+}
+
+impl<A:Clone> Invokable<A> for Invoker<A> {
+    fn f(&self) -> (A, u16) {
+        (self.a.clone(), self.b)
+    }
+}
+
+fn f<A:Clone + 'static>(a: A, b: u16) -> @Invokable<A> {
+    @Invoker {
+        a: a,
+        b: b,
+    } as @Invokable<A>
 }
 
 pub fn main() {
-    let (a, b) = f(22_u64, 44u16)();
+    let (a, b) = f(22_u64, 44u16).f();
     info!("a=%? b=%?", a, b);
     assert_eq!(a, 22u64);
     assert_eq!(b, 44u16);
index e924c31bad6b5dfef0b242d186a74e068bc654c3..9bf95968a9a211af58eab3cc663133a436a9a324 100644 (file)
@@ -23,13 +23,30 @@ fn make_cycle<A:'static>(a: A) {
     g.rec = Some(g);
 }
 
+struct Invoker<A,B> {
+    a: A,
+    b: B,
+}
+
+trait Invokable<A,B> {
+    fn f(&self) -> (A, B);
+}
+
+impl<A:Clone,B:Clone> Invokable<A,B> for Invoker<A,B> {
+    fn f(&self) -> (A, B) {
+        (self.a.clone(), self.b.clone())
+    }
+}
+
 fn f<A:Send + Clone + 'static,
      B:Send + Clone + 'static>(
      a: A,
      b: B)
-     -> @fn() -> (A, B) {
-    let result: @fn() -> (A, B) = || (a.clone(), b.clone());
-    result
+     -> @Invokable<A,B> {
+    @Invoker {
+        a: a,
+        b: b,
+    } as @Invokable<A,B>
 }
 
 pub fn main() {
@@ -37,7 +54,7 @@ pub fn main() {
     let y = 44_u64;
     let z = f(~x, y);
     make_cycle(z);
-    let (a, b) = z();
+    let (a, b) = z.f();
     info!("a=%u b=%u", *a as uint, b as uint);
     assert_eq!(*a, x);
     assert_eq!(b, y);
index d68b0be632eb349b03bdb29de1277074045d3b31..6a59278982ad3fddbe30930bdf194b5900df4641 100644 (file)
@@ -14,10 +14,6 @@ fn asSendfn( f : ~fn()->uint ) -> uint {
    return f();
 }
 
-fn asLambda( f : @fn()->uint ) -> uint {
-   return f();
-}
-
 fn asBlock( f : &fn()->uint ) -> uint {
    return f();
 }
@@ -25,8 +21,6 @@ fn asBlock( f : &fn()->uint ) -> uint {
 pub fn main() {
    let x = asSendfn(|| 22u);
    assert_eq!(x, 22u);
-   let x = asLambda(|| 22u);
-   assert_eq!(x, 22u);
    let x = asBlock(|| 22u);
    assert_eq!(x, 22u);
 }
diff --git a/src/test/run-pass/block-arg-used-as-lambda.rs b/src/test/run-pass/block-arg-used-as-lambda.rs
deleted file mode 100644 (file)
index 34fa7e3..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn to_lambda(f: @fn(uint) -> uint) -> @fn(uint) -> uint {
-    return f;
-}
-
-pub fn main() {
-    let x: @fn(uint) -> uint = to_lambda(|x| x * 2u );
-    let y = to_lambda(x);
-
-    let x_r = x(22u);
-    let y_r = y(x_r);
-
-    assert_eq!(x_r, 44u);
-    assert_eq!(y_r, 88u);
-}
index 095e2ba6fea4b0e688f4004de6230189ef181f4c..f6328c8c65822cd8eb8ff0d574601076ce281d0d 100644 (file)
@@ -1,5 +1,5 @@
 pub fn main() {
     let bar = ~3;
-    let h: @fn() -> int = || *bar;
+    let h: ~fn() -> int = || *bar;
     assert_eq!(h(), 3);
 }
index cc8d8e96195561e4c27fab0956b6d38f4e3e58b7..16728dffd19b17d5d3d7677b73f3945a82560b4d 100644 (file)
@@ -11,7 +11,7 @@
 fn foo() -> int { 22 }
 
 pub fn main() {
-    let mut x: ~[@fn() -> int] = ~[];
+    let mut x: ~[extern "Rust" fn() -> int] = ~[];
     x.push(foo);
     assert_eq!((x[0])(), 22);
 }
index aadd6a724940b25d2b834aa75978fd671f0f938d..64be8dab6e7021be8904b75de0e80a0b43da13ed 100644 (file)
 use std::ptr;
 
 pub fn main() {
-    let x = ~1;
-    let y = ptr::to_unsafe_ptr(&(*x)) as uint;
-    let lam_move: @fn() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
-    assert_eq!(lam_move(), y);
-
-    let x = ~2;
-    let y = ptr::to_unsafe_ptr(&(*x)) as uint;
-    let lam_move: @fn() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
-    assert_eq!(lam_move(), y);
-
     let x = ~3;
     let y = ptr::to_unsafe_ptr(&(*x)) as uint;
     let snd_move: ~fn() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
index 01c6442fa00b86263db84c875a1f38c538055c54..8b7967ac1501e5bfdf3ee73cd6ef846fb6c3e82a 100644 (file)
@@ -16,13 +16,30 @@ struct Pair<A,B> {
     a: A, b: B
 }
 
-fn f<A:Clone + 'static>(a: A, b: u16) -> @fn() -> (A, u16) {
-    let result: @fn() -> (A, u16) = || (a.clone(), b);
-    result
+struct Invoker<A> {
+    a: A,
+    b: u16,
+}
+
+trait Invokable<A> {
+    fn f(&self) -> (A, u16);
+}
+
+impl<A:Clone> Invokable<A> for Invoker<A> {
+    fn f(&self) -> (A, u16) {
+        (self.a.clone(), self.b)
+    }
+}
+
+fn f<A:Clone + 'static>(a: A, b: u16) -> @Invokable<A> {
+    @Invoker {
+        a: a,
+        b: b,
+    } as @Invokable<A>
 }
 
 pub fn main() {
-    let (a, b) = f(22_u64, 44u16)();
+    let (a, b) = f(22_u64, 44u16).f();
     info!("a=%? b=%?", a, b);
     assert_eq!(a, 22u64);
     assert_eq!(b, 44u16);
index cd148417f4c673c988a3e7070e35d80146ed814a..46c0c52e0c7187831d9aa91edf52c4981b5c1e18 100644 (file)
@@ -8,13 +8,33 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct foo { z: @fn() }
+struct foo {
+    z: Option<@Invokable>,
+}
+
+struct Thing {
+    w: @mut foo,
+}
+
+trait Invokable {
+    fn f(&self);
+}
+
+impl Invokable for Thing {
+    fn f(&self) {
+        nop_foo(self.w);
+    }
+}
 
 fn nop() { }
 fn nop_foo(_x : @mut foo) { }
 
 pub fn main() {
-    let w = @mut foo{ z: || nop() };
-    let x: @fn() = || nop_foo(w);
-    w.z = x;
+    let w = @mut foo {
+        z: None,
+    };
+    let x = @Thing {
+        w: w,
+    } as @Invokable;
+    w.z = Some(x);
 }
diff --git a/src/test/run-pass/cycle-collection4.rs b/src/test/run-pass/cycle-collection4.rs
deleted file mode 100644 (file)
index 8b61309..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-struct foo { z : @fn() }
-
-fn nop() { }
-fn nop_foo(_y: ~[int], _x : @mut foo) { }
-
-pub fn main() {
-    let w = @mut foo{ z: || nop() };
-    let x : @fn() = || nop_foo(~[], w);
-    w.z = x;
-}
diff --git a/src/test/run-pass/cycle-collection5.rs b/src/test/run-pass/cycle-collection5.rs
deleted file mode 100644 (file)
index f724a86..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-struct foo { z: @fn() }
-
-fn nop() { }
-fn nop_foo(_y: @int, _x: @mut foo) { }
-
-fn o() -> @int { @10 }
-
-pub fn main() {
-    let w = @mut foo { z: || nop() };
-    let x : @fn() = || nop_foo(o(), w);
-    w.z = x;
-}
index 6aef1f5f9e567b9d984c9303cb536756f08f7834..1f725ffb3576a3858e424767642b6077771b246b 100644 (file)
@@ -10,9 +10,9 @@
 
 // Testing that we can drop the || in do exprs
 
-fn f(_f: @fn() -> bool) -> bool { true }
+fn f(_f: &fn() -> bool) -> bool { true }
 
-fn d(_f: @fn()) { }
+fn d(_f: &fn()) { }
 
 pub fn main() {
     do d { }
index 735621a19fe7599d2a2e7ca50797e5ae65942620..0444b269cb34f2225cca898ef585c98eea6abc8f 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn f(f: @fn(int)) { f(10) }
+fn f(f: &fn(int)) { f(10) }
 
 pub fn main() {
     do f() |i| { assert!(i == 10) }
index 684a2c108eb81f6d9c75a19f9f52f89fb960569a..9feededc9800b68587a00323526e19e988f692a7 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn f(f: @fn(int) -> int) -> int { f(10) }
+fn f(f: &fn(int) -> int) -> int { f(10) }
 
 pub fn main() {
     assert_eq!(do f() |i| { i }, 10);
index b0d49fd2bdd924e006ba573253a81c1c5154c6a9..eeb983b455792826b08a748cc17ef504e3eae27c 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn f(f: @fn(int) -> int) -> int { f(10) }
+fn f(f: &fn(int) -> int) -> int { f(10) }
 
 pub fn main() {
     assert_eq!(do f |i| { i }, 10);
index dbb1ac1f649895ac415d9285fafd09a0a5679b0f..63e5c7688d345a38150a67c4753290ea546a1459 100644 (file)
@@ -11,7 +11,7 @@
 
 
 fn test_fn() {
-    type t = @fn() -> int;
+    type t = &'static fn() -> int;
     fn ten() -> int { return 10; }
     let rs: t = { ten };
     assert!((rs() == 10));
index 2c9021818105f3a0ed349c5b0a99790caa5540c3..12b387b7eae5e6a634c61635b66d8ae4ad5178a0 100644 (file)
@@ -12,7 +12,7 @@
 
 
 // -*- rust -*-
-type compare<T> = @fn(@T, @T) -> bool;
+type compare<T> = &'static fn(@T, @T) -> bool;
 
 fn test_generic<T>(expected: @T, eq: compare<T>) {
     let actual: @T = { expected };
index 7d849bbff01ce2a1a3f44e36bbec5a313b07179b..cfa59d68635de986173715c850d726784bd63fc2 100644 (file)
@@ -11,7 +11,7 @@
 
 // xfail-fast
 
-type compare<T> = @fn(T, T) -> bool;
+type compare<'self, T> = &'self fn(T, T) -> bool;
 
 fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
     let actual: T = { expected.clone() };
index 0249820410c435fc642e536dadd2ef5c624c881e..3f9c101761f8d211003d7790efa2123c042e803b 100644 (file)
@@ -11,7 +11,7 @@
 
 
 // -*- rust -*-
-type compare<T> = @fn(~T, ~T) -> bool;
+type compare<'self, T> = &'self fn(~T, ~T) -> bool;
 
 fn test_generic<T:Clone>(expected: ~T, eq: compare<T>) {
     let actual: ~T = { expected.clone() };
index 389a42ae7af71148b20ad9d619c5459be11aad0c..3484a4f7f5a1c307c24028e0c129f3e436fceae8 100644 (file)
@@ -11,7 +11,7 @@
 // xfail-fast
 // -*- rust -*-
 
-type compare<T> = @fn(T, T) -> bool;
+type compare<'self, T> = &'self fn(T, T) -> bool;
 
 fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
     let actual: T = { expected.clone() };
index 7091fceb7715ea72973eebf65046b05697563b78..2f379602c6bd1cb54ab7ef9e3fd3bf62b6127abb 100644 (file)
@@ -13,7 +13,7 @@
 // xfail-fast
 
 // Tests for standalone blocks as expressions with dynamic type sizes
-type compare<T> = @fn(T, T) -> bool;
+type compare<'self, T> = &'self fn(T, T) -> bool;
 
 fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
     let actual: T = { expected.clone() };
index def991adea8750cf92b4994e387081307491e575..8bf6e658408cb8b1b9770e015c313340f7b630f5 100644 (file)
@@ -12,7 +12,7 @@
 
 
 // -*- rust -*-
-type compare<T> = @fn(@T, @T) -> bool;
+type compare<T> = &'static fn(@T, @T) -> bool;
 
 fn test_generic<T>(expected: @T, not_expected: @T, eq: compare<T>) {
     let actual: @T = if true { expected } else { not_expected };
index a2d28a2be041c31bc8f1f88f9fadddc231d3fb15..2c4707a87d5c5369fcfa974896c2caa7c7a02836 100644 (file)
@@ -11,7 +11,7 @@
 // xfail-fast
 // -*- rust -*-
 
-type compare<T> = @fn(T, T) -> bool;
+type compare<T> = &'static fn(T, T) -> bool;
 
 fn test_generic<T:Clone>(expected: T, not_expected: T, eq: compare<T>) {
     let actual: T = if true { expected.clone() } else { not_expected };
index f5b2a1a79869b058d1812afd605a364949e8a9e7..1bbf3a537db282083366ff501e53becde2b8f834 100644 (file)
@@ -12,7 +12,7 @@
 // -*- rust -*-
 
 // Tests for if as expressions with dynamic type sizes
-type compare<T> = @fn(T, T) -> bool;
+type compare<T> = &'static fn(T, T) -> bool;
 
 fn test_generic<T:Clone>(expected: T, not_expected: T, eq: compare<T>) {
     let actual: T = if true { expected.clone() } else { not_expected };
index 4ea2d0fba9b2fe19451f89818cba4b45953d40ff..064e33436205047e61e289bfae458ad686fc2b40 100644 (file)
@@ -12,7 +12,7 @@
 
 
 // -*- rust -*-
-type compare<T> = @fn(@T, @T) -> bool;
+type compare<T> = &'static fn(@T, @T) -> bool;
 
 fn test_generic<T>(expected: @T, eq: compare<T>) {
     let actual: @T = match true { true => { expected }, _ => fail!() };
index a2ccf5c0fb906452e33b0cd42fbd01a9c6718904..bca06ebdbb5f3405f5757b836d0badffad7bfba4 100644 (file)
@@ -11,7 +11,7 @@
 // xfail-fast
 // -*- rust -*-
 
-type compare<T> = @fn(T, T) -> bool;
+type compare<T> = &'static fn(T, T) -> bool;
 
 fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
     let actual: T = match true { true => { expected.clone() }, _ => fail!("wat") };
index 0f564e6a78029a51cdc18f9b0b0e25897ce0a394..7371f8fd89b9ce28c193edbc0cb9ad7e2c4c8d05 100644 (file)
@@ -11,7 +11,7 @@
 
 
 // -*- rust -*-
-type compare<T> = @fn(~T, ~T) -> bool;
+type compare<T> = &'static fn(~T, ~T) -> bool;
 
 fn test_generic<T:Clone>(expected: ~T, eq: compare<T>) {
     let actual: ~T = match true {
index ae88d48bc443b606a038b2932e905d913311bfa6..d07d40e675766c2ddae974844d25a8a507adb62e 100644 (file)
@@ -11,7 +11,7 @@
 // xfail-fast
 // -*- rust -*-
 
-type compare<T> = @fn(T, T) -> bool;
+type compare<'self, T> = &'self fn(T, T) -> bool;
 
 fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
     let actual: T = match true {
index 59f1ff14f5902047f8f4cd691460f0aceae9fa26..b43085d346f30416b2e89a06c56c904afd2ae165 100644 (file)
@@ -11,7 +11,7 @@
 // xfail-fast
 // -*- rust -*-
 
-type compare<T> = @fn(T, T) -> bool;
+type compare<T> = extern "Rust" fn(T, T) -> bool;
 
 fn test_generic<T:Clone>(expected: T, eq: compare<T>) {
   let actual: T = match true { true => { expected.clone() }, _ => fail!("wat") };
diff --git a/src/test/run-pass/fixed-point-bind-box.rs b/src/test/run-pass/fixed-point-bind-box.rs
deleted file mode 100644 (file)
index 4c28151..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// xfail-fast
-
-fn fix_help<A, B>(f: extern fn(@fn(A) -> B, A) -> B, x: A) -> B {
-    return f( |a| fix_help(f, a), x);
-}
-
-fn fix<A, B>(f: extern fn(@fn(A) -> B, A) -> B) -> @fn(A) -> B {
-    return |a| fix_help(f, a);
-}
-
-fn fact_(f: @fn(v: int) -> int, n: int) -> int {
-    // fun fact 0 = 1
-    return if n == 0 { 1 } else { n * f(n - 1) };
-}
-
-pub fn main() {
-    let fact = fix(fact_);
-    assert_eq!(fact(5), 120);
-    assert_eq!(fact(2), 2);
-}
diff --git a/src/test/run-pass/fixed-point-bind-unique.rs b/src/test/run-pass/fixed-point-bind-unique.rs
deleted file mode 100644 (file)
index c7b64fd..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// xfail-fast
-
-fn fix_help<A:'static,B:Send>(f: extern fn(@fn(A) -> B, A) -> B, x: A) -> B {
-    return f(|a| fix_help(f, a), x);
-}
-
-fn fix<A:'static,B:Send>(f: extern fn(@fn(A) -> B, A) -> B) -> @fn(A) -> B {
-    return |a| fix_help(f, a);
-}
-
-fn fact_(f: @fn(v: int) -> int, n: int) -> int {
-    // fun fact 0 = 1
-    return if n == 0 { 1 } else { n * f(n - 1) };
-}
-
-pub fn main() {
-    let fact = fix(fact_);
-    assert_eq!(fact(5), 120);
-    assert_eq!(fact(2), 2);
-}
diff --git a/src/test/run-pass/fn-assign-managed-to-bare-1.rs b/src/test/run-pass/fn-assign-managed-to-bare-1.rs
deleted file mode 100644 (file)
index dece775..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn add(n: int) -> @fn(int) -> int {
-    let result: @fn(int) -> int = |m| m + n;
-    result
-}
-
-pub fn main() {
-      assert_eq!(add(3)(4), 7);
-      let add3 : &fn(int)->int = add(3);
-      assert_eq!(add3(4), 7);
-}
diff --git a/src/test/run-pass/fn-assign-managed-to-bare-2.rs b/src/test/run-pass/fn-assign-managed-to-bare-2.rs
deleted file mode 100644 (file)
index f8daacf..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn add(n: int) -> @fn(int) -> int {
-    let result: @fn(int) -> int = |m| m + n;
-    result
-}
-
-pub fn main()
-{
-    assert_eq!(add(3)(4), 7);
-
-    let add1 : @fn(int)->int = add(1);
-    assert_eq!(add1(6), 7);
-
-    let add2 : &(@fn(int)->int) = &add(2);
-    assert_eq!((*add2)(5), 7);
-
-    let add3 : &fn(int)->int = add(3);
-    assert_eq!(add3(4), 7);
-}
diff --git a/src/test/run-pass/fn-bare-coerce-to-shared.rs b/src/test/run-pass/fn-bare-coerce-to-shared.rs
deleted file mode 100644 (file)
index 853b44e..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn bare() {}
-
-fn likes_shared(f: @fn()) { f() }
-
-pub fn main() {
-    likes_shared(bare);
-}
index 22aab1aa661911dde5774d18964afea037d19c23..ae2e353f913ba5631ece94819717d0c14250a9a1 100644 (file)
@@ -8,8 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct r {
-    field: @fn()
+struct r<'self> {
+    field: &'self fn()
 }
 
 pub fn main() {
index bb9254589f7b3f935f92673713e21d1a024f7cf9..09e7ababa6cb6d6acff9075392e24796345f6130 100644 (file)
@@ -11,7 +11,7 @@
 #[allow(unused_variable)];
 
 pub fn main() {
-    // We should be able to type infer inside of @fns.
+    // We should be able to type infer inside of &fns.
     let _f = || {
         let i = 10;
     };
index 52e6a4649a8dc54cc655e7b03d5751aaea5102ef..5011998f92949beb460cd00a4f30c1350804c788 100644 (file)
@@ -9,7 +9,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn ho(f: @fn(int) -> int) -> int { let n: int = f(3); return n; }
+fn ho(f: &fn(int) -> int) -> int { let n: int = f(3); return n; }
 
 fn direct(x: int) -> int { return x + 1; }
 
index 7cd26dd84c4abb25edfeef0d07b5fb611136261e..15286a85c01b270746b85c50bc02ff328744cdf6 100644 (file)
@@ -24,7 +24,7 @@ mod map_reduce {
     use std::str;
     use std::task;
 
-    pub type putter = @fn(~str, ~str);
+    pub type putter<'self> = &'self fn(~str, ~str);
 
     pub type mapper = extern fn(~str, putter);
 
diff --git a/src/test/run-pass/infer-with-expected.rs b/src/test/run-pass/infer-with-expected.rs
deleted file mode 100644 (file)
index 6f2fd54..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Tests the passing down of expected types through boxing and
-// wrapping in a record or tuple. (The a.x would complain about 'this
-// type must be known in this context' if the passing down doesn't
-// happen.)
-
-fn eat_tup(_r: ~@(int, @fn(Pair) -> int)) {}
-fn eat_rec(_r: ~Rec) {}
-
-struct Rec<'self> { a: int, b: &'self fn(Pair) -> int }
-struct Pair { x: int, y: int }
-
-pub fn main() {
-    eat_tup(~@(10, |a| a.x ));
-    eat_rec(~Rec{a: 10, b: |a| a.x });
-}
index 2767ac6d69fb3b654ef59e94b98e9e8bdb01fb43..4b73d83595e64c6c2ac33d71c8c46b8e75c0360f 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 pub fn main() {
-    let early_error: @fn(&str) -> !  = |_msg| { fail!() };
+    let early_error: &'static fn(&str) -> !  = |_msg| { fail!() };
 }
index c84386c722da745774a4a2a999bac04f20a5fe2b..a1ea1b9080954d03560f92487abc63425973fe13 100644 (file)
 //
 // Running /usr/local/bin/rustc:
 // issue-2185.rs:24:0: 26:1 error: conflicting implementations for a trait
-// issue-2185.rs:24 impl iterable<uint> for @fn(&fn(uint)) {
+// issue-2185.rs:24 impl iterable<uint> for &'static fn(&fn(uint)) {
 // issue-2185.rs:25     fn iter(&self, blk: &fn(v: uint)) { self( |i| blk(i) ) }
 // issue-2185.rs:26 }
 // issue-2185.rs:20:0: 22:1 note: note conflicting implementation here
-// issue-2185.rs:20 impl<A> iterable<A> for @fn(&fn(A)) {
+// issue-2185.rs:20 impl<A> iterable<A> for &'static fn(&fn(A)) {
 // issue-2185.rs:21     fn iter(&self, blk: &fn(A)) { self(blk); }
 // issue-2185.rs:22 }
 //
@@ -42,15 +42,17 @@ trait iterable<A> {
     fn iter(&self, blk: &fn(A));
 }
 
-impl<A> iterable<A> for @fn(&fn(A)) {
+impl<A> iterable<A> for &'static fn(&fn(A)) {
     fn iter(&self, blk: &fn(A)) { self(blk); }
 }
 
-impl iterable<uint> for @fn(&fn(uint)) {
+impl iterable<uint> for &'static fn(&fn(uint)) {
     fn iter(&self, blk: &fn(v: uint)) { self( |i| blk(i) ) }
 }
 
-fn filter<A,IA:iterable<A>>(self: IA, prd: @fn(A) -> bool, blk: &fn(A)) {
+fn filter<A,IA:iterable<A>>(self: IA,
+                            prd: &'static fn(A) -> bool,
+                            blk: &fn(A)) {
     do self.iter |a| {
         if prd(a) { blk(a) }
     }
@@ -73,8 +75,8 @@ fn range(lo: uint, hi: uint, it: &fn(uint)) {
 }
 
 pub fn main() {
-    let range: @fn(&fn(uint)) = |a| range(0u, 1000u, a);
-    let filt: @fn(&fn(v: uint)) = |a| filter(
+    let range: &'static fn(&fn(uint)) = |a| range(0u, 1000u, a);
+    let filt: &'static fn(&fn(v: uint)) = |a| filter(
         range,
         |&&n: uint| n % 3u != 0u && n % 5u != 0u,
         a);
index e7da12861378b91267cd0edd2bd2e255504a8c36..bde18d77b9add6edf023e34e56a14b11f636ff50 100644 (file)
@@ -9,12 +9,16 @@
 // except according to those terms.
 
 struct cat {
-    meow: @fn(),
+    meow: extern "Rust" fn(),
+}
+
+fn meow() {
+    error!("meow")
 }
 
 fn cat() -> cat {
     cat {
-        meow: || error!("meow")
+        meow: meow,
     }
 }
 
index 852c6d995c60e587cba32e7158d4a5668f34606e..cb1ffc389089808ca828cb83c859c636b5813363 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-type Connection = @fn(~[u8]);
+type Connection = &'static fn(~[u8]);
 
 fn f() -> Option<Connection> {
     let mock_connection: Connection = |_| {};
index abea01cefd339e78b2d6cdba1e1b8707983e6ec4..fc493485b794e752751e9de07c5dc4ce781203dd 100644 (file)
@@ -10,6 +10,6 @@
 
 pub fn main() {
   let x = 1;
-  let y: @fn() -> int = || x;
+  let y: &fn() -> int = || x;
   let _z = y();
 }
diff --git a/src/test/run-pass/issue-4929.rs b/src/test/run-pass/issue-4929.rs
deleted file mode 100644 (file)
index 5803c3d..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-fn make_adder(x: int) -> @fn(int) -> int { |y| x + y }
-pub fn main() { }
diff --git a/src/test/run-pass/issue-5783.rs b/src/test/run-pass/issue-5783.rs
deleted file mode 100644 (file)
index 7f988dc..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Issue #5783
-// Nondeterministic behavior when referencing a closure more than once
-
-fn main() {
-    let a: &fn(int) -> @fn(int) -> int = |x:int| |y:int| -> int x + y;
-    let b = a(2);
-    assert!(a(2)(3) == 5);
-    assert!(b(6) == 8);
-}
diff --git a/src/test/run-pass/issue4516_ty_param.rs b/src/test/run-pass/issue4516_ty_param.rs
deleted file mode 100644 (file)
index 35df47d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// xfail-fast - check-fast doesn't understand aux-build
-// aux-build:issue4516_ty_param_lib.rs
-
-// Trigger a bug concerning inlining of generic functions.
-// The def-ids in type parameters were not being correctly
-// resolved and hence when we checked the type of the closure
-// variable (see the library mod) to determine if the value
-// should be moved into the closure, trans failed to find
-// the relevant kind bounds.
-
-extern mod issue4516_ty_param_lib;
-use issue4516_ty_param_lib::to_closure;
-pub fn main() {
-    to_closure(22)();
-}
index 9eecc788a69c1660a10e015d27311853e8fb4f46..d55150e448e81a12d137a7172d8ee79711ce6168 100644 (file)
@@ -9,13 +9,13 @@
 // except according to those terms.
 
 // This should typecheck even though the type of e is not fully
-// resolved when we finish typechecking the @fn.
+// resolved when we finish typechecking the &fn.
 
 
 struct Refs { refs: ~[int], n: int }
 
 pub fn main() {
     let e = @mut Refs{refs: ~[], n: 0};
-    let _f: @fn() = || error!(e.n);
+    let _f: &fn() = || error!(e.n);
     e.refs.push(1);
 }
diff --git a/src/test/run-pass/lambda-no-leak.rs b/src/test/run-pass/lambda-no-leak.rs
deleted file mode 100644 (file)
index e195032..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Make sure we don't leak @fns in silly ways.
-fn force(f: @fn()) { f() }
-pub fn main() {
-    let x = 7;
-    let _f: @fn() = || error!(x);
-    force(|| error!(x));
-}
index 75c3008af8eb39f9eb6b3599f098a9f7c9db0208..d014a3cf1a15cf4d1b4ed4e4aa8feaa86d903b89 100644 (file)
 
 struct A { a: ~int }
 
-fn foo() -> @fn() -> int {
+fn foo() -> &'static fn() -> int {
     let k = ~22;
     let _u = A {a: k.clone()};
-    let result: @fn() -> int = || 22;
+    let result: &'static fn() -> int = || 22;
     result
 }
 
index 2c62b6894d0df425be2dbb62a1131f5820f860b5..079d2374a29ffe75f98df5aaa3c59452e8ee233c 100644 (file)
@@ -13,7 +13,7 @@
 struct A { a: ~int }
 
 pub fn main() {
-    fn invoke(f: @fn()) { f(); }
+    fn invoke(f: &fn()) { f(); }
     let k = ~22;
     let _u = A {a: k.clone()};
     invoke(|| error!(k.clone()) )
diff --git a/src/test/run-pass/monomorphize-trait-in-fn-at.rs b/src/test/run-pass/monomorphize-trait-in-fn-at.rs
deleted file mode 100644 (file)
index 8e36b11..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// test that invoking functions which require
-// dictionaries from inside an @fn works
-// (at one point, it didn't)
-
-fn mk_nil<C:ty_ops>(cx: C) -> uint {
-    cx.mk()
-}
-
-trait ty_ops {
-    fn mk(&self) -> uint;
-}
-
-impl ty_ops for () {
-    fn mk(&self) -> uint { 22u }
-}
-
-pub fn main() {
-    let fn_env: @fn() -> uint = || mk_nil(());
-    assert_eq!(fn_env(), 22u);
-}
index 464d915b2c43c60360b75474df7b9ea7e5b4cd03..87281c2fd225314787432a573e661d0ae0348f36 100644 (file)
@@ -9,9 +9,9 @@
 // except according to those terms.
 
 // Issue #922
-fn f2(_thing: @fn()) { }
+fn f2(_thing: &fn()) { }
 
-fn f(thing: @fn()) {
+fn f(thing: &fn()) {
     f2(thing);
 }
 
index 10ac45922aa6cbd7b150f42f0d45151e5c6e567a..6d6757890ad3e6e0d8af6dc9c2399b4626e840e0 100644 (file)
@@ -11,8 +11,6 @@
 // Test that the lambda kind is inferred correctly as a return
 // expression
 
-fn shared() -> @fn() { return || (); }
-
 fn unique() -> ~fn() { return || (); }
 
 pub fn main() {
index 4dfe3575eb5915f995bc87714b80597f43adca2e..17ff8ce94d90ff1841bbe694186bd97bca788528 100644 (file)
@@ -11,8 +11,6 @@
 // Test that the lambda kind is inferred correctly as a return
 // expression
 
-fn shared() -> @fn() { || () }
-
 fn unique() -> ~fn() { || () }
 
 pub fn main() {
index 9c2a223174ca1bc1edf59937919ee2f0034993cd..d9d0daa7138cdf76873eb74e76549097d5420b4e 100644 (file)
@@ -14,16 +14,9 @@ fn f(i: int, f: &fn(int) -> int) -> int { f(i) }
 
 fn g(_g: &fn()) { }
 
-fn ff() -> @fn(int) -> int {
-    return |x| x + 1;
-}
-
 pub fn main() {
     assert_eq!(f(10, |a| a), 10);
     g(||());
     assert_eq!(do f(10) |a| { a }, 10);
     do g() { }
-    let _x: @fn() -> int = || 10;
-    let _y: @fn(int) -> int = |a| a;
-    assert_eq!(ff()(10), 11);
 }
diff --git a/src/test/run-pass/propagate-expected-type-through-block.rs b/src/test/run-pass/propagate-expected-type-through-block.rs
deleted file mode 100644 (file)
index f8f824c..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Test that expected type propagates through `{}` expressions.  If it
-// did not, then the type of `x` would not be known and a compilation
-// error would result.
-
-pub fn main() {
-    let y = ~3;
-    let foo: @fn(&int) -> int = {
-        let y = y.clone();
-        |x| *x + *y
-    };
-    assert_eq!(foo(@22), 25);
-}
index 2d9f4a2ff6f6d9192ca0e756acfe018fb3a0156a..cf6f12a06e5f803dfe518644402bc237d46cf822 100644 (file)
@@ -460,9 +460,9 @@ fn visit_opaque_box(&mut self) -> bool {
     }
 
     fn visit_closure_ptr(&mut self, ck: uint) -> bool {
-        self.align_to::<@fn()>();
+        self.align_to::<(uint,uint)>();
         if ! self.inner.visit_closure_ptr(ck) { return false; }
-        self.bump_past::<@fn()>();
+        self.bump_past::<(uint,uint)>();
         true
     }
 }
index a6b43df1f88a7a6e33f138d44ab4184b50369515..06c8aca4741645da3756fb932d864bc51d94732f 100644 (file)
 #[allow(unused_variable)];
 
 // Should pass region checking.
-fn ok(f: @fn(x: &uint)) {
+fn ok(f: &fn(x: &uint)) {
     // Here, g is a function that can accept a uint pointer with
     // lifetime r, and f is a function that can accept a uint pointer
     // with any lifetime.  The assignment g = f should be OK (i.e.,
     // f's type should be a subtype of g's type), because f can be
     // used in any context that expects g's type.  But this currently
     // fails.
-    let mut g: @fn<'r>(y: &'r uint) = |x| { };
+    let mut g: &fn<'r>(y: &'r uint) = |x| { };
     g = f;
 }
 
 // This version is the same as above, except that here, g's type is
 // inferred.
-fn ok_inferred(f: @fn(x: &uint)) {
-    let mut g: @fn<'r>(x: &'r uint) = |_| {};
+fn ok_inferred(f: &fn(x: &uint)) {
+    let mut g: &fn<'r>(x: &'r uint) = |_| {};
     g = f;
 }
 
index dd70b7daa700516ea0d5217c592ef16b59fc8cbe..662121a09931fbc50658319a1f8701b9e99a9c1f 100644 (file)
@@ -10,6 +10,6 @@
 
 pub fn main() {
     let _x = ~1;
-    let lam_move: @fn() = || {};
+    let lam_move: &fn() = || {};
     lam_move();
 }