Closed
Description
I wrote the following code in a small project to help assert constant integers are equivalent. There are other ways to write this test but this tells me the values on failure.
macro_rules! static_assert_ints_eq {
($a:expr, $b:expr) => {
// todo: enforce that args are reasonable integers
const _: [(); $a as usize] = [(); $b as usize];
};
}
Later, I called it in a manner where the values were equal but negative. They were the result of a const function, but something like this is equivalent:
static_assert_ints_eq!(-1i32, -1i32);
I expected this to be relatively cheap for rustc — I was hoping that the const _:
indicates that I'm just looking for a type check.
Unfortunately, I had to kill the compiler because it was taking too long. I imagine there's a bug somewhere for this but could not find it, but if not, this can be that bug.
Meta
rustc --version --verbose
:
rustc 1.49.0-nightly (38d911dfc 2020-10-09)
binary: rustc
commit-hash: 38d911dfc55a7a1eea1c80139113ed2ff0151087
commit-date: 2020-10-09
host: x86_64-apple-darwin
release: 1.49.0-nightly
LLVM version: 11.0