@@ -54,6 +54,7 @@ use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap,
5454 StableHasher , StableHasherResult ,
5555 StableVec } ;
5656use arena:: SyncDroplessArena ;
57+ use rustc_data_structures:: fx:: FxIndexMap ;
5758use rustc_data_structures:: indexed_vec:: { Idx , IndexVec } ;
5859use rustc_data_structures:: sync:: { Lrc , Lock , WorkerLocal } ;
5960use std:: any:: Any ;
@@ -1065,7 +1066,7 @@ pub struct GlobalCtxt<'tcx> {
10651066 // Records the captured variables referenced by every closure
10661067 // expression. Do not track deps for this, just recompute it from
10671068 // scratch every time.
1068- upvars : FxHashMap < DefId , Vec < hir:: Upvar > > ,
1069+ upvars : FxHashMap < DefId , FxIndexMap < hir :: HirId , hir:: Upvar > > ,
10691070
10701071 maybe_unused_trait_imports : FxHashSet < DefId > ,
10711072 maybe_unused_extern_crates : Vec < ( DefId , Span ) > ,
@@ -1297,11 +1298,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
12971298 } ) . collect ( ) ;
12981299 ( k, exports)
12991300 } ) . collect ( ) ,
1300- upvars : resolutions. upvars . into_iter ( ) . map ( |( k, v ) | {
1301- let vars : Vec < _ > = v . into_iter ( ) . map ( |e | {
1302- e . map_id ( |id| hir. node_to_hir_id ( id ) )
1301+ upvars : resolutions. upvars . into_iter ( ) . map ( |( k, upvars ) | {
1302+ let upvars : FxIndexMap < _ , _ > = upvars . into_iter ( ) . map ( |( var_id , upvar ) | {
1303+ ( hir. node_to_hir_id ( var_id ) , upvar )
13031304 } ) . collect ( ) ;
1304- ( hir. local_def_id ( k) , vars )
1305+ ( hir. local_def_id ( k) , upvars )
13051306 } ) . collect ( ) ,
13061307 maybe_unused_trait_imports :
13071308 resolutions. maybe_unused_trait_imports
@@ -3023,7 +3024,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
30233024 assert_eq ! ( id, LOCAL_CRATE ) ;
30243025 tcx. arena . alloc ( middle:: lang_items:: collect ( tcx) )
30253026 } ;
3026- providers. upvars = |tcx, id| tcx. gcx . upvars . get ( & id) . map ( |v| & v [ .. ] ) ;
3027+ providers. upvars = |tcx, id| tcx. gcx . upvars . get ( & id) ;
30273028 providers. maybe_unused_trait_import = |tcx, id| {
30283029 tcx. maybe_unused_trait_imports . contains ( & id)
30293030 } ;
0 commit comments