Commit graph

3662 commits

Author SHA1 Message Date
Linus Färnstrand
4726daad52 Use int assoc consts in checked_conversions lint 2020-04-08 00:43:27 +02:00
Linus Färnstrand
c2f67e1e19 Use integer assoc consts in more lint example code 2020-04-08 00:43:27 +02:00
Linus Färnstrand
518568ae0a Don't import primitive type modules 2020-04-08 00:43:27 +02:00
Linus Färnstrand
51bb1d28c5 Use assoc const NAN for zero_div_zero lint 2020-04-08 00:43:27 +02:00
Linus Färnstrand
645b62e436 Fix float cmp to use assoc fxx::EPSILON 2020-04-08 00:43:27 +02:00
Linus Färnstrand
0b4ee9a649 Fix NAN comparison lint to use assoc NAN 2020-04-08 00:43:27 +02:00
Philipp Krones
f5b6a0c54d
Format clippy_lints/src/let_underscore.rs 2020-04-07 22:19:20 +02:00
Eduard Burtescu
2ad4d6a057 rustup: update for the new Ty::walk interface. 2020-04-07 19:53:56 +00:00
Eduard Burtescu
89e14d201d use_self: switch to hir_ty_to_ty. 2020-04-07 19:53:02 +00:00
flip1995
98aa5938c4
Rustup to rust-lang/rust#70634 2020-04-02 22:29:41 +02:00
Simon Farnsworth
5f8b696e2e
Update clippy_lints/src/types.rs
Co-Authored-By: Philipp Krones <hello@philkrones.com>
2020-04-02 14:30:13 +01:00
Simon Farnsworth
50ecc12541
Update types.rs 2020-04-02 14:29:08 +01:00
Simon Farnsworth
f3f1babc1b
Update types.rs 2020-04-02 14:28:25 +01:00
Simon Farnsworth
db3423f46a
Improve docs for option_option
Hint about using tri-state enums to replace legitimate uses of `Option<Option<_>>`
2020-04-02 10:03:15 +01:00
bors
a840d594cc Auto merge of #5349 - jpospychala:useless_rc, r=Manishearth
useless Rc<Rc<T>>, Rc<Box<T>>, Rc<&T>, Box<&T>

refers to  #2394

changelog: Add lints for Rc<Rc<T>> and Rc<Box<T>> and Rc<&T>, Box<&T>

this is based on top of another change #5310 so probably should go after that one.
2020-04-02 03:11:29 +00:00
Jacek Pospychala
f8e892db5e useless Rc<Rc<T>>, Rc<Box<T>>, Rc<&T>, Box<&T> 2020-04-02 00:02:25 +02:00
bors
7ebb3aa55d Auto merge of #5402 - pmk21:allow-let-underscore-must-use, r=flip1995
Allow let_underscore_must_use to be ignored

changelog: none
Fixes #5366
2020-04-01 21:43:44 +00:00
bors
42796e11c5 Auto merge of #5401 - dtolnay:option, r=Manishearth
Downgrade option_option to pedantic

Based on a search of my work codebase (\>500k lines) for `Option<Option<`, it looks like a bunch of reasonable uses to me. The documented motivation for this lint is:

> an optional optional value is logically the same thing as an optional value but has an unneeded extra level of wrapping

which seems a bit bogus in practice. For example a typical usage would look like:

```rust
let mut host: Option<String> = None;
let mut port: Option<i32> = None;
let mut payload: Option<Option<String>> = None;

for each field {
    match field.name {
        "host" => host = Some(...),
        "port" => port = Some(...),
        "payload" => payload = Some(...), // can be null or string
        _ => return error,
    }
}

let host = host.ok_or(...)?;
let port = port.ok_or(...)?;
let payload = payload.ok_or(...)?;
do_thing(host, port, payload)
```

This lint seems to fit right in with the pedantic group; I don't think linting on occurrences of `Option<Option<T>>` by default is justified.

---

changelog: Remove option_option from default set of enabled lints
2020-04-01 21:30:24 +00:00
pmk21
c9978b69bd Allow let_underscore 2020-04-02 00:48:16 +05:30
David Tolnay
86b0dd4197
Downgrade option_option to pedantic 2020-04-01 12:00:49 -07:00
flip1995
fcc56fcd1b
Fix dogfood fallout 2020-04-01 20:24:46 +02:00
flip1995
7d58ba20b4
Rustup to rust-lang/rust#70632 2020-04-01 20:14:05 +02:00
flip1995
3142ee3f7a
Rustup to rust-lang/rust#70627 2020-04-01 19:42:15 +02:00
pmk21
4cac9786c5 Skip single_match lints in macro rules 2020-03-31 15:50:15 +05:30
bors
1cac2f9e86 Auto merge of #5293 - matthiaskrgr:macro_skip_lifetime, r=phansch
don't emit lifetime lint warnings for code inside macros.

Fixes #5283

changelog: Don't emit lifetime lint warnings for code inside macros.
2020-03-30 21:33:49 +00:00
Matthias Krüger
8e83afa61f don't emit lifetime lints for code inside macros.
Fixes #5283
2020-03-30 23:22:50 +02:00
bors
0a25944f78 Auto merge of #5294 - tmiasko:trait-ptr-cmp, r=Manishearth
Lint unnamed address comparisons

Functions and vtables have an insignificant address. Attempts to compare such addresses will lead to very surprising behaviour. For example: addresses of different functions could compare equal; two trait object pointers representing the same object and the same type could be unequal.

Lint against unnamed address comparisons to avoid issues like those in rust-lang/rust#69757 and rust-lang/rust#54685.

changelog: New lints: [`fn_address_comparisons`] [#5294](https://github.com/rust-lang/rust-clippy/pull/5294), [`vtable_address_comparisons`] [#5294](https://github.com/rust-lang/rust-clippy/pull/5294)
2020-03-30 19:52:41 +00:00
Tomasz Miąsko
b77b219280 Lint unnamed address comparisons 2020-03-30 21:42:16 +02:00
bors
42c36dc77b Auto merge of #5365 - mgr-inz-rafal:issue4983_bool_updates, r=yaahc
Issue4983 bool updates

changelog: Check for bool inequality comparison that might be written more concisely

Fixes #4983
2020-03-30 19:20:10 +00:00
Jane Lusby
c8f3241177
Update clippy_lints/src/needless_bool.rs 2020-03-30 12:19:30 -07:00
bors
563da5248d Auto merge of #5387 - jpospychala:useless_self_fp, r=yaahc
`unused_self` false positive

fixes #5351

Remove the for loop in `unused_self` so that lint enabled for one method doesn't trigger on another method.

changelog: Fix false positive in `unused_self` around lint gates on impl items
2020-03-30 18:10:21 +00:00
Matthias Krüger
aff57e0f43 rustup https://github.com/rust-lang/rust/pull/70536 2020-03-30 11:17:58 +02:00
bors
bfd11235a6 Auto merge of #5380 - lzutao:deprecate-REPLACE_CONSTS, r=phansch
Deprecate REPLACE_CONSTS lint

Closes #5346
changelog: Deprecate `replace_consts` lint
2020-03-30 08:03:42 +00:00
Philipp Hansch
68ed6ccf04
Rustup to https://github.com/rust-lang/rust/pull/70449 2020-03-30 07:34:19 +02:00
Jacek Pospychala
82f929cbaf unused_self false positive 2020-03-29 22:22:36 +02:00
Lzu Tao
d055b7d61c Deprecate REPLACE_CONSTS lint 2020-03-29 12:59:35 +07:00
bors
70b93aab6e Auto merge of #5376 - flip1995:verbose_file_reads_restriction, r=matthiaskrgr
Move verbose_file_reads to restriction

cc #5368

Using `File::read` instead of  `fs::read_to_end` does make sense in multiple cases, so this lint is rather restriction, than complexity

changelog: Move [`verbose_file_reads`] to restriction
2020-03-27 20:13:06 +00:00
Matthias Krüger
0982097e4d remove redundant import 2020-03-27 20:47:34 +01:00
Matthias Krüger
48da6e926c rustup https://github.com/rust-lang/rust/pull/68404 2020-03-27 20:41:53 +01:00
Matthias Krüger
6b1bad54ef rustup https://github.com/rust-lang/rust/pull/69644 2020-03-27 20:41:51 +01:00
Matthias Krüger
8177e49e10 rustup https://github.com/rust-lang/rust/pull/70344 2020-03-27 20:41:35 +01:00
flip1995
7a40b5c132
Move verbose_file_reads to restriction 2020-03-26 15:01:03 +01:00
Matthias Krüger
b86e8434df move redundant_pub_crate to nursery
cc #5369
2020-03-25 18:14:11 +01:00
Philipp Hansch
cec1e8f74e
Remove dependency on matches crate
The std equivalent works exactly the same.
2020-03-25 07:50:08 +01:00
bors
100a24d9d8 Auto merge of #5364 - flip1995:useless_transmute_quarantine, r=Manishearth
Move useless_transmute to nursery

cc #5343

@rust-lang/clippy anyone against moving this to nursery?

changelog: Move [`useless_transmute`] to nursery
2020-03-23 20:52:57 +00:00
bors
d3989eef2d Auto merge of #5319 - 1tgr:master, r=flip1995
Lint for `pub(crate)` items that are not crate visible due to the visibility of the module that contains them

changelog: Add `redundant_pub_crate` lint

Closes #5274.
2020-03-23 20:35:49 +00:00
mgr-inz-rafal
ff9602515e Code clean-up and formatting 2020-03-23 21:21:18 +01:00
mgr-inz-rafal
3d3af07845 Provide appropriate suggestion 2020-03-23 21:00:02 +01:00
flip1995
13fcee51e7
Move useless_transmute to nursery 2020-03-23 20:32:04 +01:00
mgr-inz-rafal
12796cd688 Initial lint without suggestion 2020-03-23 20:29:12 +01:00