Error when autoderef of smart pointer occurs in const fn
is unclear
#91496
Labels
A-const-fn
Area: const fn foo(..) {..}. Pure functions which can be applied at compile time.
A-diagnostics
Area: Messages for errors, warnings, and lints
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
D-newcomer-roadblock
Diagnostics: Confusing error or lint; hard to understand for new users.
D-terse
Diagnostics: An error or lint that doesn't give enough information about the problem at hand.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given the following code:
The current output is:
It's unclear from the diagnostic that the problem is not the call of
foo
itself (which is aconst fn
) but thatSmartPointer
would have to be dereferenced.Ideally the output should look like:
Perhaps more generally, the compiler should avoid referring to non-intrinsic operators as "calls" in const errors, or explain that it means calling the operator method. This is usually less of a problem because an operator appears in the span.
@rustbot label A-const-fn
The text was updated successfully, but these errors were encountered: