@@ -18,7 +18,6 @@ use metadata::filesearch::FileSearch;
1818use metadata:: loader;
1919
2020use core:: hashmap:: HashMap ;
21- use core:: vec;
2221use syntax:: attr;
2322use syntax:: codemap:: { span, dummy_sp} ;
2423use syntax:: diagnostic:: span_handler;
@@ -30,7 +29,7 @@ use syntax::ast;
3029// Traverses an AST, reading all the information about use'd crates and extern
3130// libraries necessary for later resolving, typechecking, linking, etc.
3231pub fn read_crates ( diag : @span_handler ,
33- crate : @ ast:: crate ,
32+ crate : & ast:: crate ,
3433 cstore : @mut cstore:: CStore ,
3534 filesearch : @FileSearch ,
3635 os : loader:: os ,
@@ -53,8 +52,8 @@ pub fn read_crates(diag: @span_handler,
5352 .. * visit:: default_simple_visitor ( ) } ) ;
5453 visit_crate ( e, crate ) ;
5554 visit:: visit_crate ( crate , ( ( ) , v) ) ;
56- dump_crates ( e. crate_cache ) ;
57- warn_if_multiple_versions ( e, diag, e. crate_cache ) ;
55+ dump_crates ( * e. crate_cache ) ;
56+ warn_if_multiple_versions ( e, diag, * e. crate_cache ) ;
5857}
5958
6059struct cache_entry {
@@ -64,7 +63,7 @@ struct cache_entry {
6463 metas : @~[ @ast:: meta_item ]
6564}
6665
67- fn dump_crates ( crate_cache : @ mut ~ [ cache_entry ] ) {
66+ fn dump_crates ( crate_cache : & [ cache_entry ] ) {
6867 debug ! ( "resolved crates:" ) ;
6968 for crate_cache. iter( ) . advance |entry| {
7069 debug ! ( "cnum: %?" , entry. cnum) ;
@@ -75,11 +74,9 @@ fn dump_crates(crate_cache: @mut ~[cache_entry]) {
7574
7675fn warn_if_multiple_versions( e: @mut Env ,
7776 diag: @span_handler,
78- crate_cache: @ mut ~ [ cache_entry] ) {
77+ crate_cache: & [ cache_entry] ) {
7978 use core:: either:: * ;
8079
81- let crate_cache = & mut * crate_cache;
82-
8380 if crate_cache. len ( ) != 0 u {
8481 let name = loader:: crate_name_from_metas (
8582 * crate_cache[ crate_cache. len ( ) - 1 ] . metas
@@ -111,7 +108,7 @@ fn warn_if_multiple_versions(e: @mut Env,
111108 }
112109 }
113110
114- warn_if_multiple_versions ( e, diag, @ mut non_matches) ;
111+ warn_if_multiple_versions ( e, diag, non_matches) ;
115112 }
116113}
117114
@@ -126,7 +123,7 @@ struct Env {
126123 intr : @ident_interner
127124}
128125
129- fn visit_crate ( e : @ mut Env , c : & ast:: crate ) {
126+ fn visit_crate ( e : & Env , c : & ast:: crate ) {
130127 let cstore = e. cstore ;
131128 let link_args = attr:: find_attrs_by_name ( c. node . attrs , "link_args" ) ;
132129
@@ -152,7 +149,7 @@ fn visit_view_item(e: @mut Env, i: @ast::view_item) {
152149 }
153150}
154151
155- fn visit_item ( e : @ mut Env , i : @ast:: item ) {
152+ fn visit_item ( e : & Env , i : @ast:: item ) {
156153 match i. node {
157154 ast:: item_foreign_mod( ref fm) => {
158155 if fm. abis . is_rust ( ) || fm. abis . is_intrinsic ( ) {
@@ -204,26 +201,25 @@ fn visit_item(e: @mut Env, i: @ast::item) {
204201 }
205202}
206203
207- fn metas_with ( ident : @str , key : @str , metas : ~[ @ast:: meta_item ] )
204+ fn metas_with ( ident : @str , key : @str , mut metas : ~[ @ast:: meta_item ] )
208205 -> ~[ @ast:: meta_item ] {
209206 let name_items = attr:: find_meta_items_by_name ( metas, key) ;
210207 if name_items. is_empty ( ) {
211- vec:: append_one ( metas, attr:: mk_name_value_item_str ( key, ident) )
212- } else {
213- metas
208+ metas. push ( attr:: mk_name_value_item_str ( key, ident) ) ;
214209 }
210+ metas
215211}
216212
217213fn metas_with_ident ( ident : @str , metas : ~[ @ast:: meta_item ] )
218214 -> ~[ @ast:: meta_item ] {
219215 metas_with ( ident, @"name", metas)
220216}
221217
222- fn existing_match ( e : @ mut Env , metas : & [ @ast:: meta_item ] , hash : @ str )
218+ fn existing_match ( e : & Env , metas : & [ @ast:: meta_item ] , hash : & str )
223219 -> Option < int > {
224220 for e. crate_cache. iter( ) . advance |c| {
225221 if loader:: metadata_matches( * c. metas, metas)
226- && ( hash. is_empty( ) || c. hash == hash) {
222+ && ( hash. is_empty( ) || c. hash. as_slice ( ) == hash) {
227223 return Some ( c. cnum) ;
228224 }
229225 }
0 commit comments