diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-01-12 10:54:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-12 10:54:53 +0100 |
| commit | 53aa8a1ad0fe12594347d68ee7f7c12e7c1a1937 (patch) | |
| tree | 02010777dbd348871d0b4280a1d923b190882def /src/librustc | |
| parent | e69a5cb2d7d7a8ae40a6ea3687b7c1f319a2a8ea (diff) | |
| parent | 69e491815d927b3206c8acf88fbdbed8521e5955 (diff) | |
| download | rust-53aa8a1ad0fe12594347d68ee7f7c12e7c1a1937.tar.gz rust-53aa8a1ad0fe12594347d68ee7f7c12e7c1a1937.zip | |
Rollup merge of #56906 - blitzerr:master, r=nikomatsakis
Issue #56905 Adding a map to TypeckTables to get the list of all the Upvars given a closureID. This is help us get rid of the recurring pattern in the codebase of iterating over the free vars using with_freevars.
Diffstat (limited to 'src/librustc')
| -rw-r--r-- | src/librustc/ty/context.rs | 10 | ||||
| -rw-r--r-- | src/librustc/ty/mod.rs | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index c0ba4329ae0..8d4b8aae8b1 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -417,6 +417,12 @@ pub struct TypeckTables<'tcx> { /// All the existential types that are restricted to concrete types /// by this function pub concrete_existential_types: FxHashMap<DefId, Ty<'tcx>>, + + /// Given the closure ID this map provides the list of UpvarIDs used by it. + /// The upvarID contains the HIR node ID and it also contains the full path + /// leading to the member of the struct or tuple that is used instead of the + /// entire variable. + pub upvar_list: ty::UpvarListMap, } impl<'tcx> TypeckTables<'tcx> { @@ -441,6 +447,7 @@ impl<'tcx> TypeckTables<'tcx> { tainted_by_errors: false, free_region_map: Default::default(), concrete_existential_types: Default::default(), + upvar_list: Default::default(), } } @@ -741,6 +748,8 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for TypeckTables<'gcx> { tainted_by_errors, ref free_region_map, ref concrete_existential_types, + ref upvar_list, + } = *self; hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| { @@ -783,6 +792,7 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for TypeckTables<'gcx> { tainted_by_errors.hash_stable(hcx, hasher); free_region_map.hash_stable(hcx, hasher); concrete_existential_types.hash_stable(hcx, hasher); + upvar_list.hash_stable(hcx, hasher); }) } } diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index a2c96e7cf9f..cfd99948e43 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -808,6 +808,7 @@ pub struct UpvarBorrow<'tcx> { pub region: ty::Region<'tcx>, } +pub type UpvarListMap = FxHashMap<DefId, Vec<UpvarId>>; pub type UpvarCaptureMap<'tcx> = FxHashMap<UpvarId, UpvarCapture<'tcx>>; #[derive(Copy, Clone)] |
