-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Do not report as_conversions for coercions #6428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The first example could be changed to use |
For the second example, there are some more complex cases where the compiler cannot infer it to be |
@SOF3 Could you confirm that you need a single lint that warns every uses of |
@rail-rain you mean separate lints such as |
oh yeah, I forgot those exist. should probably have used them instead. |
In that case, do you still need this issue? Otherwise, could you close the issue please? |
Thank you! |
Add a note to `as_conversions` I have seen a couple of examples where there are some misunderstandings of `as_conversions` ([1](#5890 (comment)), [2](#6116 (comment)) and [3](#6428)). This PR adds the note that explains its purpose and relationship with other `as` related casts. Open question: should I list every related lints for discoverbility, or just suggest how to find these? I chose the former because there's no way to list only and all `as` related lints (e.g. on All the Clippt Lints, 'cast' includes some noises, but `cast_` excludes some) even though I cannot guarantee the list will be updated to include future changes. --- changelog: Add a note to the document of `as_conversions`
The use of
as
is discouraged when it is semantically unclear, such as conversion between numeric types. However, when it is used as a coercion, there is no better concise way to indicate the desired semantics.For example, the following examples are legitimate:
I understand that
as_conversions
is set toallow
for these reasons. However, i wish to setwarn(as_conversions)
at the crate-level to prevent future contributors from adding numeric casts to my project. It would be helpful to have a variant ofas_conversions
only for non-coercing casts, in particular, numeric casts.The text was updated successfully, but these errors were encountered: