]> git.lizzy.rs Git - rust.git/commitdiff
add test for layout optimizations
authorRalf Jung <post@ralfj.de>
Wed, 12 Feb 2020 20:50:54 +0000 (21:50 +0100)
committerRalf Jung <post@ralfj.de>
Wed, 12 Feb 2020 21:04:58 +0000 (22:04 +0100)
tests/run-pass/stacked-borrows/refcell.rs

index 0939a666193e87ab1bbe71da31466dfa964eb06a..83db10577cebfc162da20fb76ac4a66ca0a4b001 100644 (file)
@@ -4,6 +4,7 @@ fn main() {
     basic();
     ref_protector();
     ref_mut_protector();
+    rust_issue_68303();
 }
 
 fn basic() {
@@ -66,3 +67,11 @@ fn break_it(rc: &RefCell<i32>, r: RefMut<'_, i32>) {
     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;
+}