@@ -197,6 +197,7 @@ use rustc_session::config::EntryFnType;
197197use rustc_span:: source_map:: { dummy_spanned, respan, Span , Spanned , DUMMY_SP } ;
198198use smallvec:: SmallVec ;
199199use std:: iter;
200+ use std:: ops:: Range ;
200201use std:: path:: PathBuf ;
201202
202203#[ derive( PartialEq ) ]
@@ -210,9 +211,8 @@ pub enum MonoItemCollectionMode {
210211pub struct InliningMap < ' tcx > {
211212 // Maps a source mono item to the range of mono items
212213 // 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 > > ,
216216 targets : Vec < MonoItem < ' tcx > > ,
217217
218218 // Contains one bit per mono item in the `targets` field. That bit
@@ -245,7 +245,7 @@ impl<'tcx> InliningMap<'tcx> {
245245 }
246246
247247 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( ) ) ;
249249 }
250250
251251 // Internally iterate over all items referenced by `source` which will be
@@ -254,9 +254,9 @@ impl<'tcx> InliningMap<'tcx> {
254254 where
255255 F : FnMut ( MonoItem < ' tcx > ) ,
256256 {
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) {
260260 f ( * candidate) ;
261261 }
262262 }
@@ -268,8 +268,8 @@ impl<'tcx> InliningMap<'tcx> {
268268 where
269269 F : FnMut ( MonoItem < ' tcx > , & [ MonoItem < ' tcx > ] ) ,
270270 {
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 ( ) ] )
273273 }
274274 }
275275}
0 commit comments