1 // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // compile-flags: -Z identify_regions -Z span_free_formats -Z emit-end-regions
12 // ignore-tidy-linelength
14 // This test models a scenario with a cyclic reference. Rust obviously
15 // needs to handle such cases.
17 // The interesting part about this test is that such case shows that
18 // one cannot generally force all references to be dead before you hit
19 // their EndRegion; at least, not without breaking the more important
20 // property that all borrowed storage locations have their regions
21 // ended strictly before their StorageDeads. (This test was inspired
22 // by discussion on Issue #43481.)
27 r: Cell<Option<&'a S<'a>>>,
32 let x = S { r: Cell::new(None) };
39 fn query() -> bool { true }
42 // START rustc.node16.SimplifyCfg-qualify-consts.after.mir
46 // let _2: S<'35_0rs>;
49 // let mut _3: std::cell::Cell<std::option::Option<&'35_0rs S<'35_0rs>>>;
50 // let mut _4: std::option::Option<&'35_0rs S<'35_0rs>>;
52 // let mut _6: &'16s std::cell::Cell<std::option::Option<&'35_0rs S<'35_0rs>>>;
53 // let mut _7: std::option::Option<&'35_0rs S<'35_0rs>>;
54 // let mut _8: &'35_0rs S<'35_0rs>;
55 // let mut _9: &'35_0rs S<'35_0rs>;
60 // let mut _14: &'33s std::cell::Cell<std::option::Option<&'35_0rs S<'35_0rs>>>;
61 // let mut _15: std::option::Option<&'35_0rs S<'35_0rs>>;
62 // let mut _16: &'35_0rs S<'35_0rs>;
63 // let mut _17: &'35_0rs S<'35_0rs>;
71 // _4 = std::option::Option<&'35_0rs S<'35_0rs>>::None;
72 // _3 = const <std::cell::Cell<T>>::new(_4) -> bb2;
76 // _2 = S<'35_0rs> { r: _3 };
79 // _6 = &'16s (_2.0: std::cell::Cell<std::option::Option<&'35_0rs S<'35_0rs>>>);
84 // _8 = &'35_0rs (*_9);
85 // _7 = std::option::Option<&'35_0rs S<'35_0rs>>::Some(_8,);
87 // _5 = const <std::cell::Cell<T>>::set(_6, _7) -> bb3;
95 // _11 = const query() -> bb4;
98 // switchInt(_11) -> [0u8: bb6, otherwise: bb5];
103 // EndRegion('35_0rs);
111 // _14 = &'33s (_2.0: std::cell::Cell<std::option::Option<&'35_0rs S<'35_0rs>>>);
115 // _17 = &'35_0rs _2;
116 // _16 = &'35_0rs (*_17);
117 // _15 = std::option::Option<&'35_0rs S<'35_0rs>>::Some(_16,);
119 // _13 = const <std::cell::Cell<T>>::set(_14, _15) -> bb7;
127 // EndRegion('35_0rs);
132 // END rustc.node16.SimplifyCfg-qualify-consts.after.mir