I've come across some unexpected behavior of the compile-time integer div-by-zero check while writing a declarative macro. Invocations in the same compilation unit as the macro is declared behave as expected, compile-time constant expressions that would divide by zero at run-time are caught and compilation fails. However, when the macro is invoked in another compilation unit, the same expressions pass and go on to panic at run-time.
Is this expected behavior? I've examined the expansion in both cases and it is identical. So if not, I guess some compiler passes are being reordered or skipped?
Any advice greatly appreciated!
Playground: Rust Playground