about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-02-16 09:58:49 +0000
committerbors <bors@rust-lang.org>2021-02-16 09:58:49 +0000
commite2753f9a7bcfcedaad7dcf78eba6ccfe14f2a3aa (patch)
treea8eff8d034fdb788f305cfd8136667a499d3f145 /src/test/codegen
parentf28c54cd08b02ba89648f80b67f512f878e9dce2 (diff)
parent9b0c1ebc183bbf0fab5fbbe5ac8b2f94e5e56b87 (diff)
downloadrust-e2753f9a7bcfcedaad7dcf78eba6ccfe14f2a3aa.tar.gz
rust-e2753f9a7bcfcedaad7dcf78eba6ccfe14f2a3aa.zip
Auto merge of #6662 - Y-Nak:default-numeric-fallback, r=flip1995
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`
Diffstat (limited to 'src/test/codegen')
0 files changed, 0 insertions, 0 deletions