You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 integersconst _:[(); $a asusize] = [(); $b asusize];};}
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.
Note: I'm aware of several other ways to write this that are better along various metrics — that's not my point. My point is that this way (which is somewhat common) does poorly.
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.
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:
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
:The text was updated successfully, but these errors were encountered: