Commit Graph

8286 Commits

Author SHA1 Message Date
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
Eduard Burtescu
18520aa8b2 Only /usr/bin/env is portable in shebangs. 2020-04-07 19:51:59 +00:00
xiongmao86
d7056f8ffb Refine lint message. 2020-04-07 21:25:07 +08:00
xiongmao86
4f14826e09 Lint on opt.as_ref().map(|x| &**x). 2020-04-06 22:53:59 +08:00
Jacek Pospychala
9c9af1d885 Include OpAssign in suspicious_op_assign_impl 2020-04-05 22:25:51 +02:00
Nick Torres
5d54fbb791 result_map_or_into_option: fix syntax error in example 2020-04-04 17:20:23 -07:00
Nick Torres
325d0b69d2 result_map_or_into: fix dogfood_clippy error => {h,l}int 2020-04-04 15:02:38 -07:00
Nick Torres
fecdb72b14 CONTRIBUTING.md: fix broken triage link 2020-04-04 14:39:24 -07:00
Nick Torres
2533f56a0e result_map_or_into_option: fix cargo dev fmt --check errors 2020-04-04 14:33:43 -07:00
Nick Torres
acc3bc1ba2 result_map_or_into_option: move arg checks into tuple assignment 2020-04-04 14:24:22 -07:00
Nick Torres
fb276dc3fa result_map_or_into_option: add opt.map_or(None, |_| Some(y)) test 2020-04-04 14:16:26 -07:00
Nick Torres
d0738bd673 result_map_or_into_option: destructure lint tuple or return early 2020-04-04 14:16:23 -07:00
Nick Torres
3a29aedf8d result_map_or_into_option: add good and bad examples 2020-04-04 14:16:18 -07:00
Nick Torres
91759a7582 result_map_or_into_option: explicitly note absence of known problems 2020-04-04 14:16:11 -07:00
David Tolnay
560c8c9c70
Downgrade new_ret_no_self to pedantic 2020-04-04 12:58:18 -07:00
David Tolnay
be34bc46ed
Downgrade unreadable_literal to pedantic 2020-04-04 12:52:03 -07:00
flip1995
fac5a41ca5
Update CONTRIBUTING.md 2020-04-04 17:03:07 +02:00
flip1995
2481d3c74a
Rename rustc -> rustc_middle in doc links 2020-04-04 17:01:42 +02:00
Nick Torres
91d8a804d3 result_map_or_into_option: add lint to catch manually adpating Result -> Option
Result<T, E> has an `ok()` method that adapts a Result<T,E> into an Option<T>.
It's possible to get around this adapter by writing Result<T,E>.map_or(None, Some).

This lint is implemented as a new variant of the existing
[`option_map_none` lint](https://github.com/rust-lang/rust-clippy/pull/2128)
2020-04-04 03:17:13 -07:00
flip1995
30503a91d2
Move matches test in matches module 2020-04-03 22:02:27 +02:00
flip1995
045722a17e
Run update_lints 2020-04-03 21:19:33 +02:00
flip1995
d89bb50f72
Make lint modules private 2020-04-03 21:19:33 +02:00
flip1995
a186d9fafd
Don't filter lints in code generation functions 2020-04-03 21:19:32 +02:00
flip1995
98c30fea8c
Build lint lists once and the reuse them to update files 2020-04-03 21:19:32 +02:00
flip1995
da679825e0
Get rid of Lint::is_internal method 2020-04-03 21:19:32 +02:00
flip1995
ffb2e41234
Clean up update_lints 2020-04-03 21:18:36 +02:00
Manish Goregaokar
7907abea27
Merge pull request #5407 from flip1995/rustup
Rustup to rust-lang/rust#70634
2020-04-03 10:47:20 -07:00
David Tolnay
e26ae7a0ff
Downgrade inefficient_to_string to pedantic 2020-04-02 20:00:12 -07:00
David Tolnay
94154cad20
Downgrade trivially_copy_pass_by_ref to pedantic 2020-04-02 18:56:10 -07:00
David Tolnay
adcaa1b86d
Downgrade let_unit_value to pedantic 2020-04-02 18:31:31 -07:00
flip1995
98aa5938c4
Rustup to rust-lang/rust#70634 2020-04-02 22:29:41 +02:00
bors
949a5bab33 Auto merge of #5403 - farnz:patch-1, r=flip1995
Improve docs for option_option

Hint about using tri-state enums to replace legitimate uses of `Option<Option<_>>`

changelog: The docs for `option_option` now suggest using a tri-state enum
2020-04-02 13:39:30 +00: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
f6e8da81f1
Update option_option ui test 2020-04-01 12:15:39 -07:00
pmk21
97acabe56a Test for ignoring let_underscore_must_use 2020-04-02 00:44:09 +05:30
David Tolnay
86b0dd4197
Downgrade option_option to pedantic 2020-04-01 12:00:49 -07:00
bors
326b22048a Auto merge of #5400 - flip1995:rustup, r=Manishearth
Rustups

r? @Manishearth

changelog: none
2020-04-01 18:51:38 +00: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
63987aafba
Rustup to rust-lang/rust#70081 2020-04-01 20:12:36 +02:00