-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add new primitive_method_to_numeric_cast
lint
#13979
base: master
Are you sure you want to change the base?
Add new primitive_method_to_numeric_cast
lint
#13979
Conversation
// We get the type on which the `min`/`max` method of the `Ord` trait is implemented. | ||
&& let [ty] = generics.as_slice() | ||
&& let Some(ty) = ty.as_type() | ||
// We get its name in case it's a primitive with an associated MIN/MAx constant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
// We get its name in case it's a primitive with an associated MIN/MAx constant. | |
// We get its name in case it's a primitive with an associated MIN/MAX constant. |
use rustc_lint::LateContext; | ||
use rustc_middle::ty::{self, Ty}; | ||
|
||
use super::PRIMITIVE_METHOD_TO_NUMERIC_CAST; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there primitive methods only max, min
If so might make sense to specify them at lint name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or confusing_method_to_numeric_cast
?
Fixes #13973.
I don't think we can make
fn_to_numeric_cast_any
to be emitted in some special cases. Its category cannot be changed at runtime.I think in this case, the best might be a specialized new lint so we can target exactly what we want.
changelog: Add new
primitive_method_to_numeric_cast
lint