external macros don't evaluate panicking consts when crate-local ones do. #61058
Labels
A-const-eval
Area: Constant evaluation, covers all const contexts (static, const fn, ...)
A-diagnostics
Area: Messages for errors, warnings, and lints
A-macros
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I have a proc macro crate which produces a panicking constant in its generate code.
For some reason the constant outputed by the proc-macro doesn't get evaluated in
cargo check
,even though it gets evaluated when the macro is manually expanded.This is the conversation that motivated me to write this issue:dtolnay/case-studies#6
I've put all the code in this repository.
All of these were tried using the current stable.
Commands to run:
With a proc macro
const_panic_proc_macro
crate:using_proc_macro
crate:The compiler detects no const errors,even though there is an out of bounds error in the constant.
Output:
Manually expanded version
Here is the manually expanded version of the macro (in the
manually_expanded
binary inusing_const_panic
):When compiled with
cargo check
outputs the out of bounds error.Output:
With macro_rules in the same crate
With a macro_rule declared in the
with_internal_macro_rules
binary inusing_const_panic
:When compiled with
cargo check
it produces the intended const error.Output:
With macro_rules from another crate
With a macro_rule declared in another crate:
macro_rules_panic
crate:with_external_macro_rules
binary inusing_const_panic
:This code
cargo check
s without errors,even though it has an out of bounds error in the constant.Output:
The text was updated successfully, but these errors were encountered: