librusti: Eliminate @fn.

This commit is contained in:
Patrick Walton 2013-09-11 16:26:06 -07:00
parent 68ea9aed96
commit a170183ba3
2 changed files with 20 additions and 11 deletions

View File

@ -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)
}
}

View File

@ -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 };