Simplify code with const assert!.

The code that prevents compilation on systems where usize is larger than
u64 previously used a const index-out-of-bounds trick. That code can now
be replaced with assert!, as const panic! has landed in 1.57.0 stable.
This commit is contained in:
Tim Kuehn
2021-12-03 15:18:05 -08:00
parent 70493c15f4
commit eea38b8bf4

View File

@@ -81,14 +81,10 @@ impl<C, D> fmt::Debug for NewClient<C, D> {
}
}
#[allow(dead_code)]
#[allow(clippy::no_effect)]
const CHECK_USIZE: () = {
if std::mem::size_of::<usize>() > std::mem::size_of::<u64>() {
// TODO: replace this with panic!() as soon as RFC 2345 gets stabilized
["usize is too big to fit in u64"][42];
}
};
const _CHECK_USIZE: () = assert!(
std::mem::size_of::<usize>() <= std::mem::size_of::<u64>(),
"usize is too big to fit in u64"
);
/// Handles communication from the client to request dispatch.
#[derive(Debug)]