mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-13 17:13:48 +00:00
e2753f9a7b
New lint: default_numeric_fallback fixes #6064 r? `@flip1995` As we discussed in [here](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Issue.20.236064/near/224647188) and [here](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Issue.20clippy.236064/near/224746333), I start implementing this lint from the strictest version. In this PR, I'll allow the below two cases to pass the lint to reduce FPs. 1. Appearances of unsuffixed numeric literals in `Local` if `Local` has a type annotation, for example: ```rust // Good. let x: i32 = 1; // Also good. let x: (i32, i32) = if cond { (1, 2) } else { (2, 3) }; ``` 2. Appearances of unsuffixed numeric literals in args of `Call` or `MethodCall` if corresponding arguments of their signature have concrete types, for example: ```rust fn foo_mono(x: i32) -> i32 { x } fn foo_poly<T>(t: T) -> t { t } // Good. let x = foo_mono(13); // Still bad. let x: i32 = foo_poly(13); ``` changelog: Added restriction lint: `default_numeric_fallback` |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |