Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions src/test/ui/drop/dynamic-drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#![feature(generators, generator_trait, untagged_unions)]
#![feature(move_ref_pattern)]
#![feature(bindings_after_at)]

#![allow(unused_assignments)]
#![allow(unused_variables)]
Expand Down Expand Up @@ -291,6 +292,44 @@ fn subslice_mixed_min_lengths(a: &Allocator, c: i32) {
}
}

fn bindings_after_at_dynamic_init_move(a: &Allocator, c: bool) {
let foo = if c { Some(a.alloc()) } else { None };
let _x;

if let bar @ Some(_) = foo {
_x = bar;
}
}

fn bindings_after_at_dynamic_init_ref(a: &Allocator, c: bool) {
let foo = if c { Some(a.alloc()) } else { None };
let _x;

if let bar @ Some(_baz) = &foo {
_x = bar;
}
}

fn bindings_after_at_dynamic_drop_move(a: &Allocator, c: bool) {
let foo = if c { Some(a.alloc()) } else { None };

if let bar @ Some(_) = foo {
bar
} else {
None
};
}

fn bindings_after_at_dynamic_drop_ref(a: &Allocator, c: bool) {
let foo = if c { Some(a.alloc()) } else { None };

if let bar @ Some(_baz) = &foo {
bar
} else {
&None
};
}

fn move_ref_pattern(a: &Allocator) {
let mut tup = (a.alloc(), a.alloc(), a.alloc(), a.alloc());
let (ref _a, ref mut _b, _c, mut _d) = tup;
Expand Down Expand Up @@ -471,5 +510,14 @@ fn main() {
run_test(|a| panic_after_init_temp(a));
run_test(|a| panic_after_init_by_loop(a));

run_test(|a| bindings_after_at_dynamic_init_move(a, true));
run_test(|a| bindings_after_at_dynamic_init_move(a, false));
run_test(|a| bindings_after_at_dynamic_init_ref(a, true));
run_test(|a| bindings_after_at_dynamic_init_ref(a, false));
run_test(|a| bindings_after_at_dynamic_drop_move(a, true));
run_test(|a| bindings_after_at_dynamic_drop_move(a, false));
run_test(|a| bindings_after_at_dynamic_drop_ref(a, true));
run_test(|a| bindings_after_at_dynamic_drop_ref(a, false));

run_test_nopanic(|a| union1(a));
}