@@ -26,15 +26,12 @@ use util::nodemap::{DefIdSet, NodeSet};
26
26
27
27
use rustc_data_structures:: indexed_vec:: IndexVec ;
28
28
use std:: cell:: { RefCell , RefMut } ;
29
- use std:: option;
30
29
use std:: fmt:: Debug ;
31
30
use std:: hash:: Hash ;
32
- use std:: iter:: { self , Once } ;
33
31
use std:: mem;
34
32
use std:: collections:: BTreeMap ;
35
33
use std:: ops:: Deref ;
36
34
use std:: rc:: Rc ;
37
- use std:: vec;
38
35
use syntax_pos:: { Span , DUMMY_SP } ;
39
36
use syntax:: symbol:: Symbol ;
40
37
@@ -161,67 +158,6 @@ impl<'tcx> Value<'tcx> for ty::SymbolName {
161
158
}
162
159
}
163
160
164
- trait IntoKeyValues < K : Key , V > {
165
- type KeyValues : IntoIterator < Item =( K , V ) > ;
166
-
167
- fn into_key_values ( key : & K , value : Self ) -> Self :: KeyValues ;
168
- }
169
-
170
- impl < K : Key , V > IntoKeyValues < K , V > for V {
171
- type KeyValues = Once < ( K , V ) > ;
172
-
173
- fn into_key_values ( key : & K , value : Self ) -> Self :: KeyValues {
174
- iter:: once ( ( key. clone ( ) , value) )
175
- }
176
- }
177
-
178
- /// Return type for a multi-query, which is a query which may (if it
179
- /// chooses) return more than one (key, value) pair. Construct a
180
- /// `Multi` using `Multi::from(...)`.
181
- pub struct Multi < K : Key , V > {
182
- single : Option < V > ,
183
- map : Vec < ( K , V ) > ,
184
- }
185
-
186
- impl < K : Key , V > Multi < K , V > {
187
- pub fn iter < ' a > ( & ' a self , key : & ' a K ) -> impl Iterator < Item = ( & ' a K , & ' a V ) > + ' a {
188
- self . single . iter ( )
189
- . map ( move |v| ( key, v) )
190
- . chain ( self . map . iter ( ) . map ( move |& ( ref k, ref v) | ( k, v) ) )
191
- }
192
- }
193
-
194
- /// Construct a `Multi` from a single value.
195
- impl < K : Key , V > From < V > for Multi < K , V > {
196
- fn from ( value : V ) -> Self {
197
- Multi {
198
- single : Some ( value) ,
199
- map : vec ! [ ] ,
200
- }
201
- }
202
- }
203
-
204
- /// Construct a `Multi` from a hashmap of (K, V) pairs.
205
- impl < K : Key , V > From < Vec < ( K , V ) > > for Multi < K , V > {
206
- fn from ( value : Vec < ( K , V ) > ) -> Self {
207
- Multi {
208
- single : None ,
209
- map : value
210
- }
211
- }
212
- }
213
-
214
- impl < K : Key , V > IntoKeyValues < K , V > for Multi < K , V > {
215
- type KeyValues = iter:: Chain < option:: IntoIter < ( K , V ) > , vec:: IntoIter < ( K , V ) > > ;
216
-
217
- fn into_key_values ( key : & K , value : Self ) -> Self :: KeyValues {
218
- value. single
219
- . map ( |v| ( key. clone ( ) , v) )
220
- . into_iter ( )
221
- . chain ( value. map )
222
- }
223
- }
224
-
225
161
pub struct CycleError < ' a , ' tcx : ' a > {
226
162
span : Span ,
227
163
cycle : RefMut < ' a , [ ( Span , Query < ' tcx > ) ] > ,
@@ -490,14 +426,7 @@ macro_rules! define_maps {
490
426
provider( tcx. global_tcx( ) , key)
491
427
} ) ?;
492
428
493
- {
494
- let map = & mut * tcx. maps. $name. borrow_mut( ) ;
495
- for ( k, v) in IntoKeyValues :: <$K, $V>:: into_key_values( & key, result) {
496
- map. insert( k, v) ;
497
- }
498
- }
499
-
500
- Ok ( f( tcx. maps. $name. borrow( ) . get( & key) . expect( "value just generated" ) ) )
429
+ Ok ( f( tcx. maps. $name. borrow_mut( ) . entry( key) . or_insert( result) ) )
501
430
}
502
431
503
432
pub fn try_get( tcx: TyCtxt <' a, $tcx, ' lcx>, span: Span , key: $K)
@@ -683,20 +612,6 @@ macro_rules! define_provider_struct {
683
612
}
684
613
} ;
685
614
686
- // The `multi` modifier indicates a **multiquery**, in which case
687
- // the function returns a `Multi<K,V>` instead of just a value
688
- // `V`.
689
- ( tcx: $tcx: tt,
690
- input: ( ( [ multi $( $other_modifiers: tt) * ] $name: tt [ $K: ty] [ $V: ty] ) $( $input: tt) * ) ,
691
- output: $output: tt) => {
692
- define_provider_struct! {
693
- tcx: $tcx,
694
- ready: ( $name [ $K] [ Multi <$K, $V>] ) ,
695
- input: ( $( $input) * ) ,
696
- output: $output
697
- }
698
- } ;
699
-
700
615
// Regular queries produce a `V` only.
701
616
( tcx: $tcx: tt,
702
617
input: ( ( [ ] $name: tt $K: tt $V: tt) $( $input: tt) * ) ,
@@ -709,7 +624,7 @@ macro_rules! define_provider_struct {
709
624
}
710
625
} ;
711
626
712
- // Skip modifiers other than `multi` .
627
+ // Skip modifiers.
713
628
( tcx: $tcx: tt,
714
629
input: ( ( [ $other_modifier: tt $( $modifiers: tt) * ] $( $fields: tt) * ) $( $input: tt) * ) ,
715
630
output: $output: tt) => {
0 commit comments