Skip to content

Commit 5bdc2d6

Browse files
committed
---
yaml --- r: 178455 b: refs/heads/try c: d855202 h: refs/heads/master i: 178453: 2b5ac27 178451: 6b39bb3 178447: 4237ee7 v: v3
1 parent 84f120f commit 5bdc2d6

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 336c8d2e9c6b276b162bdb3edd43706372e6eddd
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 474b324eda10440d6568ef872a7307d38e7de95b
5-
refs/heads/try: 5b66c6dfa4a6b258d83f8eaf566e53814c7f812e
5+
refs/heads/try: d85520202ab05f1d67da26e00905bf22c548b86f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/librustc_trans/trans/expr.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,11 +475,6 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
475475
let info = unsized_info(bcx, k, expr.id, unboxed_ty, |t| ty::mk_uniq(tcx, t));
476476
Store(bcx, info, get_len(bcx, scratch.val));
477477

478-
let scratch = unpack_datum!(bcx,
479-
scratch.to_expr_datum().to_lvalue_datum(bcx,
480-
"fresh_uniq_fat_ptr",
481-
expr.id));
482-
483478
DatumBlock::new(bcx, scratch.to_expr_datum())
484479
}
485480
}

branches/try/src/test/run-pass/issue-20055-box-trait.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// See Issues #20055 and #21695.
12+
13+
// We are checking here that the temporaries `Box<[i8, k]>`, for `k`
14+
// in 1, 2, 3, 4, that are induced by the match expression are
15+
// properly handled, in that only *one* will be initialized by
16+
// whichever arm is run, and subsequently dropped at the end of the
17+
// statement surrounding the `match`.
18+
1119
trait Boo { }
1220

1321
impl Boo for [i8; 1] { }
@@ -16,12 +24,12 @@ impl Boo for [i8; 3] { }
1624
impl Boo for [i8; 4] { }
1725

1826
pub fn foo(box_1: fn () -> Box<[i8; 1]>,
19-
box_2: fn () -> Box<[i8; 20]>,
20-
box_3: fn () -> Box<[i8; 300]>,
21-
box_4: fn () -> Box<[i8; 4000]>,
27+
box_2: fn () -> Box<[i8; 2]>,
28+
box_3: fn () -> Box<[i8; 3]>,
29+
box_4: fn () -> Box<[i8; 4]>,
2230
) {
2331
println!("Hello World 1");
24-
let _: Box<[i8]> = match 3 {
32+
let _: Box<Boo> = match 3 {
2533
1 => box_1(),
2634
2 => box_2(),
2735
3 => box_3(),
@@ -31,10 +39,10 @@ pub fn foo(box_1: fn () -> Box<[i8; 1]>,
3139
}
3240

3341
pub fn main() {
34-
fn box_1() -> Box<[i8; 1]> { Box::new( [1i8] ) }
35-
fn box_2() -> Box<[i8; 20]> { Box::new( [1i8; 20] ) }
36-
fn box_3() -> Box<[i8; 300]> { Box::new( [1i8; 300] ) }
37-
fn box_4() -> Box<[i8; 4000]> { Box::new( [1i8; 4000] ) }
42+
fn box_1() -> Box<[i8; 1]> { Box::new( [1i8; 1] ) }
43+
fn box_2() -> Box<[i8; 2]> { Box::new( [1i8; 2] ) }
44+
fn box_3() -> Box<[i8; 3]> { Box::new( [1i8; 3] ) }
45+
fn box_4() -> Box<[i8; 4]> { Box::new( [1i8; 4] ) }
3846

3947
foo(box_1, box_2, box_3, box_4);
4048
}

branches/try/src/test/run-pass/issue-20055-box-unsized-array.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Issue #2005: Check that boxed fixed-size arrays are properly
12+
// accounted for (namely, only deallocated if they were actually
13+
// created) when they appear as temporaries in unused arms of a match
14+
// expression.
15+
1116
pub fn foo(box_1: fn () -> Box<[i8; 1]>,
1217
box_2: fn () -> Box<[i8; 20]>,
1318
box_3: fn () -> Box<[i8; 300]>,

0 commit comments

Comments
 (0)