File tree Expand file tree Collapse file tree 2 files changed +20
-11
lines changed Expand file tree Collapse file tree 2 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ extern mod syntax;
7272
7373use std:: { libc, io, os, task} ;
7474use std:: cell:: Cell ;
75+ use extra:: rl:: CompletionCb ;
7576use extra:: rl;
7677
7778use rustc:: driver:: { driver, session} ;
@@ -520,6 +521,19 @@ pub fn main() {
520521 main_args ( args) ;
521522}
522523
524+ struct Completer ;
525+
526+ impl CompletionCb for Completer {
527+ fn complete ( & self , line : ~str , suggest : & fn ( ~str ) ) {
528+ if line. starts_with ( ":" ) {
529+ suggest ( ~": clear") ;
530+ suggest ( ~": exit") ;
531+ suggest ( ~": help") ;
532+ suggest ( ~": load") ;
533+ }
534+ }
535+ }
536+
523537pub fn main_args ( args : & [ ~str ] ) {
524538 #[ fixed_stack_segment] ; #[ inline( never) ] ;
525539
@@ -543,13 +557,8 @@ pub fn main_args(args: &[~str]) {
543557 println( "unstable. If you encounter problems, please use the" ) ;
544558 println ( "compiler instead. Type :help for help." ) ;
545559
546- do rl:: complete |line, suggest| {
547- if line. starts_with ( ":" ) {
548- suggest ( ~": clear") ;
549- suggest ( ~": exit") ;
550- suggest ( ~": help") ;
551- suggest ( ~": load") ;
552- }
560+ unsafe {
561+ rl:: complete ( @Completer as @CompletionCb )
553562 }
554563 }
555564
Original file line number Diff line number Diff line change @@ -15,11 +15,11 @@ use syntax::print::pprust;
1515use syntax:: parse:: token;
1616use syntax:: visit;
1717
18- struct EachBindingVisitor {
19- f : @ fn ( & ast:: Path , ast:: NodeId )
18+ struct EachBindingVisitor < ' self > {
19+ f : & ' self fn ( & ast:: Path , ast:: NodeId )
2020}
2121
22- impl visit:: Visitor < ( ) > for EachBindingVisitor {
22+ impl < ' self > visit:: Visitor < ( ) > for EachBindingVisitor < ' self > {
2323 fn visit_pat ( & mut self , pat : @ast:: Pat , _: ( ) ) {
2424 match pat. node {
2525 ast:: PatIdent ( _, ref path, _) => {
@@ -32,7 +32,7 @@ impl visit::Visitor<()> for EachBindingVisitor {
3232 }
3333}
3434
35- pub fn each_binding ( l : @ast:: Local , f : @ fn ( & ast:: Path , ast:: NodeId ) ) {
35+ pub fn each_binding ( l : @ast:: Local , f : & fn ( & ast:: Path , ast:: NodeId ) ) {
3636 use syntax:: visit:: Visitor ;
3737
3838 let mut vt = EachBindingVisitor { f : f } ;
You can’t perform that action at this time.
0 commit comments