@@ -32,6 +32,8 @@ use syntax::visit;
32
32
use syntax:: visit:: Visitor ;
33
33
34
34
use std:: hashmap:: HashMap ;
35
+ use std:: iter:: Enumerate ;
36
+ use std:: vec;
35
37
36
38
pub enum LangItem {
37
39
FreezeTraitLangItem , // 0
@@ -92,8 +94,8 @@ impl LanguageItems {
92
94
}
93
95
}
94
96
95
- pub fn each_item ( & self , f : & fn ( Option < DefId > , uint ) -> bool ) -> bool {
96
- self . items . iter ( ) . enumerate ( ) . advance ( | ( i , & item ) | f ( item , i ) )
97
+ pub fn items < ' a > ( & ' a self ) -> Enumerate < vec :: VecIterator < ' a , Option < DefId > > > {
98
+ self . items . iter ( ) . enumerate ( )
97
99
}
98
100
99
101
pub fn item_name ( index : uint ) -> & ' static str {
@@ -298,7 +300,7 @@ struct LanguageItemCollector<'self> {
298
300
crate : & ' self Crate ,
299
301
session : Session ,
300
302
301
- item_refs : HashMap < @ str , uint > ,
303
+ item_refs : HashMap < & ' static str , uint > ,
302
304
}
303
305
304
306
struct LanguageItemVisitor < ' self > {
@@ -327,51 +329,51 @@ impl<'self> LanguageItemCollector<'self> {
327
329
-> LanguageItemCollector < ' a > {
328
330
let mut item_refs = HashMap :: new ( ) ;
329
331
330
- item_refs. insert ( @ "freeze", FreezeTraitLangItem as uint ) ;
331
- item_refs. insert ( @ "send", SendTraitLangItem as uint ) ;
332
- item_refs. insert ( @ "sized", SizedTraitLangItem as uint ) ;
333
-
334
- item_refs. insert ( @ "drop", DropTraitLangItem as uint ) ;
335
-
336
- item_refs. insert ( @ "add", AddTraitLangItem as uint ) ;
337
- item_refs. insert ( @ "sub", SubTraitLangItem as uint ) ;
338
- item_refs. insert ( @ "mul", MulTraitLangItem as uint ) ;
339
- item_refs. insert ( @ "div", DivTraitLangItem as uint ) ;
340
- item_refs. insert ( @ "rem", RemTraitLangItem as uint ) ;
341
- item_refs. insert ( @ "neg", NegTraitLangItem as uint ) ;
342
- item_refs. insert ( @ "not", NotTraitLangItem as uint ) ;
343
- item_refs. insert ( @ "bitxor", BitXorTraitLangItem as uint ) ;
344
- item_refs. insert ( @ "bitand", BitAndTraitLangItem as uint ) ;
345
- item_refs. insert ( @ "bitor", BitOrTraitLangItem as uint ) ;
346
- item_refs. insert ( @ "shl", ShlTraitLangItem as uint ) ;
347
- item_refs. insert ( @ "shr", ShrTraitLangItem as uint ) ;
348
- item_refs. insert ( @ "index", IndexTraitLangItem as uint ) ;
349
-
350
- item_refs. insert ( @ "eq", EqTraitLangItem as uint ) ;
351
- item_refs. insert ( @ "ord", OrdTraitLangItem as uint ) ;
352
-
353
- item_refs. insert ( @ "str_eq", StrEqFnLangItem as uint ) ;
354
- item_refs. insert ( @ "uniq_str_eq", UniqStrEqFnLangItem as uint ) ;
355
- item_refs. insert ( @ "fail_", FailFnLangItem as uint ) ;
356
- item_refs. insert ( @ "fail_bounds_check",
332
+ item_refs. insert ( "freeze" , FreezeTraitLangItem as uint ) ;
333
+ item_refs. insert ( "send" , SendTraitLangItem as uint ) ;
334
+ item_refs. insert ( "sized" , SizedTraitLangItem as uint ) ;
335
+
336
+ item_refs. insert ( "drop" , DropTraitLangItem as uint ) ;
337
+
338
+ item_refs. insert ( "add" , AddTraitLangItem as uint ) ;
339
+ item_refs. insert ( "sub" , SubTraitLangItem as uint ) ;
340
+ item_refs. insert ( "mul" , MulTraitLangItem as uint ) ;
341
+ item_refs. insert ( "div" , DivTraitLangItem as uint ) ;
342
+ item_refs. insert ( "rem" , RemTraitLangItem as uint ) ;
343
+ item_refs. insert ( "neg" , NegTraitLangItem as uint ) ;
344
+ item_refs. insert ( "not" , NotTraitLangItem as uint ) ;
345
+ item_refs. insert ( "bitxor" , BitXorTraitLangItem as uint ) ;
346
+ item_refs. insert ( "bitand" , BitAndTraitLangItem as uint ) ;
347
+ item_refs. insert ( "bitor" , BitOrTraitLangItem as uint ) ;
348
+ item_refs. insert ( "shl" , ShlTraitLangItem as uint ) ;
349
+ item_refs. insert ( "shr" , ShrTraitLangItem as uint ) ;
350
+ item_refs. insert ( "index" , IndexTraitLangItem as uint ) ;
351
+
352
+ item_refs. insert ( "eq" , EqTraitLangItem as uint ) ;
353
+ item_refs. insert ( "ord" , OrdTraitLangItem as uint ) ;
354
+
355
+ item_refs. insert ( "str_eq" , StrEqFnLangItem as uint ) ;
356
+ item_refs. insert ( "uniq_str_eq" , UniqStrEqFnLangItem as uint ) ;
357
+ item_refs. insert ( "fail_" , FailFnLangItem as uint ) ;
358
+ item_refs. insert ( "fail_bounds_check" ,
357
359
FailBoundsCheckFnLangItem as uint ) ;
358
- item_refs. insert ( @ "exchange_malloc", ExchangeMallocFnLangItem as uint ) ;
359
- item_refs. insert ( @ "closure_exchange_malloc", ClosureExchangeMallocFnLangItem as uint ) ;
360
- item_refs. insert ( @ "exchange_free", ExchangeFreeFnLangItem as uint ) ;
361
- item_refs. insert ( @ "malloc", MallocFnLangItem as uint ) ;
362
- item_refs. insert ( @ "free", FreeFnLangItem as uint ) ;
363
- item_refs. insert ( @ "borrow_as_imm", BorrowAsImmFnLangItem as uint ) ;
364
- item_refs. insert ( @ "borrow_as_mut", BorrowAsMutFnLangItem as uint ) ;
365
- item_refs. insert ( @ "return_to_mut", ReturnToMutFnLangItem as uint ) ;
366
- item_refs. insert ( @ "check_not_borrowed",
360
+ item_refs. insert ( "exchange_malloc" , ExchangeMallocFnLangItem as uint ) ;
361
+ item_refs. insert ( "closure_exchange_malloc" , ClosureExchangeMallocFnLangItem as uint ) ;
362
+ item_refs. insert ( "exchange_free" , ExchangeFreeFnLangItem as uint ) ;
363
+ item_refs. insert ( "malloc" , MallocFnLangItem as uint ) ;
364
+ item_refs. insert ( "free" , FreeFnLangItem as uint ) ;
365
+ item_refs. insert ( "borrow_as_imm" , BorrowAsImmFnLangItem as uint ) ;
366
+ item_refs. insert ( "borrow_as_mut" , BorrowAsMutFnLangItem as uint ) ;
367
+ item_refs. insert ( "return_to_mut" , ReturnToMutFnLangItem as uint ) ;
368
+ item_refs. insert ( "check_not_borrowed" ,
367
369
CheckNotBorrowedFnLangItem as uint ) ;
368
- item_refs. insert ( @ "strdup_uniq", StrDupUniqFnLangItem as uint ) ;
369
- item_refs. insert ( @ "record_borrow", RecordBorrowFnLangItem as uint ) ;
370
- item_refs. insert ( @ "unrecord_borrow", UnrecordBorrowFnLangItem as uint ) ;
371
- item_refs. insert ( @ "start", StartFnLangItem as uint ) ;
372
- item_refs. insert ( @ "ty_desc", TyDescStructLangItem as uint ) ;
373
- item_refs. insert ( @ "ty_visitor", TyVisitorTraitLangItem as uint ) ;
374
- item_refs. insert ( @ "opaque", OpaqueStructLangItem as uint ) ;
370
+ item_refs. insert ( "strdup_uniq" , StrDupUniqFnLangItem as uint ) ;
371
+ item_refs. insert ( "record_borrow" , RecordBorrowFnLangItem as uint ) ;
372
+ item_refs. insert ( "unrecord_borrow" , UnrecordBorrowFnLangItem as uint ) ;
373
+ item_refs. insert ( "start" , StartFnLangItem as uint ) ;
374
+ item_refs. insert ( "ty_desc" , TyDescStructLangItem as uint ) ;
375
+ item_refs. insert ( "ty_visitor" , TyVisitorTraitLangItem as uint ) ;
376
+ item_refs. insert ( "opaque" , OpaqueStructLangItem as uint ) ;
375
377
376
378
LanguageItemCollector {
377
379
crate: crate ,
@@ -416,8 +418,8 @@ impl<'self> LanguageItemCollector<'self> {
416
418
return ; // Didn't match.
417
419
}
418
420
419
- let item_index = self . item_refs . find ( & value) . map_move ( |x| * x) ;
420
- // prevent borrow checker from considering ^~~~~~~~~~~
421
+ let item_index = self . item_refs . find_equiv ( & value) . map_move ( |x| * x) ;
422
+ // prevent borrow checker from considering ^~~~~~~~~~~
421
423
// self to be borrowed (annoying)
422
424
423
425
match item_index {
0 commit comments