Skip to content

Commit ec9c4fd

Browse files
committed
Merge remote branch 'upstream/master'
2 parents e6f87a7 + 14258b8 commit ec9c4fd

23 files changed

+50
-47
lines changed

src/comp/middle/trans.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2274,6 +2274,31 @@ fn make_free_glue(&@block_ctxt cx, ValueRef v0, &ty::t t) {
22742274
rslt.bcx.build.RetVoid();
22752275
}
22762276

2277+
fn maybe_free_ivec_heap_part(&@block_ctxt cx, ValueRef v0, ty::t unit_ty)
2278+
-> result {
2279+
auto llunitty = type_of_or_i8(cx, unit_ty);
2280+
2281+
auto stack_len = cx.build.Load(cx.build.InBoundsGEP(v0, [C_int(0),
2282+
C_uint(abi::ivec_elt_len)]));
2283+
auto maybe_on_heap_cx = new_sub_block_ctxt(cx, "maybe_on_heap");
2284+
auto next_cx = new_sub_block_ctxt(cx, "next");
2285+
auto maybe_on_heap = cx.build.ICmp(lib::llvm::LLVMIntEQ, stack_len,
2286+
C_int(0));
2287+
cx.build.CondBr(maybe_on_heap, maybe_on_heap_cx.llbb, next_cx.llbb);
2288+
2289+
// Might be on the heap. Load the heap pointer and free it. (It's ok to
2290+
// free a null pointer.)
2291+
auto stub_ptr = maybe_on_heap_cx.build.PointerCast(v0,
2292+
T_ptr(T_ivec_heap(llunitty)));
2293+
auto heap_ptr = maybe_on_heap_cx.build.Load(
2294+
maybe_on_heap_cx.build.InBoundsGEP(stub_ptr,
2295+
[C_int(0), C_uint(abi::ivec_heap_stub_elt_ptr)]));
2296+
auto after_free_cx = trans_non_gc_free(maybe_on_heap_cx, heap_ptr).bcx;
2297+
after_free_cx.build.Br(next_cx.llbb);
2298+
2299+
ret res(next_cx, C_nil());
2300+
}
2301+
22772302
fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty::t t) {
22782303
// NB: v0 is an *alias* of type t here, not a direct value.
22792304
auto rslt;
@@ -2286,6 +2311,11 @@ fn make_drop_glue(&@block_ctxt cx, ValueRef v0, &ty::t t) {
22862311
rslt = decr_refcnt_maybe_free(cx, v0, v0, t);
22872312
}
22882313

2314+
case (ty::ty_ivec(?tm)) {
2315+
rslt = iter_structural_ty(cx, v0, t, drop_ty);
2316+
rslt = maybe_free_ivec_heap_part(rslt.bcx, v0, tm.ty);
2317+
}
2318+
22892319
case (ty::ty_box(_)) {
22902320
rslt = decr_refcnt_maybe_free(cx, v0, v0, t);
22912321
}
@@ -5885,7 +5915,7 @@ fn trans_ivec(@block_ctxt bcx, &vec[@ast::expr] args, &ast::ann ann)
58855915
llfirsteltptr = C_null(T_ptr(llunitty));
58865916
} else {
58875917
auto llheapsz = bcx.build.Add(llsize_of(llheapty), lllen);
5888-
rslt = trans_raw_malloc(bcx, llheapty, llheapsz);
5918+
rslt = trans_raw_malloc(bcx, T_ptr(llheapty), llheapsz);
58895919
bcx = rslt.bcx;
58905920
auto llheapptr = rslt.val;
58915921

src/comp/middle/typeck.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,17 @@ mod collect {
527527
fn ty_of_arg(@ctxt cx, &ast::arg a) -> ty::arg {
528528
auto ty_mode = ast_mode_to_mode(a.mode);
529529
auto f = bind getter(cx, _);
530-
ret rec(mode=ty_mode, ty=ast_ty_to_ty(cx.tcx, f, a.ty));
530+
auto tt = ast_ty_to_ty(cx.tcx, f, a.ty);
531+
if (ty::type_has_dynamic_size(cx.tcx, tt)) {
532+
alt (ty_mode) {
533+
case (mo_val) {
534+
cx.tcx.sess.span_err(a.ty.span,
535+
"Dynamically sized arguments must be passed by alias");
536+
}
537+
case (_) { }
538+
}
539+
}
540+
ret rec(mode=ty_mode, ty=tt);
531541
}
532542

533543
fn ty_of_method(@ctxt cx, &@ast::method m) -> ty::method {

src/test/compile-fail/aliasness-mismatch.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// -*- rust -*-
2-
// xfail-stage0
3-
42
// error-pattern: mismatched types
53

64
fn f(&int x) { log_err x; }

src/test/compile-fail/bad-bang-ann-2.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// -*- rust -*-
2-
// xfail-stage0
32
// Tests that a function with a ! annotation always actually fails
43
// error-pattern: some control paths may return
54

src/test/compile-fail/bad-bang-ann-3.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// -*- rust -*-
2-
// xfail-stage0
32
// Tests that a function with a ! annotation always actually fails
43
// error-pattern: some control paths may return
54

src/test/compile-fail/bad-bang-ann.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// -*- rust -*-
2-
// xfail-stage0
32
// Tests that a function with a ! annotation always actually fails
43
// error-pattern: may return to the caller
54

src/test/compile-fail/bad-expr-path2.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// xfail-stage0
21
// error-pattern: unresolved name: a
32

43
mod m1 {

src/test/compile-fail/bad-module.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// xfail-stage0
21
// error-pattern: unresolved import: vec
32
import vec;
43

src/test/compile-fail/bad-name.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// xfail-stage0
2-
// xfail-stage1
3-
// xfail-stage2
4-
51
// error-pattern: expecting
62

73
fn main() {

src/test/compile-fail/constructor-as-cast.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
// xfail-stage0
2-
// xfail-stage1
3-
// xfail-stage2
4-
// error-pattern: non-type context
1+
// error-pattern: unresolved name: base
52
type base =
63
obj {
74
fn foo();

src/test/compile-fail/direct-obj-fn-call.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
// xfail-stage0
2-
// xfail-stage1
3-
// xfail-stage2
4-
5-
// error-pattern: is not a mod
1+
// error-pattern: base type for expr_field
62

73
obj x() {
84
fn hello() {

src/test/compile-fail/does-nothing.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
// xfail-stage0
2-
// xfail-stage1
3-
// xfail-stage2
4-
// error-pattern: does nothing
1+
// error-pattern: unresolved name: this_does_nothing_what_the
52
fn main() {
63
log "doing";
74
this_does_nothing_what_the;

src/test/compile-fail/duplicate-name.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// xfail-stage0
2-
31
// error-pattern: duplicate value name: x
42

53
fn main() {

src/test/compile-fail/export-import.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// xfail-stage0
21
// error-pattern: unresolved import
32

43
import m::unexported;

src/test/compile-fail/extfmt-no-args.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// xfail-stage0
21
// error-pattern:format string
32

43
fn main() {

src/test/compile-fail/for-loop-decl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn bitv_to_str(fn_info enclosing, bitv::t v) -> str {
1212
// error is that the value type in the hash map is var_info, not a tuple
1313
for each (@tup(uint, tup(uint, uint)) p in enclosing.vars.items()) {
1414
if (bitv::get(v, p._1._0)) {
15-
s += "foo"; // " " + p._1._1 + " " + "[" + p._0 + "]";
15+
s += "foo";
1616
}
1717
}
1818
ret s;

src/test/compile-fail/import.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// xfail-stage0
21
// error-pattern: unresolved import: baz
32
import zed::bar;
43
import zed::baz;

src/test/compile-fail/import3.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// xfail-stage0
21
// error-pattern: unresolved modulename
32
import main::bar;
43

src/test/compile-fail/infinite-vec-type-recursion.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
// xfail-stage0
2-
// xfail-stage1
3-
// xfail-stage2
41
// -*- rust -*-
5-
6-
// error-pattern: infinite recursive type definition
2+
// xfail-stage0
3+
// error-pattern: illegal recursive type
74

85
type x = vec[x];
96

src/test/compile-fail/item-name-overload.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
// xfail-stage0
2-
// xfail-stage1
3-
// xfail-stage2
41
// -*- rust -*-
5-
6-
// error-pattern: name
2+
// xfail-stage0
3+
// error-pattern: Dynamically sized arguments must be passed by alias
74

85
mod foo {
96
fn bar[T](T f) -> int { ret 17; }

src/test/compile-fail/missing-return.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// xfail-stage0
21
// error-pattern: return
32

43
fn f() -> int {

src/test/compile-fail/missing-return2.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// xfail-stage0
21
// error-pattern: return
32

43
fn f() -> int {

src/test/compile-fail/vector-no-ann.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// xfail-stage0
2-
31
// error-pattern:cannot determine a type
42
fn main() -> () {
53
auto foo = [];

0 commit comments

Comments
 (0)