mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 18:53:39 +00:00
Add a runtime flag to enable/disable claims en masse
Now, if the environment variable CHECK_CLAIMS is set, then all claims turn into checks. Otherwise, claims are no-ops.
This commit is contained in:
parent
d4b5b48e0a
commit
1ba85932b1
@ -6061,12 +6061,23 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) ->
|
||||
ret trans_check_expr(cx, a, "Predicate");
|
||||
}
|
||||
case (ast::expr_check(ast::unchecked, ?a)) {
|
||||
if (cx.fcx.lcx.ccx.sess.get_opts().check_claims) {
|
||||
ret trans_check_expr(cx, a, "Claim");
|
||||
}
|
||||
else {
|
||||
ret rslt(cx, C_nil());
|
||||
}
|
||||
/* Claims are turned on and off by a global variable
|
||||
that the RTS sets. This case generates code to
|
||||
check the value of that variable, doing nothing
|
||||
if it's set to false and acting like a check
|
||||
otherwise. */
|
||||
auto c = get_extern_const(cx.fcx.lcx.ccx.externs,
|
||||
cx.fcx.lcx.ccx.llmod,
|
||||
"check_claims", T_bool());
|
||||
auto cond = cx.build.Load(c);
|
||||
|
||||
auto then_cx = new_scope_block_ctxt(cx, "claim_then");
|
||||
auto check_res = trans_check_expr(then_cx, a, "Claim");
|
||||
auto else_cx = new_scope_block_ctxt(cx, "else");
|
||||
auto els = rslt(else_cx, C_nil());
|
||||
|
||||
cx.build.CondBr(cond, then_cx.llbb, else_cx.llbb);
|
||||
ret rslt(join_branches(cx, [check_res, els]), C_nil());
|
||||
}
|
||||
case (ast::expr_break) { ret trans_break(e.span, cx); }
|
||||
case (ast::expr_cont) { ret trans_cont(e.span, cx); }
|
||||
|
@ -91,10 +91,16 @@ int get_num_threads()
|
||||
* initialize the kernel, create the root domain and run it.
|
||||
*/
|
||||
|
||||
int check_claims = 0;
|
||||
|
||||
void enable_claims(void* ck) { check_claims = (ck != 0); }
|
||||
|
||||
extern "C" CDECL int
|
||||
rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
|
||||
|
||||
update_log_settings(crate_map, getenv("RUST_LOG"));
|
||||
enable_claims(getenv("CHECK_CLAIMS"));
|
||||
|
||||
rust_srv *srv = new rust_srv();
|
||||
rust_kernel *kernel = new rust_kernel(srv);
|
||||
kernel->start();
|
||||
|
@ -20,6 +20,10 @@
|
||||
#define FASTCALL
|
||||
#endif
|
||||
|
||||
/* Controls whether claims are turned into checks */
|
||||
/* Variable name must be kept consistent with trans.rs */
|
||||
extern "C" int check_claims;
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* fill-column: 78;
|
||||
|
@ -1,4 +1,5 @@
|
||||
align_of
|
||||
check_claims
|
||||
debug_box
|
||||
debug_fn
|
||||
debug_obj
|
||||
|
@ -1,4 +1,5 @@
|
||||
// xfail-stage0
|
||||
// xfail-stage1
|
||||
// error-pattern:quux
|
||||
use std;
|
||||
import std::str::*;
|
||||
|
@ -1,4 +1,5 @@
|
||||
// xfail-stage0
|
||||
// xfail-stage1
|
||||
// tests that the pred in a claim isn't actually eval'd
|
||||
use std;
|
||||
import std::str::*;
|
||||
|
Loading…
Reference in New Issue
Block a user