about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2018-01-08 13:18:50 +0100
committerJohn Kåre Alsaker <john.kare.alsaker@gmail.com>2018-01-08 13:19:27 +0100
commit1a7b00d5fd28edc3ea236bbe8e5fe0b5d81b4c8c (patch)
tree45ef222240cdb6dcbcf5d82b5c10f417f7b1af7c /src
parent795594cd8ce3272bd6b1ebf7e1b7f33a5a86e3ac (diff)
Don't look for niches inside generator types. Fixes #47253
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)));