Closed
Description
I updated a dependency and the type of a struct field changed from an i32
to a u16
.
I am assigning a u16
value to this struct field. Before, I was calling i32::from
to convert the u16
to an i32
. With the upgrade this is unnecessary since the field and the value are both u16
.
The rust compiler suggests this fix:
error[E0308]: mismatched types
--> artichoke-frontend/src/parser.rs:90:37
|
90 | (*self.parser).lineno = i32::from((*self.context).lineno);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u16, found i32
help: you can convert an `i32` to `u16` and panic if the converted value wouldn't fit
|
90 | (*self.parser).lineno = i32::from((*self.context).lineno).try_into().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
error: Could not compile `artichoke-frontend`.
warning: build failed, waiting for other jobs to finish...
error: build failed
But it should really suggest removing the i32::from
and using the u16
directly.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Category: This is a bug.Category: An issue proposing an enhancement or a PR with one.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Medium priorityRelevant to the compiler team, which will review and decide on the PR/issue.