-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
run non-const Display/Debug impls for const panic message #86364
Copy link
Copy link
Open
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Given that the CTFE core engine already supports the entire display machinery (demonstrated by the fact that it works in Miri), we might
alternativelypoke a small hole into the const checks that allows executing formatting machinery frompanic_fmtonly -- something like "miri unleashed", but more targeted.Originally posted by @RalfJung in #78356 (comment)
Basically the same rationale as allowing -> _ return types in the parser, to get a better error later. In this case, when you use panic!() in CTFE, you are going to fail the build anyway, so we can just as well run something that may fail to get evaluated because it does something horribly unconst.
The only problem is that then const fn can execute non-const code at runtime during the panic machinery and before actually panicking, which may not be desirable.