-
Notifications
You must be signed in to change notification settings - Fork 2k
needless_type_cast is mixing up casts and coercions #16240
Copy link
Copy link
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
Type
Fields
Give feedbackNo fields configured for issues without a type.
Summary
needless_type_castis in some way mixing up casts and coercions. It is taking my completely-type-annotated code and proposing that I replace theaswith a type annotation, which then fails because coercions cannot perform numeric casts.Lint Name
needless_type_cast
Reproducer
I tried this code:
I saw this happen:
Applying the suggestion causes a compilation error since
usizedoes not coerce tou64.I believe that, instead, the lint should not fire at all in this case.
Version
Additional Labels
@rustbot label +I-suggestion-causes-error