]> git.lizzy.rs Git - rust.git/commitdiff
Fix recursion depth counting in `layout`
authorJames Miller <james@aatch.net>
Wed, 8 Feb 2017 09:23:09 +0000 (22:23 +1300)
committerEduard-Mihai Burtescu <edy.burt@gmail.com>
Fri, 10 Mar 2017 00:55:39 +0000 (02:55 +0200)
src/librustc/ty/util.rs

index be1582066e393c4b99b6884e6b8f9a5c9dbe85ab..a81c3a177f8854070966720631c65aac9e59c62e 100644 (file)
@@ -654,11 +654,12 @@ pub fn layout<'lcx>(&'tcx self, infcx: &InferCtxt<'a, 'tcx, 'lcx>)
         }
 
         tcx.layout_depth.set(depth+1);
-        let layout = Layout::compute_uncached(self, infcx)?;
+        let layout = Layout::compute_uncached(self, infcx);
+        tcx.layout_depth.set(depth);
+        let layout = layout?;
         if can_cache {
             tcx.layout_cache.borrow_mut().insert(self, layout);
         }
-        tcx.layout_depth.set(depth);
         Ok(layout)
     }