about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-01-09 01:58:54 +0800
committerkennytm <kennytm@gmail.com>2018-01-09 03:37:21 +0800
commit9dd7caef041e1b3ef52e9694d146c2170d833ad7 (patch)
tree4034f3be010e44602a556ed1c09cb6d901d32443 /src
parentde4e1a9773201ba89f77b3a1015e0a3ac9969cf1 (diff)
parent1a7b00d5fd28edc3ea236bbe8e5fe0b5d81b4c8c (diff)
downloadrust-9dd7caef041e1b3ef52e9694d146c2170d833ad7.tar.gz
rust-9dd7caef041e1b3ef52e9694d146c2170d833ad7.zip
Rollup merge of #47270 - Zoxc:gen-layout-fix, r=eddyb
Don't look for niches inside generator types. Fixes #47253

r? @eddyb
Diffstat (limited to 'src')
-rw-r--r--src/librustc/ty/layout.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs
index 34a7d4ad7cf..50efb730037 100644
--- a/src/librustc/ty/layout.rs
+++ b/src/librustc/ty/layout.rs
@@ -2295,6 +2295,13 @@ impl<'a, 'tcx> TyLayout<'tcx> {
             }, niche_start))
         };
 
+        // Locals variables which live across yields are stored
+        // in the generator type as fields. These may be uninitialized
+        // so we don't look for niches there.
+        if let ty::TyGenerator(..) = self.ty.sty {
+            return Ok(None);
+        }
+
         match self.abi {
             Abi::Scalar(ref scalar) => {
                 return Ok(scalar_component(scalar, Size::from_bytes(0)));