allow using tuple variant names as function handles in presence of NonZero optimizations

This commit is contained in:
Oliver Schneider 2016-12-19 17:49:51 +01:00
parent 04eadedb28
commit e22cceaceb
No known key found for this signature in database
GPG key ID: A69F8D225B3AD7D9
3 changed files with 21 additions and 1 deletions

View file

@ -258,7 +258,12 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
discr_size,
)?;
},
// FIXME: raw nullable pointer constructors
Layout::StructWrappedNullablePointer { .. } |
Layout::RawNullablePointer { .. } => {
assert_eq!(args.len(), 1);
let (val, ty) = args.pop().unwrap();
self.write_value(val, lvalue, ty)?;
},
_ => bug!("bad layout for tuple struct constructor: {:?}", dest_layout),
}
self.goto_block(target);

View file

@ -0,0 +1,4 @@
fn main() {
let x = 5;
assert_eq!(Some(&x).map(Some), Some(Some(&x)));
}

View file

@ -0,0 +1,11 @@
#[derive(Copy, Clone, PartialEq, Debug)]
struct A<'a> {
x: i32,
y: &'a i32,
}
fn main() {
let x = 5;
let a = A { x: 99, y: &x };
assert_eq!(Some(a).map(Some), Some(Some(a)));
}