transmute &[T]
to &[U]
may cause truncations for whole bit-pattern when size_of::<T>
> size_of::<U>
#10286
Labels
A-lint
Area: New lints
What it does
Consider following example:
but this is not true. This may be true (depending on architecture):
or this:
This is generic over both element type (in above example,
u32
andu8
).This can be rewritten as:
or
Lint Name
transmute_to_smaller_element_may_cause_truncation
Category
suspicious
Advantage
Drawbacks
Example
Could be written as:
or
The text was updated successfully, but these errors were encountered: