Skip to content

Commit

Permalink
Rollup merge of rust-lang#69810 - thekuom:test/67523-dynamic-semantic…
Browse files Browse the repository at this point in the history
…s-bindings-after-at, r=Centril

test(bindings_after_at): add dynamic drop tests for bindings_after_at

Fixes rust-lang#67523.
Working towards rust-lang#65490.
  • Loading branch information
Centril authored Mar 8, 2020
2 parents 17b7791 + 2e88bec commit 49c82d1
Showing 1 changed file with 48 additions and 0 deletions.
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));
}

0 comments on commit 49c82d1

Please sign in to comment.