@@ -36,7 +36,7 @@ pub use self::Visibility::*;
36
36
pub use self :: PathParameters :: * ;
37
37
38
38
use intravisit:: Visitor ;
39
- use rustc_data_structures :: fnv :: FnvHashMap ;
39
+ use std :: collections :: BTreeMap ;
40
40
use syntax:: codemap:: { self , Span , Spanned , DUMMY_SP , ExpnId } ;
41
41
use syntax:: abi:: Abi ;
42
42
use syntax:: ast:: { Name , Ident , NodeId , DUMMY_NODE_ID , TokenTree , AsmDialect } ;
@@ -329,7 +329,14 @@ pub struct Crate {
329
329
pub config : CrateConfig ,
330
330
pub span : Span ,
331
331
pub exported_macros : Vec < MacroDef > ,
332
- pub items : FnvHashMap < NodeId , Item > ,
332
+
333
+ // NB: We use a BTreeMap here so that `visit_all_items` iterates
334
+ // over the ids in increasing order. In principle it should not
335
+ // matter what order we visit things in, but in *practice* it
336
+ // does, because it can affect the order in which errors are
337
+ // detected, which in turn can make compile-fail tests yield
338
+ // slightly different results.
339
+ pub items : BTreeMap < NodeId , Item > ,
333
340
}
334
341
335
342
impl Crate {
@@ -346,15 +353,7 @@ impl Crate {
346
353
/// approach. You should override `visit_nested_item` in your
347
354
/// visitor and then call `intravisit::walk_crate` instead.
348
355
pub fn visit_all_items < ' hir , V : Visitor < ' hir > > ( & ' hir self , visitor : & mut V ) {
349
- // In principle, we could just iterate over the hashmap, but
350
- // in practice that makes the order of error reporting vary
351
- // with small changes in the input etc etc, which makes the
352
- // test base hard to maintain. So instead we sort by node-id
353
- // so as to get reproducible results.
354
- let mut pairs: Vec < _ > = self . items . iter ( ) . collect ( ) ;
355
- pairs. sort_by ( |& ( id1, _) , & ( id2, _) | id1. cmp ( id2) ) ;
356
-
357
- for ( _, item) in pairs {
356
+ for ( _, item) in & self . items {
358
357
visitor. visit_item ( item) ;
359
358
}
360
359
}
0 commit comments