@@ -197,6 +197,7 @@ use rustc_session::config::EntryFnType;
197
197
use rustc_span:: source_map:: { dummy_spanned, respan, Span , Spanned , DUMMY_SP } ;
198
198
use smallvec:: SmallVec ;
199
199
use std:: iter;
200
+ use std:: ops:: Range ;
200
201
use std:: path:: PathBuf ;
201
202
202
203
#[ derive( PartialEq ) ]
@@ -210,9 +211,8 @@ pub enum MonoItemCollectionMode {
210
211
pub struct InliningMap < ' tcx > {
211
212
// Maps a source mono item to the range of mono items
212
213
// accessed by it.
213
- // The two numbers in the tuple are the start (inclusive) and
214
- // end index (exclusive) within the `targets` vecs.
215
- index : FxHashMap < MonoItem < ' tcx > , ( usize , usize ) > ,
214
+ // The range selects elements within the `targets` vecs.
215
+ index : FxHashMap < MonoItem < ' tcx > , Range < usize > > ,
216
216
targets : Vec < MonoItem < ' tcx > > ,
217
217
218
218
// Contains one bit per mono item in the `targets` field. That bit
@@ -245,7 +245,7 @@ impl<'tcx> InliningMap<'tcx> {
245
245
}
246
246
247
247
let end_index = self . targets . len ( ) ;
248
- assert ! ( self . index. insert( source, ( start_index, end_index) ) . is_none( ) ) ;
248
+ assert ! ( self . index. insert( source, start_index.. end_index) . is_none( ) ) ;
249
249
}
250
250
251
251
// Internally iterate over all items referenced by `source` which will be
@@ -254,9 +254,9 @@ impl<'tcx> InliningMap<'tcx> {
254
254
where
255
255
F : FnMut ( MonoItem < ' tcx > ) ,
256
256
{
257
- if let Some ( & ( start_index , end_index ) ) = self . index . get ( & source) {
258
- for ( i, candidate) in self . targets [ start_index..end_index ] . iter ( ) . enumerate ( ) {
259
- if self . inlines . contains ( start_index + i) {
257
+ if let Some ( range ) = self . index . get ( & source) {
258
+ for ( i, candidate) in self . targets [ range . clone ( ) ] . iter ( ) . enumerate ( ) {
259
+ if self . inlines . contains ( range . start + i) {
260
260
f ( * candidate) ;
261
261
}
262
262
}
@@ -268,8 +268,8 @@ impl<'tcx> InliningMap<'tcx> {
268
268
where
269
269
F : FnMut ( MonoItem < ' tcx > , & [ MonoItem < ' tcx > ] ) ,
270
270
{
271
- for ( & accessor, & ( start_index , end_index ) ) in & self . index {
272
- f ( accessor, & self . targets [ start_index..end_index ] )
271
+ for ( & accessor, range ) in & self . index {
272
+ f ( accessor, & self . targets [ range . clone ( ) ] )
273
273
}
274
274
}
275
275
}
0 commit comments