@@ -141,24 +141,28 @@ pub fn find_extern_mod_stmt_cnum(cstore: @mut CStore,
141141 extern_mod_crate_map. find ( & emod_id)
142142}
143143
144- // returns hashes of crates directly used by this crate. Hashes are
145- // sorted by crate name.
144+ // returns hashes of crates directly used by this crate. Hashes are sorted by
145+ // (crate name, crate version, crate hash) in lexicographic order (not semver)
146146pub fn get_dep_hashes ( cstore : @mut CStore ) -> ~[ ~str ] {
147- struct crate_hash { name : @~str , hash : @~str }
147+ struct crate_hash { name : @~str , vers : @~ str , hash : @~str }
148148 let mut result = ~[ ] ;
149149
150150 let extern_mod_crate_map = cstore. extern_mod_crate_map ;
151151 for extern_mod_crate_map. each_value |& cnum| {
152152 let cdata = cstore:: get_crate_data ( cstore, cnum) ;
153153 let hash = decoder:: get_crate_hash ( cdata. data ) ;
154- debug ! ( "Add hash[%s]: %s" , * cdata. name, * hash) ;
154+ let vers = decoder:: get_crate_vers ( cdata. data ) ;
155+ debug ! ( "Add hash[%s]: %s %s" , * cdata. name, * vers, * hash) ;
155156 result. push ( crate_hash {
156157 name : cdata. name ,
158+ vers : vers,
157159 hash : hash
158160 } ) ;
159161 }
160162
161- let sorted = std:: sort:: merge_sort ( result, |a, b| a. name <= b. name ) ;
163+ let sorted = do std:: sort:: merge_sort ( result) |a, b| {
164+ ( a. name , a. vers , a. hash ) <= ( b. name , b. vers , b. hash )
165+ } ;
162166
163167 debug ! ( "sorted:" ) ;
164168 for sorted. each |x| {
0 commit comments