diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2015-01-28 03:37:24 +0100 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2015-01-28 10:22:26 +0100 |
| commit | d85520202ab05f1d67da26e00905bf22c548b86f (patch) | |
| tree | 4483cabdf6c21310beff825a0a7a636d36f8fa1d /src/test | |
| parent | 5b66c6dfa4a6b258d83f8eaf566e53814c7f812e (diff) | |
| download | rust-d85520202ab05f1d67da26e00905bf22c548b86f.tar.gz rust-d85520202ab05f1d67da26e00905bf22c548b86f.zip | |
In unsize_unique_expr, do not convert scratch value to lvalue.
Fix the issue-20055-box-trait.rs test to actually test `Box<Trait>`. Fix #21695.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/run-pass/issue-20055-box-trait.rs | 24 | ||||
| -rw-r--r-- | src/test/run-pass/issue-20055-box-unsized-array.rs | 5 |
2 files changed, 21 insertions, 8 deletions
diff --git a/src/test/run-pass/issue-20055-box-trait.rs b/src/test/run-pass/issue-20055-box-trait.rs index fca63f91ca8..836e78b5b51 100644 --- a/src/test/run-pass/issue-20055-box-trait.rs +++ b/src/test/run-pass/issue-20055-box-trait.rs @@ -8,6 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// See Issues #20055 and #21695. + +// We are checking here that the temporaries `Box<[i8, k]>`, for `k` +// in 1, 2, 3, 4, that are induced by the match expression are +// properly handled, in that only *one* will be initialized by +// whichever arm is run, and subsequently dropped at the end of the +// statement surrounding the `match`. + trait Boo { } impl Boo for [i8; 1] { } @@ -16,12 +24,12 @@ impl Boo for [i8; 3] { } impl Boo for [i8; 4] { } pub fn foo(box_1: fn () -> Box<[i8; 1]>, - box_2: fn () -> Box<[i8; 20]>, - box_3: fn () -> Box<[i8; 300]>, - box_4: fn () -> Box<[i8; 4000]>, + box_2: fn () -> Box<[i8; 2]>, + box_3: fn () -> Box<[i8; 3]>, + box_4: fn () -> Box<[i8; 4]>, ) { println!("Hello World 1"); - let _: Box<[i8]> = match 3 { + let _: Box<Boo> = match 3 { 1 => box_1(), 2 => box_2(), 3 => box_3(), @@ -31,10 +39,10 @@ pub fn foo(box_1: fn () -> Box<[i8; 1]>, } pub fn main() { - fn box_1() -> Box<[i8; 1]> { Box::new( [1i8] ) } - fn box_2() -> Box<[i8; 20]> { Box::new( [1i8; 20] ) } - fn box_3() -> Box<[i8; 300]> { Box::new( [1i8; 300] ) } - fn box_4() -> Box<[i8; 4000]> { Box::new( [1i8; 4000] ) } + fn box_1() -> Box<[i8; 1]> { Box::new( [1i8; 1] ) } + fn box_2() -> Box<[i8; 2]> { Box::new( [1i8; 2] ) } + fn box_3() -> Box<[i8; 3]> { Box::new( [1i8; 3] ) } + fn box_4() -> Box<[i8; 4]> { Box::new( [1i8; 4] ) } foo(box_1, box_2, box_3, box_4); } diff --git a/src/test/run-pass/issue-20055-box-unsized-array.rs b/src/test/run-pass/issue-20055-box-unsized-array.rs index 2f3f737d1a7..f751be6f13b 100644 --- a/src/test/run-pass/issue-20055-box-unsized-array.rs +++ b/src/test/run-pass/issue-20055-box-unsized-array.rs @@ -8,6 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// Issue #2005: Check that boxed fixed-size arrays are properly +// accounted for (namely, only deallocated if they were actually +// created) when they appear as temporaries in unused arms of a match +// expression. + pub fn foo(box_1: fn () -> Box<[i8; 1]>, box_2: fn () -> Box<[i8; 20]>, box_3: fn () -> Box<[i8; 300]>, |
