]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoMake the epsilon note spanless
Marcin Serwin [Mon, 6 Apr 2020 13:29:54 +0000 (15:29 +0200)]
Make the epsilon note spanless

4 years agoSplit check_fn function
Marcin Serwin [Mon, 6 Apr 2020 07:40:53 +0000 (09:40 +0200)]
Split check_fn function

4 years agoIndicate when arrays are compared in error message
Marcin Serwin [Mon, 6 Apr 2020 07:06:50 +0000 (09:06 +0200)]
Indicate when arrays are compared in error message

4 years agoMake epsilon note spanless when comparing arrays
Marcin Serwin [Mon, 6 Apr 2020 06:56:22 +0000 (08:56 +0200)]
Make epsilon note spanless when comparing arrays

4 years agoAdd float cmp const tests for arrays
Marcin Serwin [Fri, 20 Mar 2020 10:54:04 +0000 (11:54 +0100)]
Add float cmp const tests for arrays

4 years agoAdd float cmp tests for arrays
Marcin Serwin [Fri, 20 Mar 2020 10:42:39 +0000 (11:42 +0100)]
Add float cmp tests for arrays

4 years agoHandle constant arrays with single value
Marcin Serwin [Fri, 20 Mar 2020 10:25:39 +0000 (11:25 +0100)]
Handle constant arrays with single value

4 years agoDon't show comparison suggestion for arrays
Marcin Serwin [Fri, 20 Mar 2020 09:51:48 +0000 (10:51 +0100)]
Don't show comparison suggestion for arrays

4 years agoAllow for const arrays of zeros
Marcin Serwin [Fri, 20 Mar 2020 09:40:44 +0000 (10:40 +0100)]
Allow for const arrays of zeros

4 years agoHandle evaluating constant index expression
Marcin Serwin [Thu, 19 Mar 2020 15:54:19 +0000 (16:54 +0100)]
Handle evaluating constant index expression

4 years agoAdd handling of float arrays to miri_to_const
Marcin Serwin [Thu, 19 Mar 2020 14:53:02 +0000 (15:53 +0100)]
Add handling of float arrays to miri_to_const

4 years agoUpdate stderr of float_cmp test
Marcin Serwin [Tue, 17 Mar 2020 09:32:20 +0000 (10:32 +0100)]
Update stderr of float_cmp test

4 years agoUpdate field names in is_float
Marcin Serwin [Tue, 17 Mar 2020 08:03:36 +0000 (09:03 +0100)]
Update field names in is_float

4 years agoAdd tests for float in array comparison
briankabiro [Thu, 19 Sep 2019 12:57:43 +0000 (15:57 +0300)]
Add tests for float in array comparison

4 years agoAdd lint when comparing floats in an array
briankabiro [Wed, 31 Jul 2019 11:52:12 +0000 (14:52 +0300)]
Add lint when comparing floats in an array

Finishes #4277

4 years agoAuto merge of #5411 - dtolnay:hasher, r=flip1995
bors [Wed, 8 Apr 2020 17:14:09 +0000 (17:14 +0000)]
Auto merge of #5411 - dtolnay:hasher, r=flip1995

Downgrade implicit_hasher to pedantic

From the [documentation](https://rust-lang.github.io/rust-clippy/master/index.html#implicit_hasher), this lint is intended to suggest:

```diff
- pub fn foo(map: &mut HashMap<i32, i32>) { }

+ pub fn foo<S: BuildHasher>(map: &mut HashMap<i32, i32, S>) { }
```

I think this is pedantic. I get that this lint can benefit core libraries like serde, but that's exactly the use case for pedantic lints; a library like serde will [enable clippy_pedantic](https://github.com/serde-rs/json/blob/fd6741f4b0b3fc90a58a6f578e33a9adc6403f3f/src/lib.rs#L304) and take the time to go through everything possible. Similar for libraries doing a libz blitz style checkup before committing to a 1.0 release; it would make sense to run through all the available pedantic lints then.

But otherwise, for most codebases and certainly for industrial codebases, the above suggested change just makes the codebase more obtuse for questionable benefit.

changelog: Remove implicit_hasher from default set of enabled lints

4 years agoAuto merge of #5437 - rabisg0:should-impl-trait, r=flip1995
bors [Wed, 8 Apr 2020 16:55:47 +0000 (16:55 +0000)]
Auto merge of #5437 - rabisg0:should-impl-trait, r=flip1995

Check fn header along with decl when suggesting to implement trait

When checking for functions that are potential candidates for trait
implementations check the function header to make sure modifiers like
asyncness, constness and safety match before triggering the lint.

Fixes #5413, #4290

changelog: check fn header along with decl for should_implement_trait

4 years agoAuto merge of #5428 - dtolnay:cognitive, r=flip1995
bors [Wed, 8 Apr 2020 16:38:00 +0000 (16:38 +0000)]
Auto merge of #5428 - dtolnay:cognitive, r=flip1995

Move cognitive_complexity to nursery

As discussed in https://github.com/rust-lang/rust-clippy/issues/5418#issuecomment-610054361; Clippy's current understanding of cognitive complexity is not good enough yet at analyzing code for understandability to have this lint be enabled by default.

changelog: Remove cognitive_complexity from default set of enabled lints

4 years agoCheck fn header along with decl when suggesting to implement trait
Rabi Guha [Wed, 8 Apr 2020 10:57:58 +0000 (16:27 +0530)]
Check fn header along with decl when suggesting to implement trait

When checking for functions that are potential candidates for trait
implementations check the function header to make sure modifiers like
asyncness, constness and safety match before triggering the lint.

Fixes #5413, #4290

4 years agoDowngrade implicit_hasher to pedantic
David Tolnay [Fri, 3 Apr 2020 02:09:30 +0000 (19:09 -0700)]
Downgrade implicit_hasher to pedantic

4 years agoMove cognitive_complexity to nursery
David Tolnay [Mon, 6 Apr 2020 22:46:40 +0000 (15:46 -0700)]
Move cognitive_complexity to nursery

4 years agoAuto merge of #5438 - flip1995:rollup-pi762oy, r=flip1995
bors [Wed, 8 Apr 2020 14:17:47 +0000 (14:17 +0000)]
Auto merge of #5438 - flip1995:rollup-pi762oy, r=flip1995

Rollup of 11 pull requests

Successful merges:

 - #5406 (Fix update_lints)
 - #5409 (Downgrade let_unit_value to pedantic)
 - #5410 (Downgrade trivially_copy_pass_by_ref to pedantic)
 - #5412 (Downgrade inefficient_to_string to pedantic)
 - #5415 (Add new lint for `Result<T, E>.map_or(None, Some(T))`)
 - #5417 (Update doc links and mentioned names in docs)
 - #5419 (Downgrade unreadable_literal to pedantic)
 - #5420 (Downgrade new_ret_no_self to pedantic)
 - #5422 (CONTRIBUTING.md: fix broken triage link)
 - #5424 (Incorrect suspicious_op_assign_impl)
 - #5425 (Ehance opt_as_ref_deref lint.)

Failed merges:

 - #5345 (Add lint for float in array comparison)
 - #5411 (Downgrade implicit_hasher to pedantic)
 - #5428 (Move cognitive_complexity to nursery)

r? @ghost

changelog: rollup

4 years agoRun fmt and update test
flip1995 [Wed, 8 Apr 2020 14:00:03 +0000 (16:00 +0200)]
Run fmt and update test

4 years agoRollup merge of #5425 - xiongmao86:issue5367, r=flip1995
Philipp Krones [Wed, 8 Apr 2020 13:50:28 +0000 (15:50 +0200)]
Rollup merge of #5425 - xiongmao86:issue5367, r=flip1995

Ehance opt_as_ref_deref lint.

- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Run `cargo dev fmt`

Lint on opt.as_ref().map(|x| &**x). Fixes #5367.

changelog: lint on opt.as_ref().map(|x| &**x)

4 years agoRollup merge of #5424 - jpospychala:suspicious_op_assign_impl, r=flip1995
Philipp Krones [Wed, 8 Apr 2020 13:50:26 +0000 (15:50 +0200)]
Rollup merge of #5424 - jpospychala:suspicious_op_assign_impl, r=flip1995

Incorrect suspicious_op_assign_impl

fixes #5255

changelog: In suspicious_op_assign_impl ignore all operators in expression if it's part of AssignOp

4 years agoRollup merge of #5422 - nickrtorres:contributing-triage, r=flip1995
Philipp Krones [Wed, 8 Apr 2020 13:50:25 +0000 (15:50 +0200)]
Rollup merge of #5422 - nickrtorres:contributing-triage, r=flip1995

CONTRIBUTING.md: fix broken triage link

Fixes #5421

4 years agoRollup merge of #5420 - dtolnay:newret, r=flip1995
Philipp Krones [Wed, 8 Apr 2020 13:50:24 +0000 (15:50 +0200)]
Rollup merge of #5420 - dtolnay:newret, r=flip1995

Downgrade new_ret_no_self to pedantic

As motivated by #5418. This is the second most widely suppressed Clippy style lint, and [this grep.app search](https://grep.app/search?q=%5C%5Ballow%5C%28.%2Aclippy%3A%3Anew_ret_no_self%5Cb&regexp=true&case=true&filter[lang][0]=Rust) shows a large number of diverse reasonable signatures for a `new` method.

changelog: Remove new_ret_no_self from default set of enabled lints

4 years agoRollup merge of #5419 - dtolnay:unreadable, r=flip1995
Philipp Krones [Wed, 8 Apr 2020 13:50:23 +0000 (15:50 +0200)]
Rollup merge of #5419 - dtolnay:unreadable, r=flip1995

Downgrade unreadable_literal to pedantic

As motivated by #5418. This is the top most commonly suppressed Clippy style lint, which indicates that the community has decided they don't share Clippy's opinion on the best style of this.

I've left the lint in as pedantic, though it could be that "restriction" would be better -- I can see this lint being useful as an opt-in restriction in some codebases.

changelog: Remove unreadable_literal from default set of enabled lints

4 years agoRollup merge of #5417 - flip1995:doc_update, r=flip1995
Philipp Krones [Wed, 8 Apr 2020 13:50:21 +0000 (15:50 +0200)]
Rollup merge of #5417 - flip1995:doc_update, r=flip1995

Update doc links and mentioned names in docs

changelog: none

4 years agoRollup merge of #5415 - nickrtorres:master, r=flip1995
Philipp Krones [Wed, 8 Apr 2020 13:50:20 +0000 (15:50 +0200)]
Rollup merge of #5415 - nickrtorres:master, r=flip1995

Add new lint for `Result<T, E>.map_or(None, Some(T))`

Fixes #5414

PR Checklist
---
- [x] Followed lint naming conventions (the name is a bit awkward, but it seems to conform)
- [x] Added passing UI tests (including committed .stderr file)
- [x] cargo test passes locally
- [x] Executed cargo dev update_lints
- [x] Added lint documentation
- [x] Run cargo dev fmt

`Result<T, E>` has an [`ok()`](https://doc.rust-lang.org/std/result/enum.Result.html#method.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)

4 years agoRollup merge of #5412 - dtolnay:tostring, r=flip1995
Philipp Krones [Wed, 8 Apr 2020 13:50:19 +0000 (15:50 +0200)]
Rollup merge of #5412 - dtolnay:tostring, r=flip1995

Downgrade inefficient_to_string to pedantic

From the [documentation](https://rust-lang.github.io/rust-clippy/master/index.html#inefficient_to_string):

> ```diff
> - ["foo", "bar"].iter().map(|s| s.to_string());
>
> + ["foo", "bar"].iter().map(|&s| s.to_string());
> ```

I feel like saving 10 nanoseconds from the formatting machinery isn't worth asking the programmer to insert extra `&` / `*` noise in the *vast* majority of cases. This is a pedantic lint.

changelog: Remove inefficient_to_string from default set of enabled lints

4 years agoRollup merge of #5410 - dtolnay:trivially, r=flip1995
Philipp Krones [Wed, 8 Apr 2020 13:50:17 +0000 (15:50 +0200)]
Rollup merge of #5410 - dtolnay:trivially, r=flip1995

Downgrade trivially_copy_pass_by_ref to pedantic

The rationale for this lint is documented as:

> In many calling conventions instances of structs will be passed through registers if they fit into two or less general purpose registers.

I think the purported performance benefits of clippy's recommendation are overstated. This isn't worth asking people to sprinkle code with more `*`​`*`​`&`​`*`​`&` to chase the alleged performance.

This should be a pedantic lint that is disabled by default and opted in if some specific performance sensitive codebase determines that it is worthwhile.

As a reminder, a typical place that a reference to a primitive would come up is if the function is used as a filter. Triggering a performance-oriented lint on this type of code is the definition of pedantic.

```rust
fn filter(_n: &i32) -> bool {
    true
}

fn main() {
    let v = vec![1, 2, 3];
    v.iter().copied().filter(filter).for_each(drop);
}
```

```console
warning: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
 --> src/main.rs:1:15
  |
1 | fn filter(_n: &i32) -> bool {
  |               ^^^^ help: consider passing by value instead: `i32`
```

changelog: Remove trivially_copy_pass_by_ref from default set of enabled lints

4 years agoRollup merge of #5409 - dtolnay:letunit, r=flip1995
Philipp Krones [Wed, 8 Apr 2020 13:50:16 +0000 (15:50 +0200)]
Rollup merge of #5409 - dtolnay:letunit, r=flip1995

Downgrade let_unit_value to pedantic

Given that the false positive in #1502 is marked E-hard and I don't have much hope of it getting fixed, I think it would be wise to disable this lint by default. I have had to suppress this lint in every substantial codebase (\>100k line) I have worked in. Any time this lint is being triggered, it's always the false positive case.

The motivation for this lint is documented as:

> A unit value cannot usefully be used anywhere. So binding one is kind of pointless.

with this example:

> ```rust
> let x = {
>     1;
> };
> ```

Sure, but the author would find this out via an unused_variable warning or from `x` not being the type that they need further down. If there ends up being a type error on `x`, clippy's advice isn't going to help get the code compiling because it can only run if the code already compiles.

changelog: Remove let_unit_value from default set of enabled lints

4 years agoRollup merge of #5406 - flip1995:update_lints_fix, r=flip1995
Philipp Krones [Wed, 8 Apr 2020 13:50:15 +0000 (15:50 +0200)]
Rollup merge of #5406 - flip1995:update_lints_fix, r=flip1995

Fix update_lints

This fixes a bug in update_lints, where `internal` lints were not registered properly. This also cleans up some code. For example: The code generation functions no longer filter the lints the are given. This is now the task of the caller. This way, it is more obvious in the `replace_in_file` calls which lints will be included in which part of a file.

This also turns the lint modules private. There is no need for them to be public, since shared code should be in the utils module anyway.

And last but not least, this fixes the `register_lints` code generation, so also internal lints get registered.

changelog: none

4 years agoAuto merge of #5429 - faern:use-assoc-int-float-consts, r=flip1995
bors [Wed, 8 Apr 2020 13:14:50 +0000 (13:14 +0000)]
Auto merge of #5429 - faern:use-assoc-int-float-consts, r=flip1995

Use assoc int and float consts instead of module level ones

changelog: Recommend primitive type associated constants instead of module level constants

In Rust 1.43 integer and float primitive types will have a number of new associated constants. For example `MAX`, `MIN` and a number of constants related to the machine representation of floats. https://github.com/rust-lang/rust/pull/68952

These new constants are preferred over the module level constants in `{core,std}::{f*, u*, i*}`. I have in the last few days made sure that the documentation in the main rust repository uses the new constants in every place I could find (https://github.com/rust-lang/rust/pull/69860, https://github.com/rust-lang/rust/pull/70782). So the next step is naturally to make the linter recommend the new constants as well.

This PR only changes two lints. There are more. But I did not want the PR to be too big. And since I have not contributed to clippy before it felt saner to start with a small PR so I see if there are any quirks. More will come later.

4 years agoUse int assoc consts in MANUAL_SATURATING_ARITHMETIC
Linus Färnstrand [Tue, 7 Apr 2020 22:24:18 +0000 (00:24 +0200)]
Use int assoc consts in MANUAL_SATURATING_ARITHMETIC

4 years agoUse int assoc consts in checked_conversions lint
Linus Färnstrand [Tue, 7 Apr 2020 22:22:42 +0000 (00:22 +0200)]
Use int assoc consts in checked_conversions lint

4 years agoUse primitive type assoc consts in more tests
Linus Färnstrand [Tue, 7 Apr 2020 22:04:33 +0000 (00:04 +0200)]
Use primitive type assoc consts in more tests

4 years agoUse integer assoc consts in more lint example code
Linus Färnstrand [Tue, 7 Apr 2020 22:01:27 +0000 (00:01 +0200)]
Use integer assoc consts in more lint example code

4 years agoDon't import primitive type modules
Linus Färnstrand [Tue, 7 Apr 2020 21:44:24 +0000 (23:44 +0200)]
Don't import primitive type modules

4 years agoUse assoc const NAN for zero_div_zero lint
Linus Färnstrand [Tue, 7 Apr 2020 21:41:00 +0000 (23:41 +0200)]
Use assoc const NAN for zero_div_zero lint

4 years agoFix float cmp to use assoc fxx::EPSILON
Linus Färnstrand [Mon, 6 Apr 2020 21:57:57 +0000 (23:57 +0200)]
Fix float cmp to use assoc fxx::EPSILON

4 years agoFix NAN comparison lint to use assoc NAN
Linus Färnstrand [Mon, 6 Apr 2020 21:53:11 +0000 (23:53 +0200)]
Fix NAN comparison lint to use assoc NAN

4 years agoMerge pull request #5434 from eddyb/rustup
Philipp Krones [Tue, 7 Apr 2020 20:40:18 +0000 (22:40 +0200)]
Merge pull request #5434 from eddyb/rustup

rustup: update for the new Ty::walk interface.

The first commit fixes a portability bug in `setup-toolchain.sh`, while the second rewrites the handling of "trait impl methods" in `use_self` - even if `Ty::walk` could've still been used, it was IMO a misuse.

This could also serve as a PSA: *please* use `hir_ty_to_ty` instead of trying to compare `hir::Ty`s between themselves or against semantic `Ty`s. Its "quasi-deprecation" is 3 years old and doesn't really mean anything, just that it's currently uncached and that we should eventually querify it (either for a single HIR node, or for all of the nodes in an entire definition).

---

changelog: none

4 years agoFormat clippy_lints/src/let_underscore.rs
Philipp Krones [Tue, 7 Apr 2020 20:19:20 +0000 (22:19 +0200)]
Format clippy_lints/src/let_underscore.rs

4 years agorustup: update for the new Ty::walk interface.
Eduard Burtescu [Tue, 7 Apr 2020 19:53:56 +0000 (19:53 +0000)]
rustup: update for the new Ty::walk interface.

4 years agouse_self: switch to hir_ty_to_ty.
Eduard Burtescu [Tue, 7 Apr 2020 19:53:02 +0000 (19:53 +0000)]
use_self: switch to hir_ty_to_ty.

4 years agoOnly /usr/bin/env is portable in shebangs.
Eduard Burtescu [Tue, 7 Apr 2020 19:51:59 +0000 (19:51 +0000)]
Only /usr/bin/env is portable in shebangs.

4 years agoRefine lint message.
xiongmao86 [Tue, 7 Apr 2020 13:25:07 +0000 (21:25 +0800)]
Refine lint message.

4 years agoLint on opt.as_ref().map(|x| &**x).
xiongmao86 [Mon, 6 Apr 2020 13:48:38 +0000 (21:48 +0800)]
Lint on opt.as_ref().map(|x| &**x).

4 years agoInclude OpAssign in suspicious_op_assign_impl
Jacek Pospychala [Sun, 5 Apr 2020 18:40:51 +0000 (20:40 +0200)]
Include OpAssign in suspicious_op_assign_impl

4 years agoresult_map_or_into_option: fix syntax error in example
Nick Torres [Sun, 5 Apr 2020 00:20:23 +0000 (17:20 -0700)]
result_map_or_into_option: fix syntax error in example

4 years agoresult_map_or_into: fix dogfood_clippy error => {h,l}int
Nick Torres [Sat, 4 Apr 2020 22:02:38 +0000 (15:02 -0700)]
result_map_or_into: fix dogfood_clippy error => {h,l}int

4 years agoCONTRIBUTING.md: fix broken triage link
Nick Torres [Sat, 4 Apr 2020 21:39:24 +0000 (14:39 -0700)]
CONTRIBUTING.md: fix broken triage link

4 years agoresult_map_or_into_option: fix `cargo dev fmt --check` errors
Nick Torres [Sat, 4 Apr 2020 21:33:43 +0000 (14:33 -0700)]
result_map_or_into_option: fix `cargo dev fmt --check` errors

4 years agoresult_map_or_into_option: move arg checks into tuple assignment
Nick Torres [Sat, 4 Apr 2020 21:24:22 +0000 (14:24 -0700)]
result_map_or_into_option: move arg checks into tuple assignment

4 years agoresult_map_or_into_option: add `opt.map_or(None, |_| Some(y))` test
Nick Torres [Sat, 4 Apr 2020 21:02:45 +0000 (14:02 -0700)]
result_map_or_into_option: add `opt.map_or(None, |_| Some(y))` test

4 years agoresult_map_or_into_option: destructure lint tuple or return early
Nick Torres [Sat, 4 Apr 2020 20:53:08 +0000 (13:53 -0700)]
result_map_or_into_option: destructure lint tuple or return early

4 years agoresult_map_or_into_option: add good and bad examples
Nick Torres [Sat, 4 Apr 2020 20:44:11 +0000 (13:44 -0700)]
result_map_or_into_option: add good and bad examples

4 years agoresult_map_or_into_option: explicitly note absence of known problems
Nick Torres [Sat, 4 Apr 2020 20:42:24 +0000 (13:42 -0700)]
result_map_or_into_option: explicitly note absence of known problems

4 years agoDowngrade new_ret_no_self to pedantic
David Tolnay [Sat, 4 Apr 2020 19:58:18 +0000 (12:58 -0700)]
Downgrade new_ret_no_self to pedantic

4 years agoDowngrade unreadable_literal to pedantic
David Tolnay [Sat, 4 Apr 2020 19:47:16 +0000 (12:47 -0700)]
Downgrade unreadable_literal to pedantic

4 years agoUpdate CONTRIBUTING.md
flip1995 [Sat, 4 Apr 2020 15:02:05 +0000 (17:02 +0200)]
Update CONTRIBUTING.md

4 years agoRename rustc -> rustc_middle in doc links
flip1995 [Sat, 4 Apr 2020 15:01:42 +0000 (17:01 +0200)]
Rename rustc -> rustc_middle in doc links

4 years agoresult_map_or_into_option: add lint to catch manually adpating Result -> Option
Nick Torres [Sat, 4 Apr 2020 06:59:52 +0000 (23:59 -0700)]
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)

4 years agoMove matches test in matches module
flip1995 [Fri, 3 Apr 2020 19:31:47 +0000 (21:31 +0200)]
Move matches test in matches module

4 years agoRun update_lints
flip1995 [Thu, 2 Apr 2020 20:08:25 +0000 (22:08 +0200)]
Run update_lints

4 years agoMake lint modules private
flip1995 [Thu, 2 Apr 2020 20:08:10 +0000 (22:08 +0200)]
Make lint modules private

4 years agoDon't filter lints in code generation functions
flip1995 [Thu, 2 Apr 2020 20:07:33 +0000 (22:07 +0200)]
Don't filter lints in code generation functions

4 years agoBuild lint lists once and the reuse them to update files
flip1995 [Thu, 2 Apr 2020 20:04:54 +0000 (22:04 +0200)]
Build lint lists once and the reuse them to update files

4 years agoGet rid of Lint::is_internal method
flip1995 [Thu, 2 Apr 2020 16:31:32 +0000 (18:31 +0200)]
Get rid of Lint::is_internal method

4 years agoClean up update_lints
flip1995 [Thu, 2 Apr 2020 16:20:23 +0000 (18:20 +0200)]
Clean up update_lints

4 years agoMerge pull request #5407 from flip1995/rustup
Manish Goregaokar [Fri, 3 Apr 2020 17:47:20 +0000 (10:47 -0700)]
Merge pull request #5407 from flip1995/rustup

Rustup to rust-lang/rust#70634

4 years agoDowngrade inefficient_to_string to pedantic
David Tolnay [Fri, 3 Apr 2020 03:00:12 +0000 (20:00 -0700)]
Downgrade inefficient_to_string to pedantic

4 years agoDowngrade trivially_copy_pass_by_ref to pedantic
David Tolnay [Fri, 3 Apr 2020 01:46:01 +0000 (18:46 -0700)]
Downgrade trivially_copy_pass_by_ref to pedantic

4 years agoDowngrade let_unit_value to pedantic
David Tolnay [Fri, 3 Apr 2020 01:22:18 +0000 (18:22 -0700)]
Downgrade let_unit_value to pedantic

4 years agoRustup to rust-lang/rust#70634
flip1995 [Thu, 2 Apr 2020 20:29:41 +0000 (22:29 +0200)]
Rustup to rust-lang/rust#70634

4 years agoAuto merge of #5403 - farnz:patch-1, r=flip1995
bors [Thu, 2 Apr 2020 13:39:30 +0000 (13:39 +0000)]
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

4 years agoUpdate clippy_lints/src/types.rs
Simon Farnsworth [Thu, 2 Apr 2020 13:30:13 +0000 (14:30 +0100)]
Update clippy_lints/src/types.rs

Co-Authored-By: Philipp Krones <hello@philkrones.com>
4 years agoUpdate types.rs
Simon Farnsworth [Thu, 2 Apr 2020 13:29:08 +0000 (14:29 +0100)]
Update types.rs

4 years agoUpdate types.rs
Simon Farnsworth [Thu, 2 Apr 2020 13:28:25 +0000 (14:28 +0100)]
Update types.rs

4 years agoImprove docs for option_option
Simon Farnsworth [Thu, 2 Apr 2020 09:03:15 +0000 (10:03 +0100)]
Improve docs for option_option

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

4 years agoAuto merge of #5349 - jpospychala:useless_rc, r=Manishearth
bors [Thu, 2 Apr 2020 03:11:29 +0000 (03:11 +0000)]
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.

4 years agouseless Rc<Rc<T>>, Rc<Box<T>>, Rc<&T>, Box<&T>
Jacek Pospychala [Thu, 12 Mar 2020 20:41:13 +0000 (21:41 +0100)]
useless Rc<Rc<T>>, Rc<Box<T>>, Rc<&T>, Box<&T>

4 years agoAuto merge of #5402 - pmk21:allow-let-underscore-must-use, r=flip1995
bors [Wed, 1 Apr 2020 21:43:44 +0000 (21:43 +0000)]
Auto merge of #5402 - pmk21:allow-let-underscore-must-use, r=flip1995

Allow let_underscore_must_use to be ignored

changelog: none
Fixes #5366

4 years agoAuto merge of #5401 - dtolnay:option, r=Manishearth
bors [Wed, 1 Apr 2020 21:30:24 +0000 (21:30 +0000)]
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

4 years agoAllow let_underscore
pmk21 [Wed, 1 Apr 2020 19:18:16 +0000 (00:48 +0530)]
Allow let_underscore

4 years agoUpdate option_option ui test
David Tolnay [Wed, 1 Apr 2020 19:15:21 +0000 (12:15 -0700)]
Update option_option ui test

4 years agoTest for ignoring let_underscore_must_use
pmk21 [Wed, 1 Apr 2020 19:14:09 +0000 (00:44 +0530)]
Test for ignoring let_underscore_must_use

4 years agoDowngrade option_option to pedantic
David Tolnay [Wed, 1 Apr 2020 19:00:49 +0000 (12:00 -0700)]
Downgrade option_option to pedantic

4 years agoAuto merge of #5400 - flip1995:rustup, r=Manishearth
bors [Wed, 1 Apr 2020 18:51:38 +0000 (18:51 +0000)]
Auto merge of #5400 - flip1995:rustup, r=Manishearth

Rustups

r? @Manishearth

changelog: none

4 years agoFix dogfood fallout
flip1995 [Wed, 1 Apr 2020 18:24:46 +0000 (20:24 +0200)]
Fix dogfood fallout

4 years agoRustup to rust-lang/rust#70632
flip1995 [Wed, 1 Apr 2020 18:14:05 +0000 (20:14 +0200)]
Rustup to rust-lang/rust#70632

4 years agoRustup to rust-lang/rust#70081
flip1995 [Wed, 1 Apr 2020 18:12:36 +0000 (20:12 +0200)]
Rustup to rust-lang/rust#70081

4 years agoRustup to rust-lang/rust#70627
flip1995 [Wed, 1 Apr 2020 17:42:15 +0000 (19:42 +0200)]
Rustup to rust-lang/rust#70627

4 years agoAuto merge of #5398 - flip1995:deescalate, r=Manishearth
bors [Tue, 31 Mar 2020 15:36:54 +0000 (15:36 +0000)]
Auto merge of #5398 - flip1995:deescalate, r=Manishearth

Stop updating the lint counter with every new lint

r? @Manishearth

This PR does two things:

1. Clean up the clippy_dev module a bit (first 3 commits; cc #5394 )
2. Make the counter in the README count in steps of 50 lints. Also use a `lazy_static` `Vec` for the lint list, so no counter is required there anymore.

changelog: none

4 years agoRun update_lints
flip1995 [Tue, 31 Mar 2020 15:23:30 +0000 (17:23 +0200)]
Run update_lints

4 years agoDon't use an exact lint counter anymore
flip1995 [Tue, 31 Mar 2020 15:23:14 +0000 (17:23 +0200)]
Don't use an exact lint counter anymore

4 years agoMove update_lints logic to its own module
flip1995 [Tue, 31 Mar 2020 13:14:29 +0000 (15:14 +0200)]
Move update_lints logic to its own module

4 years agoMake limit_stderr_length a subcommand
flip1995 [Tue, 31 Mar 2020 13:13:38 +0000 (15:13 +0200)]
Make limit_stderr_length a subcommand