@@ -15,87 +15,88 @@ use chalk_solve::rust_ir::{
15
15
} ;
16
16
use chalk_solve:: split:: Split ;
17
17
use chalk_solve:: RustIrDatabase ;
18
- use std:: collections:: { BTreeMap , HashSet } ;
18
+ use indexmap:: IndexMap ;
19
+ use std:: collections:: HashSet ;
19
20
use std:: fmt;
20
21
use std:: sync:: Arc ;
21
22
22
23
#[ derive( Clone , Debug , PartialEq , Eq ) ]
23
24
pub struct Program {
24
25
/// 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 > > ,
26
27
27
28
/// For each ADT:
28
- pub adt_kinds : BTreeMap < AdtId < ChalkIr > , TypeKind > ,
29
+ pub adt_kinds : IndexMap < AdtId < ChalkIr > , TypeKind > ,
29
30
30
- pub adt_variances : BTreeMap < AdtId < ChalkIr > , Vec < Variance > > ,
31
+ pub adt_variances : IndexMap < AdtId < ChalkIr > , Vec < Variance > > ,
31
32
32
- pub fn_def_ids : BTreeMap < Identifier , FnDefId < ChalkIr > > ,
33
+ pub fn_def_ids : IndexMap < Identifier , FnDefId < ChalkIr > > ,
33
34
34
- pub fn_def_kinds : BTreeMap < FnDefId < ChalkIr > , TypeKind > ,
35
+ pub fn_def_kinds : IndexMap < FnDefId < ChalkIr > , TypeKind > ,
35
36
36
- pub fn_def_variances : BTreeMap < FnDefId < ChalkIr > , Vec < Variance > > ,
37
+ pub fn_def_variances : IndexMap < FnDefId < ChalkIr > , Vec < Variance > > ,
37
38
38
- pub closure_ids : BTreeMap < Identifier , ClosureId < ChalkIr > > ,
39
+ pub closure_ids : IndexMap < Identifier , ClosureId < ChalkIr > > ,
39
40
40
- pub closure_upvars : BTreeMap < ClosureId < ChalkIr > , Binders < Ty < ChalkIr > > > ,
41
+ pub closure_upvars : IndexMap < ClosureId < ChalkIr > , Binders < Ty < ChalkIr > > > ,
41
42
42
- pub closure_kinds : BTreeMap < ClosureId < ChalkIr > , TypeKind > ,
43
+ pub closure_kinds : IndexMap < ClosureId < ChalkIr > , TypeKind > ,
43
44
44
45
/// For each generator
45
- pub generator_ids : BTreeMap < Identifier , GeneratorId < ChalkIr > > ,
46
+ pub generator_ids : IndexMap < Identifier , GeneratorId < ChalkIr > > ,
46
47
47
- pub generator_kinds : BTreeMap < GeneratorId < ChalkIr > , TypeKind > ,
48
+ pub generator_kinds : IndexMap < GeneratorId < ChalkIr > , TypeKind > ,
48
49
49
- pub generator_data : BTreeMap < GeneratorId < ChalkIr > , Arc < GeneratorDatum < ChalkIr > > > ,
50
+ pub generator_data : IndexMap < GeneratorId < ChalkIr > , Arc < GeneratorDatum < ChalkIr > > > ,
50
51
51
- pub generator_witness_data : BTreeMap < GeneratorId < ChalkIr > , Arc < GeneratorWitnessDatum < ChalkIr > > > ,
52
+ pub generator_witness_data : IndexMap < GeneratorId < ChalkIr > , Arc < GeneratorWitnessDatum < ChalkIr > > > ,
52
53
53
54
/// 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 > > ,
55
56
56
57
/// For each trait:
57
- pub trait_kinds : BTreeMap < TraitId < ChalkIr > , TypeKind > ,
58
+ pub trait_kinds : IndexMap < TraitId < ChalkIr > , TypeKind > ,
58
59
59
60
/// For each ADT:
60
- pub adt_data : BTreeMap < AdtId < ChalkIr > , Arc < AdtDatum < ChalkIr > > > ,
61
+ pub adt_data : IndexMap < AdtId < ChalkIr > , Arc < AdtDatum < ChalkIr > > > ,
61
62
62
- pub adt_reprs : BTreeMap < AdtId < ChalkIr > , Arc < AdtRepr < ChalkIr > > > ,
63
+ pub adt_reprs : IndexMap < AdtId < ChalkIr > , Arc < AdtRepr < ChalkIr > > > ,
63
64
64
- pub fn_def_data : BTreeMap < FnDefId < ChalkIr > , Arc < FnDefDatum < ChalkIr > > > ,
65
+ pub fn_def_data : IndexMap < FnDefId < ChalkIr > , Arc < FnDefDatum < ChalkIr > > > ,
65
66
66
67
pub closure_inputs_and_output :
67
- BTreeMap < ClosureId < ChalkIr > , Binders < FnDefInputsAndOutputDatum < ChalkIr > > > ,
68
+ IndexMap < ClosureId < ChalkIr > , Binders < FnDefInputsAndOutputDatum < ChalkIr > > > ,
68
69
69
70
// 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 > ,
71
72
72
73
/// For each impl:
73
- pub impl_data : BTreeMap < ImplId < ChalkIr > , Arc < ImplDatum < ChalkIr > > > ,
74
+ pub impl_data : IndexMap < ImplId < ChalkIr > , Arc < ImplDatum < ChalkIr > > > ,
74
75
75
76
/// For each associated ty value `type Foo = XXX` found in an impl:
76
77
pub associated_ty_values :
77
- BTreeMap < AssociatedTyValueId < ChalkIr > , Arc < AssociatedTyValue < ChalkIr > > > ,
78
+ IndexMap < AssociatedTyValueId < ChalkIr > , Arc < AssociatedTyValue < ChalkIr > > > ,
78
79
79
80
// 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 > > ,
81
82
82
83
/// For each opaque type:
83
- pub opaque_ty_kinds : BTreeMap < OpaqueTyId < ChalkIr > , TypeKind > ,
84
+ pub opaque_ty_kinds : IndexMap < OpaqueTyId < ChalkIr > , TypeKind > ,
84
85
85
86
/// 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 > > > ,
87
88
88
89
/// 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 > > > ,
90
91
91
92
/// For each trait:
92
- pub trait_data : BTreeMap < TraitId < ChalkIr > , Arc < TraitDatum < ChalkIr > > > ,
93
+ pub trait_data : IndexMap < TraitId < ChalkIr > , Arc < TraitDatum < ChalkIr > > > ,
93
94
94
95
/// For each trait lang item
95
- pub well_known_traits : BTreeMap < WellKnownTrait , TraitId < ChalkIr > > ,
96
+ pub well_known_traits : IndexMap < WellKnownTrait , TraitId < ChalkIr > > ,
96
97
97
98
/// 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 > > > ,
99
100
100
101
/// For each user-specified clause
101
102
pub custom_clauses : Vec < ProgramClause < ChalkIr > > ,
@@ -104,7 +105,7 @@ pub struct Program {
104
105
pub object_safe_traits : HashSet < TraitId < ChalkIr > > ,
105
106
106
107
/// 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 > > ,
108
109
}
109
110
110
111
impl Program {
0 commit comments