From aa25f22f197682de3b18fc4c8ba068d1feda220f Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Mon, 2 May 2011 11:23:07 -0700 Subject: Use different syntax for checks that matter to typestate This giant commit changes the syntax of Rust to use "assert" for "check" expressions that didn't mean anything to the typestate system, and continue using "check" for checks that are used as part of typestate checking. Most of the changes are just replacing "check" with "assert" in test cases and rustc. --- src/lib/sha1.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/lib/sha1.rs') diff --git a/src/lib/sha1.rs b/src/lib/sha1.rs index 3866be1e..690489db 100644 --- a/src/lib/sha1.rs +++ b/src/lib/sha1.rs @@ -43,7 +43,7 @@ fn mk_sha1() -> sha1 { fn add_input(&sha1state st, &vec[u8] msg) { // FIXME: Should be typestate precondition - check (!st.computed); + assert (!st.computed); for (u8 element in msg) { st.msg_block.(st.msg_block_idx) = element; @@ -67,7 +67,7 @@ fn mk_sha1() -> sha1 { fn process_msg_block(&sha1state st) { // FIXME: Make precondition - check (_vec.len[mutable u32](st.h) == digest_buf_len); + assert (_vec.len[mutable u32](st.h) == digest_buf_len); // Constants auto k = vec(0x5A827999u32, @@ -192,7 +192,7 @@ fn mk_sha1() -> sha1 { */ fn pad_msg(&sha1state st) { // FIXME: Should be a precondition - check (_vec.len[mutable u8](st.msg_block) == msg_block_len); + assert (_vec.len[mutable u8](st.msg_block) == msg_block_len); /* * Check to see if the current message block is too small to hold @@ -236,7 +236,7 @@ fn mk_sha1() -> sha1 { fn reset() { // FIXME: Should be typestate precondition - check (_vec.len[mutable u32](st.h) == digest_buf_len); + assert (_vec.len[mutable u32](st.h) == digest_buf_len); st.len_low = 0u32; st.len_high = 0u32; -- cgit v1.2.3