Skip to content

Commit b3d3fbc

Browse files
committed
assert: Make use of asserts consistent
- Use debug asserts in code - Use normal asserts in tests - Use *assert_eq! methods when possible - Remove unnecessary asserts
1 parent d1a84db commit b3d3fbc

File tree

4 files changed

+2
-7
lines changed

4 files changed

+2
-7
lines changed

custom/stdweb/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#[cfg(not(all(target_arch = "wasm32", target_os = "unknown")))]
1111
compile_error!("This crate is only for the `wasm32-unknown-unknown` target");
1212

13-
use core::mem;
1413
use std::sync::Once;
1514

1615
use stdweb::js;
@@ -26,7 +25,6 @@ enum RngSource {
2625
register_custom_getrandom!(getrandom_inner);
2726

2827
fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
29-
assert_eq!(mem::size_of::<usize>(), 4);
3028
static ONCE: Once = Once::new();
3129
static mut RNG_SOURCE: Result<RngSource, Error> = Ok(RngSource::Node);
3230

custom/wasm-bindgen/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
compile_error!("This crate is only for the `wasm32-unknown-unknown` target");
1111

1212
use core::cell::RefCell;
13-
use core::mem;
1413
use std::thread_local;
1514

1615
use wasm_bindgen::prelude::*;
@@ -32,8 +31,6 @@ thread_local!(
3231
register_custom_getrandom!(getrandom_inner);
3332

3433
fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
35-
assert_eq!(mem::size_of::<usize>(), 4);
36-
3734
RNG_SOURCE.with(|f| {
3835
let mut source = f.borrow_mut();
3936
if source.is_none() {

src/use_file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ fn wait_until_rng_ready() -> Result<(), Error> {
9999
// A negative timeout means an infinite timeout.
100100
let res = unsafe { libc::poll(&mut pfd, 1, -1) };
101101
if res >= 0 {
102-
assert_eq!(res, 1); // We only used one fd, and cannot timeout.
102+
debug_assert_eq!(res, 1); // We only used one fd, and cannot timeout.
103103
return Ok(());
104104
}
105105
let err = crate::util_libc::last_os_error();

src/util_libc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ cfg_if! {
108108

109109
// SAFETY: path must be null terminated, FD must be manually closed.
110110
pub unsafe fn open_readonly(path: &str) -> Result<libc::c_int, Error> {
111-
debug_assert!(path.as_bytes().last() == Some(&0));
111+
debug_assert_eq!(path.as_bytes().last(), Some(&0));
112112
let fd = open(path.as_ptr() as *const _, libc::O_RDONLY | libc::O_CLOEXEC);
113113
if fd < 0 {
114114
return Err(last_os_error());

0 commit comments

Comments
 (0)