about summary refs log tree commit diff
path: root/src/librustc_mir/transform
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <ariel.byd@gmail.com>2016-11-03 22:19:33 +0200
committerAriel Ben-Yehuda <ariel.byd@gmail.com>2016-11-12 19:00:50 +0200
commitca9b5664c3c4a052a044d63725239ff2e56136f4 (patch)
treecc41fd12efb663deb62c8e52731d10aa1863dbe8 /src/librustc_mir/transform
parentf3af8c8505255555023e4cb7c6c4f297ce22d80d (diff)
downloadrust-ca9b5664c3c4a052a044d63725239ff2e56136f4.tar.gz
rust-ca9b5664c3c4a052a044d63725239ff2e56136f4.zip
rustc: move closure upvar types to the closure substs
This moves closures to the (DefId, Substs) scheme like all other items,
and saves a word from the size of TyS now that Substs is 2 words.
Diffstat (limited to 'src/librustc_mir/transform')
-rw-r--r--src/librustc_mir/transform/type_check.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/librustc_mir/transform/type_check.rs b/src/librustc_mir/transform/type_check.rs
index ad525d21069..79bb14b7336 100644
--- a/src/librustc_mir/transform/type_check.rs
+++ b/src/librustc_mir/transform/type_check.rs
@@ -274,9 +274,15 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
                 ty::TyAdt(adt_def, substs) if adt_def.is_univariant() => {
                         (&adt_def.variants[0], substs)
                     }
-                ty::TyTuple(tys) | ty::TyClosure(_, ty::ClosureSubsts {
-                    upvar_tys: tys, ..
-                }) => {
+                ty::TyClosure(def_id, substs) => {
+                    return match substs.upvar_tys(def_id, tcx).nth(field.index()) {
+                        Some(ty) => Ok(ty),
+                        None => Err(FieldAccessError::OutOfRange {
+                            field_count: substs.upvar_tys(def_id, tcx).count()
+                        })
+                    }
+                }
+                ty::TyTuple(tys) => {
                     return match tys.get(field.index()) {
                         Some(&ty) => Ok(ty),
                         None => Err(FieldAccessError::OutOfRange {