@@ -15,87 +15,88 @@ use chalk_solve::rust_ir::{
1515} ;
1616use chalk_solve:: split:: Split ;
1717use chalk_solve:: RustIrDatabase ;
18- use std:: collections:: { BTreeMap , HashSet } ;
18+ use indexmap:: IndexMap ;
19+ use std:: collections:: HashSet ;
1920use std:: fmt;
2021use std:: sync:: Arc ;
2122
2223#[ derive( Clone , Debug , PartialEq , Eq ) ]
2324pub struct Program {
2425 /// From ADT name to item-id. Used during lowering only.
25- pub adt_ids : BTreeMap < Identifier , AdtId < ChalkIr > > ,
26+ pub adt_ids : IndexMap < Identifier , AdtId < ChalkIr > > ,
2627
2728 /// For each ADT:
28- pub adt_kinds : BTreeMap < AdtId < ChalkIr > , TypeKind > ,
29+ pub adt_kinds : IndexMap < AdtId < ChalkIr > , TypeKind > ,
2930
30- pub adt_variances : BTreeMap < AdtId < ChalkIr > , Vec < Variance > > ,
31+ pub adt_variances : IndexMap < AdtId < ChalkIr > , Vec < Variance > > ,
3132
32- pub fn_def_ids : BTreeMap < Identifier , FnDefId < ChalkIr > > ,
33+ pub fn_def_ids : IndexMap < Identifier , FnDefId < ChalkIr > > ,
3334
34- pub fn_def_kinds : BTreeMap < FnDefId < ChalkIr > , TypeKind > ,
35+ pub fn_def_kinds : IndexMap < FnDefId < ChalkIr > , TypeKind > ,
3536
36- pub fn_def_variances : BTreeMap < FnDefId < ChalkIr > , Vec < Variance > > ,
37+ pub fn_def_variances : IndexMap < FnDefId < ChalkIr > , Vec < Variance > > ,
3738
38- pub closure_ids : BTreeMap < Identifier , ClosureId < ChalkIr > > ,
39+ pub closure_ids : IndexMap < Identifier , ClosureId < ChalkIr > > ,
3940
40- pub closure_upvars : BTreeMap < ClosureId < ChalkIr > , Binders < Ty < ChalkIr > > > ,
41+ pub closure_upvars : IndexMap < ClosureId < ChalkIr > , Binders < Ty < ChalkIr > > > ,
4142
42- pub closure_kinds : BTreeMap < ClosureId < ChalkIr > , TypeKind > ,
43+ pub closure_kinds : IndexMap < ClosureId < ChalkIr > , TypeKind > ,
4344
4445 /// For each generator
45- pub generator_ids : BTreeMap < Identifier , GeneratorId < ChalkIr > > ,
46+ pub generator_ids : IndexMap < Identifier , GeneratorId < ChalkIr > > ,
4647
47- pub generator_kinds : BTreeMap < GeneratorId < ChalkIr > , TypeKind > ,
48+ pub generator_kinds : IndexMap < GeneratorId < ChalkIr > , TypeKind > ,
4849
49- pub generator_data : BTreeMap < GeneratorId < ChalkIr > , Arc < GeneratorDatum < ChalkIr > > > ,
50+ pub generator_data : IndexMap < GeneratorId < ChalkIr > , Arc < GeneratorDatum < ChalkIr > > > ,
5051
51- pub generator_witness_data : BTreeMap < GeneratorId < ChalkIr > , Arc < GeneratorWitnessDatum < ChalkIr > > > ,
52+ pub generator_witness_data : IndexMap < GeneratorId < ChalkIr > , Arc < GeneratorWitnessDatum < ChalkIr > > > ,
5253
5354 /// From trait name to item-id. Used during lowering only.
54- pub trait_ids : BTreeMap < Identifier , TraitId < ChalkIr > > ,
55+ pub trait_ids : IndexMap < Identifier , TraitId < ChalkIr > > ,
5556
5657 /// For each trait:
57- pub trait_kinds : BTreeMap < TraitId < ChalkIr > , TypeKind > ,
58+ pub trait_kinds : IndexMap < TraitId < ChalkIr > , TypeKind > ,
5859
5960 /// For each ADT:
60- pub adt_data : BTreeMap < AdtId < ChalkIr > , Arc < AdtDatum < ChalkIr > > > ,
61+ pub adt_data : IndexMap < AdtId < ChalkIr > , Arc < AdtDatum < ChalkIr > > > ,
6162
62- pub adt_reprs : BTreeMap < AdtId < ChalkIr > , Arc < AdtRepr < ChalkIr > > > ,
63+ pub adt_reprs : IndexMap < AdtId < ChalkIr > , Arc < AdtRepr < ChalkIr > > > ,
6364
64- pub fn_def_data : BTreeMap < FnDefId < ChalkIr > , Arc < FnDefDatum < ChalkIr > > > ,
65+ pub fn_def_data : IndexMap < FnDefId < ChalkIr > , Arc < FnDefDatum < ChalkIr > > > ,
6566
6667 pub closure_inputs_and_output :
67- BTreeMap < ClosureId < ChalkIr > , Binders < FnDefInputsAndOutputDatum < ChalkIr > > > ,
68+ IndexMap < ClosureId < ChalkIr > , Binders < FnDefInputsAndOutputDatum < ChalkIr > > > ,
6869
6970 // Weird name, but otherwise would overlap with `closure_kinds` above.
70- pub closure_closure_kind : BTreeMap < ClosureId < ChalkIr > , ClosureKind > ,
71+ pub closure_closure_kind : IndexMap < ClosureId < ChalkIr > , ClosureKind > ,
7172
7273 /// For each impl:
73- pub impl_data : BTreeMap < ImplId < ChalkIr > , Arc < ImplDatum < ChalkIr > > > ,
74+ pub impl_data : IndexMap < ImplId < ChalkIr > , Arc < ImplDatum < ChalkIr > > > ,
7475
7576 /// For each associated ty value `type Foo = XXX` found in an impl:
7677 pub associated_ty_values :
77- BTreeMap < AssociatedTyValueId < ChalkIr > , Arc < AssociatedTyValue < ChalkIr > > > ,
78+ IndexMap < AssociatedTyValueId < ChalkIr > , Arc < AssociatedTyValue < ChalkIr > > > ,
7879
7980 // From opaque type name to item-id. Used during lowering only.
80- pub opaque_ty_ids : BTreeMap < Identifier , OpaqueTyId < ChalkIr > > ,
81+ pub opaque_ty_ids : IndexMap < Identifier , OpaqueTyId < ChalkIr > > ,
8182
8283 /// For each opaque type:
83- pub opaque_ty_kinds : BTreeMap < OpaqueTyId < ChalkIr > , TypeKind > ,
84+ pub opaque_ty_kinds : IndexMap < OpaqueTyId < ChalkIr > , TypeKind > ,
8485
8586 /// For each opaque type:
86- pub opaque_ty_data : BTreeMap < OpaqueTyId < ChalkIr > , Arc < OpaqueTyDatum < ChalkIr > > > ,
87+ pub opaque_ty_data : IndexMap < OpaqueTyId < ChalkIr > , Arc < OpaqueTyDatum < ChalkIr > > > ,
8788
8889 /// Stores the hidden types for opaque types
89- pub hidden_opaque_types : BTreeMap < OpaqueTyId < ChalkIr > , Arc < Ty < ChalkIr > > > ,
90+ pub hidden_opaque_types : IndexMap < OpaqueTyId < ChalkIr > , Arc < Ty < ChalkIr > > > ,
9091
9192 /// For each trait:
92- pub trait_data : BTreeMap < TraitId < ChalkIr > , Arc < TraitDatum < ChalkIr > > > ,
93+ pub trait_data : IndexMap < TraitId < ChalkIr > , Arc < TraitDatum < ChalkIr > > > ,
9394
9495 /// For each trait lang item
95- pub well_known_traits : BTreeMap < WellKnownTrait , TraitId < ChalkIr > > ,
96+ pub well_known_traits : IndexMap < WellKnownTrait , TraitId < ChalkIr > > ,
9697
9798 /// For each associated ty declaration `type Foo` found in a trait:
98- pub associated_ty_data : BTreeMap < AssocTypeId < ChalkIr > , Arc < AssociatedTyDatum < ChalkIr > > > ,
99+ pub associated_ty_data : IndexMap < AssocTypeId < ChalkIr > , Arc < AssociatedTyDatum < ChalkIr > > > ,
99100
100101 /// For each user-specified clause
101102 pub custom_clauses : Vec < ProgramClause < ChalkIr > > ,
@@ -104,7 +105,7 @@ pub struct Program {
104105 pub object_safe_traits : HashSet < TraitId < ChalkIr > > ,
105106
106107 /// For each foreign type `extern { type A; }`
107- pub foreign_ty_ids : BTreeMap < Identifier , ForeignDefId < ChalkIr > > ,
108+ pub foreign_ty_ids : IndexMap < Identifier , ForeignDefId < ChalkIr > > ,
108109}
109110
110111impl Program {
0 commit comments