2023-10-16 18:04:10 +00:00
|
|
|
// unit-test: ElaborateDrops
|
|
|
|
// needs-unwind
|
2017-11-26 18:39:16 +00:00
|
|
|
|
2023-02-27 13:07:44 +00:00
|
|
|
#![feature(rustc_attrs, stmt_expr_attributes)]
|
2017-08-14 11:10:05 +00:00
|
|
|
|
2023-10-16 18:04:10 +00:00
|
|
|
// EMIT_MIR box_expr.main.ElaborateDrops.diff
|
2017-08-14 11:10:05 +00:00
|
|
|
fn main() {
|
2023-10-16 18:04:10 +00:00
|
|
|
// CHECK-LABEL: fn main(
|
|
|
|
// CHECK: [[box:_.*]] = ShallowInitBox(
|
|
|
|
// CHECK: [[ptr:_.*]] = ((([[box]].0: std::ptr::Unique<S>).0: std::ptr::NonNull<S>).0: *const S);
|
|
|
|
// CHECK: (*[[ptr]]) = S::new() -> [return: [[ret:bb.*]], unwind: [[unwind:bb.*]]];
|
|
|
|
// CHECK: [[ret]]: {
|
|
|
|
// CHECK: [[box2:_.*]] = move [[box]];
|
|
|
|
// CHECK: [[box3:_.*]] = move [[box2]];
|
|
|
|
// CHECK: std::mem::drop::<Box<S>>(move [[box3]])
|
|
|
|
// CHECK: [[unwind]] (cleanup): {
|
|
|
|
// CHECK: [[boxref:_.*]] = &mut [[box]];
|
|
|
|
// CHECK: <Box<S> as Drop>::drop(move [[boxref]])
|
|
|
|
|
2023-02-27 13:07:44 +00:00
|
|
|
let x = #[rustc_box]
|
|
|
|
Box::new(S::new());
|
2017-08-14 11:10:05 +00:00
|
|
|
drop(x);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct S;
|
|
|
|
|
|
|
|
impl S {
|
2023-02-27 13:07:44 +00:00
|
|
|
fn new() -> Self {
|
|
|
|
S
|
|
|
|
}
|
2017-08-14 11:10:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Drop for S {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
println!("splat!");
|
|
|
|
}
|
|
|
|
}
|