-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Const-eval InterpError: error enum variants vs throw_ub_custom! #112618
Copy link
Copy link
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.T-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, ...)C-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.T-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.
Currently we have dedicated error variants for many interpreter errors in our
InterpErrorenum, but for some errors we usethrow_ub_custom!to directly pick a translatable diagnostic instead of a variant.The original purpose of these variants was to
The first point doesn't really apply any more with translatable diagnostics. And the overhead of these error variants is quite significant; they each need an arm in
diagnostic_messageandadd_args. (And these two things need to be carefully synced, sincediagnostic_messagedecides which arguments need to be added later! Would be nice if these could be syntactically together somehow. Right now not only are we using an entirely untyped system here without any checks whether the right arguments are being added, we also have setting the arguments quite far removed from the only place that could potentially tell us which arguments are the right ones. That's pretty bad for maintenance.) That makes it tempting to convert errors tothrow_ub_custom!and reduce this boilerplate, but I don't know if that is a good idea -- @fee1-dead suggested we should avoidthrow_ub_custom!.I also see some
throw_ub_custom!do expensive work on error creation (such as this), though under the hood the macro puts this into a thunk so -- if the error is never rendered, does theformat!ever happen?Either way, we should come up with some kind of consistent policy here. We have a lot of
throw_ub_custom!currently (34 to be precise), I don't quite see the point of turning them all into variants -- that would be a lot of work, for which gain?