about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-09-11 16:26:06 -0700
committerPatrick Walton <pcwalton@mimiga.net>2013-09-23 18:23:21 -0700
commita170183ba39c32b9f85c50a379dc4f9b8bd6e0fa (patch)
tree8f8908f47d6dc597459da88e4708ea6aa7cd6ea1
parent68ea9aed96b6b8147b6c37b844c85cb7ae2867f4 (diff)
downloadrust-a170183ba39c32b9f85c50a379dc4f9b8bd6e0fa.tar.gz
rust-a170183ba39c32b9f85c50a379dc4f9b8bd6e0fa.zip
librusti: Eliminate `@fn`.
-rw-r--r--src/librusti/rusti.rs23
-rw-r--r--src/librusti/utils.rs8
2 files changed, 20 insertions, 11 deletions
diff --git a/src/librusti/rusti.rs b/src/librusti/rusti.rs
index 0d024812c21..462c0a29236 100644
--- a/src/librusti/rusti.rs
+++ b/src/librusti/rusti.rs
@@ -72,6 +72,7 @@ extern mod syntax;
 
 use std::{libc, io, os, task};
 use std::cell::Cell;
+use extra::rl::CompletionCb;
 use extra::rl;
 
 use rustc::driver::{driver, session};
@@ -520,6 +521,19 @@ pub fn main() {
     main_args(args);
 }
 
+struct Completer;
+
+impl CompletionCb for Completer {
+    fn complete(&self, line: ~str, suggest: &fn(~str)) {
+        if line.starts_with(":") {
+            suggest(~":clear");
+            suggest(~":exit");
+            suggest(~":help");
+            suggest(~":load");
+        }
+    }
+}
+
 pub fn main_args(args: &[~str]) {
     #[fixed_stack_segment]; #[inline(never)];
 
@@ -543,13 +557,8 @@ pub fn main_args(args: &[~str]) {
         println("unstable. If you encounter problems, please use the");
         println("compiler instead. Type :help for help.");
 
-        do rl::complete |line, suggest| {
-            if line.starts_with(":") {
-                suggest(~":clear");
-                suggest(~":exit");
-                suggest(~":help");
-                suggest(~":load");
-            }
+        unsafe {
+            rl::complete(@Completer as @CompletionCb)
         }
     }
 
diff --git a/src/librusti/utils.rs b/src/librusti/utils.rs
index 400399253a5..904594fdfb8 100644
--- a/src/librusti/utils.rs
+++ b/src/librusti/utils.rs
@@ -15,11 +15,11 @@ use syntax::print::pprust;
 use syntax::parse::token;
 use syntax::visit;
 
-struct EachBindingVisitor {
-    f: @fn(&ast::Path, ast::NodeId)
+struct EachBindingVisitor<'self> {
+    f: &'self fn(&ast::Path, ast::NodeId)
 }
 
-impl visit::Visitor<()> for EachBindingVisitor {
+impl<'self> visit::Visitor<()> for EachBindingVisitor<'self> {
     fn visit_pat(&mut self, pat:@ast::Pat, _:()) {
                 match pat.node {
                     ast::PatIdent(_, ref path, _) => {
@@ -32,7 +32,7 @@ impl visit::Visitor<()> for EachBindingVisitor {
     }
 }
 
-pub fn each_binding(l: @ast::Local, f: @fn(&ast::Path, ast::NodeId)) {
+pub fn each_binding(l: @ast::Local, f: &fn(&ast::Path, ast::NodeId)) {
     use syntax::visit::Visitor;
 
     let mut vt = EachBindingVisitor{ f: f };