From 87644d120fb6d0f349e003d212dd8dd5053edd49 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 12 Feb 2020 21:44:09 +0100 Subject: [PATCH 1/2] rustup --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index edb99d8eb0..89a8a40f1b 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -b5e21dbb5cabdaaadc47a4d8e3f59979dcad2871 +2d2be570970d784db5539a1d309cd22b85be910a From a843fd4e17bc88895a265136a775e73b4d44dd0a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 12 Feb 2020 21:50:54 +0100 Subject: [PATCH 2/2] add test for layout optimizations --- tests/run-pass/stacked-borrows/refcell.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/run-pass/stacked-borrows/refcell.rs b/tests/run-pass/stacked-borrows/refcell.rs index 0939a66619..83db10577c 100644 --- a/tests/run-pass/stacked-borrows/refcell.rs +++ b/tests/run-pass/stacked-borrows/refcell.rs @@ -4,6 +4,7 @@ fn main() { basic(); ref_protector(); ref_mut_protector(); + rust_issue_68303(); } fn basic() { @@ -66,3 +67,11 @@ fn ref_mut_protector() { let rc = RefCell::new(0); break_it(&rc, rc.borrow_mut()) } + +/// Make sure we do not have bad enum layout optimizations. +fn rust_issue_68303() { + let optional=Some(RefCell::new(false)); + let mut handle=optional.as_ref().unwrap().borrow_mut(); + assert!(optional.is_some()); + *handle=true; +}