Post #2272213
2026-04-20 11:20 UTC
First one is kinda small and simple **Trivial_Casts** 🔢➡️🔟
> The trivial_casts lint in Rust is designed to catch what the Rust compiler considers to be "obviously unnecessary" type casts. These casts are often a result of typos or misunderstandings of how types work in Rust, and they can lead to unexpected behavior if not caught early on.
When you cast one type to another, the compiler will automatically perform certain "trivial" casts that are considered safe and obvious. However, it might also flag cases where the cast is unnecessary because Rust can infer the correct type without any issues. These flagged cases are what the trivial_casts lint is designed to catch.
Example:
```rust
let square = Square([2; 8]);
let square = &square as □
```
#lotw
Replies (1)
-
@EndlessMason@hachyderm.io 2026-04-20 12:14
@bshn@hachyderm.io > automatically perform certain "trivial" casts that are considered safe and obvious. > unexpected behavior if not caught early on. How can both of these be true at the same time? Surely the compiler isn't doing unsafe/unexpected things automatically