Skip to content

Commit 878561c

Browse files
committed
---
yaml --- r: 3466 b: refs/heads/master c: 1ba8593 h: refs/heads/master v: v3
1 parent 03d9122 commit 878561c

File tree

7 files changed

+31
-7
lines changed

7 files changed

+31
-7
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: d4b5b48e0a738dcb1b3d76295b525cd9147f64cb
2+
refs/heads/master: 1ba85932b1e11ae9db0e64dad20cd076db17aa1c

trunk/src/comp/middle/trans.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6061,12 +6061,23 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) ->
60616061
ret trans_check_expr(cx, a, "Predicate");
60626062
}
60636063
case (ast::expr_check(ast::unchecked, ?a)) {
6064-
if (cx.fcx.lcx.ccx.sess.get_opts().check_claims) {
6065-
ret trans_check_expr(cx, a, "Claim");
6066-
}
6067-
else {
6068-
ret rslt(cx, C_nil());
6069-
}
6064+
/* Claims are turned on and off by a global variable
6065+
that the RTS sets. This case generates code to
6066+
check the value of that variable, doing nothing
6067+
if it's set to false and acting like a check
6068+
otherwise. */
6069+
auto c = get_extern_const(cx.fcx.lcx.ccx.externs,
6070+
cx.fcx.lcx.ccx.llmod,
6071+
"check_claims", T_bool());
6072+
auto cond = cx.build.Load(c);
6073+
6074+
auto then_cx = new_scope_block_ctxt(cx, "claim_then");
6075+
auto check_res = trans_check_expr(then_cx, a, "Claim");
6076+
auto else_cx = new_scope_block_ctxt(cx, "else");
6077+
auto els = rslt(else_cx, C_nil());
6078+
6079+
cx.build.CondBr(cond, then_cx.llbb, else_cx.llbb);
6080+
ret rslt(join_branches(cx, [check_res, els]), C_nil());
60706081
}
60716082
case (ast::expr_break) { ret trans_break(e.span, cx); }
60726083
case (ast::expr_cont) { ret trans_cont(e.span, cx); }

trunk/src/rt/rust.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,16 @@ int get_num_threads()
9191
* initialize the kernel, create the root domain and run it.
9292
*/
9393

94+
int check_claims = 0;
95+
96+
void enable_claims(void* ck) { check_claims = (ck != 0); }
97+
9498
extern "C" CDECL int
9599
rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
96100

97101
update_log_settings(crate_map, getenv("RUST_LOG"));
102+
enable_claims(getenv("CHECK_CLAIMS"));
103+
98104
rust_srv *srv = new rust_srv();
99105
rust_kernel *kernel = new rust_kernel(srv);
100106
kernel->start();

trunk/src/rt/rust.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#define FASTCALL
2121
#endif
2222

23+
/* Controls whether claims are turned into checks */
24+
/* Variable name must be kept consistent with trans.rs */
25+
extern "C" int check_claims;
26+
2327
/*
2428
* Local Variables:
2529
* fill-column: 78;

trunk/src/rt/rustrt.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
align_of
2+
check_claims
23
debug_box
34
debug_fn
45
debug_obj

trunk/src/test/run-fail/fn-constraint-claim.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// xfail-stage0
2+
// xfail-stage1
23
// error-pattern:quux
34
use std;
45
import std::str::*;

trunk/src/test/run-pass/claim-nonterm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// xfail-stage0
2+
// xfail-stage1
23
// tests that the pred in a claim isn't actually eval'd
34
use std;
45
import std::str::*;

0 commit comments

Comments
 (0)