|
22 | 22 | //@ [e2024] edition: 2024
|
23 | 23 |
|
24 | 24 | #![feature(super_let)]
|
| 25 | +#![allow(unused_braces)] |
25 | 26 |
|
26 | 27 | use std::cell::RefCell;
|
27 | 28 | use std::pin::pin;
|
28 | 29 |
|
| 30 | +fn f<T>(_: LogDrop<'_>, x: T) -> T { x } |
| 31 | + |
29 | 32 | fn main() {
|
30 | 33 | // Test block arguments to `pin!` in non-extending expressions.
|
31 | 34 | // In Rust 2021, block tail expressions aren't temporary drop scopes, so their temporaries
|
@@ -90,6 +93,73 @@ fn main() {
|
90 | 93 | let _ = { super let _ = { &o.log(2) as *const LogDrop<'_> }; };
|
91 | 94 | drop(o.log(1));
|
92 | 95 | });
|
| 96 | + |
| 97 | + // We have extending borrow expressions within an extending block |
| 98 | + // expression (within an extending borrow expression) within a |
| 99 | + // non-extending expresion within the initializer expression. |
| 100 | + #[cfg(e2021)] |
| 101 | + { |
| 102 | + // These two should be the same. |
| 103 | + assert_drop_order(1..=3, |e| { |
| 104 | + let _v = f(e.log(1), &{ &raw const *&e.log(2) }); |
| 105 | + drop(e.log(3)); |
| 106 | + }); |
| 107 | + assert_drop_order(1..=3, |e| { |
| 108 | + let _v = f(e.log(1), { |
| 109 | + super let v = &{ &raw const *&e.log(2) }; |
| 110 | + v |
| 111 | + }); |
| 112 | + drop(e.log(3)); |
| 113 | + }); |
| 114 | + } |
| 115 | + #[cfg(e2024)] |
| 116 | + { |
| 117 | + // These two should be the same. |
| 118 | + assert_drop_order(1..=3, |e| { |
| 119 | + let _v = f(e.log(2), &{ &raw const *&e.log(1) }); |
| 120 | + drop(e.log(3)); |
| 121 | + }); |
| 122 | + assert_drop_order(1..=3, |e| { |
| 123 | + let _v = f(e.log(2), { |
| 124 | + super let v = &{ &raw const *&e.log(1) }; |
| 125 | + v |
| 126 | + }); |
| 127 | + drop(e.log(3)); |
| 128 | + }); |
| 129 | + } |
| 130 | + |
| 131 | + // We have extending borrow expressions within a non-extending |
| 132 | + // expression within the initializer expression. |
| 133 | + // |
| 134 | + // These two should be the same. |
| 135 | + assert_drop_order(1..=3, |e| { |
| 136 | + let _v = f(e.log(1), &&raw const *&e.log(2)); |
| 137 | + drop(e.log(3)); |
| 138 | + }); |
| 139 | + assert_drop_order(1..=3, |e| { |
| 140 | + let _v = f(e.log(1), { |
| 141 | + super let v = &&raw const *&e.log(2); |
| 142 | + v |
| 143 | + }); |
| 144 | + drop(e.log(3)); |
| 145 | + }); |
| 146 | + |
| 147 | + // We have extending borrow expressions within an extending block |
| 148 | + // expression (within an extending borrow expression) within the |
| 149 | + // initializer expression. |
| 150 | + // |
| 151 | + // These two should be the same. |
| 152 | + assert_drop_order(1..=2, |e| { |
| 153 | + let _v = &{ &raw const *&e.log(2) }; |
| 154 | + drop(e.log(1)); |
| 155 | + }); |
| 156 | + assert_drop_order(1..=2, |e| { |
| 157 | + let _v = { |
| 158 | + super let v = &{ &raw const *&e.log(2) }; |
| 159 | + v |
| 160 | + }; |
| 161 | + drop(e.log(1)); |
| 162 | + }); |
93 | 163 | }
|
94 | 164 |
|
95 | 165 | // # Test scaffolding...
|
|
0 commit comments