Unexpected behavior of compile-time integer div-by-zero check in declarative macro

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

It doesn't look like this is getting much attention here. Is there a more appropriate venue for this discussion?

I don't believe div-by-zero is guaranteed to be caught at compile time. Cross-crate analysis tends to be an especially frequent source of such problems, exactly because modules are the fundamental unit of code organization. You might be able to go to IRLO as well if you are interested in compiler internals pertaining to this issue.