Skip to content

Commit f0c43cf

Browse files
diannetraviscross
andcommitted
additional tests
Co-authored-by: Travis Cross <[email protected]>
1 parent 7ed01eb commit f0c43cf

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

tests/ui/drop/super-let-tail-expr-drop-order.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@
2222
//@ [e2024] edition: 2024
2323

2424
#![feature(super_let)]
25+
#![allow(unused_braces)]
2526

2627
use std::cell::RefCell;
2728
use std::pin::pin;
2829

30+
fn f<T>(_: LogDrop<'_>, x: T) -> T { x }
31+
2932
fn main() {
3033
// Test block arguments to `pin!` in non-extending expressions.
3134
// In Rust 2021, block tail expressions aren't temporary drop scopes, so their temporaries
@@ -90,6 +93,73 @@ fn main() {
9093
let _ = { super let _ = { &o.log(2) as *const LogDrop<'_> }; };
9194
drop(o.log(1));
9295
});
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 the initializer
132+
// 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+
});
93163
}
94164

95165
// # Test scaffolding...

0 commit comments

Comments
 (0)