Skip to content

Commit d368d6b

Browse files
committed
---
yaml --- r: 3031 b: refs/heads/master c: e5eacf8 h: refs/heads/master i: 3029: 039590f 3027: dc85705 3023: 94c6d99 v: v3
1 parent ca8786b commit d368d6b

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: f1431adb404973f2f9dbce91b3c56893935df83b
2+
refs/heads/master: e5eacf8ea9e59777d6c7d4939d91d2e96dfff838

trunk/src/comp/middle/trans.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3286,6 +3286,7 @@ fn copy_val(&@block_ctxt cx,
32863286
ValueRef dst,
32873287
ValueRef src,
32883288
&ty::t t) -> result {
3289+
32893290
if (ty::type_is_scalar(cx.fcx.lcx.ccx.tcx, t) ||
32903291
ty::type_is_native(cx.fcx.lcx.ccx.tcx, t)) {
32913292
ret res(cx, cx.build.Store(src, dst));
@@ -6646,6 +6647,11 @@ fn init_local(&@block_ctxt cx, &@ast::local local) -> result {
66466647
case (some(?init)) {
66476648
alt (init.op) {
66486649
case (ast::init_assign) {
6650+
// Use the type of the RHS because if it's _|_, the LHS
6651+
// type might be something else, but we don't want to copy
6652+
// the value.
6653+
ty = node_ann_type(cx.fcx.lcx.ccx,
6654+
ty::expr_ann(init.expr));
66496655
auto sub = trans_expr(bcx, init.expr);
66506656
bcx = copy_val(sub.bcx, INIT, llptr, sub.val, ty).bcx;
66516657
}

trunk/src/test/run-fail/rhs-type.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Tests that trans treats the rhs of pth's decl
2+
// as a _|_-typed thing, not a str-typed thing
3+
// error-pattern:bye
4+
fn main() {
5+
auto pth = fail "bye";
6+
7+
let rec(str t) res = rec(t=pth);
8+
9+
}

0 commit comments

Comments
 (0)