]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoAuto merge of #6451 - giraffate:update_contributing_md, r=llogiq
bors [Mon, 14 Dec 2020 06:13:44 +0000 (06:13 +0000)]
Auto merge of #6451 - giraffate:update_contributing_md, r=llogiq

Fix links in CONTRIBUTING.md

Links is broken.

<img width="1219" alt="スクリーンショット 2020-12-14 11 58 19" src="https://user-images.githubusercontent.com/17407489/102035564-fc152400-3e03-11eb-91a7-6c04e120d72f.png">

changelog: none

3 years agoFix links in CONTRIBUTING.md
Takayuki Nakata [Mon, 14 Dec 2020 02:57:35 +0000 (11:57 +0900)]
Fix links in CONTRIBUTING.md

3 years agoAuto merge of #6435 - xFrednet:5552-false-positive-match-single-binding, r=ebroto
bors [Sun, 13 Dec 2020 21:28:38 +0000 (21:28 +0000)]
Auto merge of #6435 - xFrednet:5552-false-positive-match-single-binding, r=ebroto

Fixing a false positive for the `match_single_binding` lint #5552

This is a fix for a false positive in the `match_single_binding` lint when using `#[cfg()]` on a branch. It is sadly a bit hacky but maybe the best solution as rust removes the other branch from the AST before we can even validate it. This fix looks at the code snippet itself and returns if it includes another thick arrow `=>` besides the one matching arm we found. This can again cause false negatives if someone has the following code:
```rust
match x {
    // => <-- Causes a false negative
    _ => 1,
}
```

I thought about making the code more complex and maybe validating against other things like the `#[cfg()]` macro but I believe that this is the best solution. This has basically switched the issue from a false positive to a false negative in a very specific case.

I'm happy to make some changes if you have any suggestions 🙃.

---
Fixes #5552

changelog: Fixed a false positive in the `match_single_binding` lint with `#[cfg()]` macro

3 years agoRemoving false positive for the match_single_binding lint
xFrednet [Wed, 9 Dec 2020 12:25:45 +0000 (12:25 +0000)]
Removing false positive for the match_single_binding lint

* Applying suggested changes from the PR

3 years agoAuto merge of #6450 - matthiaskrgr:dont_format_local_repo, r=ebroto
bors [Sun, 13 Dec 2020 18:07:57 +0000 (18:07 +0000)]
Auto merge of #6450 - matthiaskrgr:dont_format_local_repo, r=ebroto

cargo dev fmt: don't format entire rustc repo if we ran ra_setup previously

It turns out that rustfmt sees a rustc repo that we pulled in as path dependency via `cargo dev ra-setup` as part of the tree and would try to format it :D

Of course we don't want this, so skip formatting if we see that we ran `ra-setup` previously.

changelog: none

3 years agocargo dev: rename ra-setup to ra_setup to be in line with the other commands
Matthias Krüger [Sun, 13 Dec 2020 16:01:44 +0000 (17:01 +0100)]
cargo dev: rename ra-setup to ra_setup to be in line with the other commands

3 years agoclippy dev fmt: don't format if we have a local rustc repo enabled as path dependency...
Matthias Krüger [Sun, 13 Dec 2020 14:49:48 +0000 (15:49 +0100)]
clippy dev fmt: don't format if we have a local rustc repo enabled as path dependency via cargo dev ra-setup.

rustfmt would try to format the entire rustc repo, probably because it sees it as a local dependency.

3 years agoNFC: clippy cargo dev: move generation of clap config into a function
Matthias Krüger [Sun, 13 Dec 2020 14:22:45 +0000 (15:22 +0100)]
NFC: clippy cargo dev: move generation of clap config into a function

3 years agoAuto merge of #6449 - matthiaskrgr:needless_borrow_ty, r=ebroto
bors [Sun, 13 Dec 2020 16:59:02 +0000 (16:59 +0000)]
Auto merge of #6449 - matthiaskrgr:needless_borrow_ty, r=ebroto

needless_borrow: print the type in the lint message

changelog: needless_borrow: print type in lint message

3 years agoAuto merge of #6443 - matthiaskrgr:clone_on_copy_type, r=ebroto
bors [Sun, 13 Dec 2020 16:47:33 +0000 (16:47 +0000)]
Auto merge of #6443 - matthiaskrgr:clone_on_copy_type, r=ebroto

clone_on_copy: show the type in the lint message

changelog: clone_on_copy: show the type in the lint message

3 years agoAuto merge of #6441 - ebroto:use_rustflags, r=flip1995
bors [Sun, 13 Dec 2020 16:37:31 +0000 (16:37 +0000)]
Auto merge of #6441 - ebroto:use_rustflags, r=flip1995

Pass Clippy args also trough RUSTFLAGS

This removes a hack (\_\_CLIPPY_HACKERY\_\_) to add another one :)

It allows this workflow to work:
```terminal
cargo clippy                             # warning: empty `loop {}` wastes CPU cycles
cargo clippy -- -A clippy::empty_loop    # no warnings emitted
```

Before this change the new flag was not taken into consideration in cargo's fingerprint and the warning was emitted again. I guess that ideally we could add a specific env var for compiler wrapper arguments, but in the meantime this should do the job.

changelog: Pass clippy arguments through RUSTFLAGS so that changing them will trigger a rebuild

r? `@flip1995`
cc `@ehuss` (I think this may count as another step towards stabilizing `RUSTC_WORKSPACE_WRAPPER` :smile:)

Fixes #5214 and avoids frustration for users unfamiliar with the issue

3 years agoAddress comments from PR review
Eduardo Broto [Sun, 13 Dec 2020 16:21:53 +0000 (17:21 +0100)]
Address comments from PR review

Also: enable tests for cargo-clippy

3 years agoPass Clippy args also trough RUSTFLAGS
Eduardo Broto [Fri, 11 Dec 2020 22:54:47 +0000 (23:54 +0100)]
Pass Clippy args also trough RUSTFLAGS

3 years agoneedless_borrow: print the type in the lint message
Matthias Krüger [Sun, 13 Dec 2020 14:17:47 +0000 (15:17 +0100)]
needless_borrow: print the type in the lint message

changelog: needless_borrow: print type in lint message

3 years agoAuto merge of #6442 - matthiaskrgr:clone-double-ref-ty, r=llogiq
bors [Sun, 13 Dec 2020 10:09:00 +0000 (10:09 +0000)]
Auto merge of #6442 - matthiaskrgr:clone-double-ref-ty, r=llogiq

clone_double_ref: print reference type in lint message

changelog: clone_double_ref: print the type of the reference in lint message

3 years agoAuto merge of #6318 - camsteffen:article-description, r=Manishearth
bors [Sat, 12 Dec 2020 21:20:40 +0000 (21:20 +0000)]
Auto merge of #6318 - camsteffen:article-description, r=Manishearth

Use article_and_description for missing docs

Moves closer to the current rustc missing_doc lint

changelog: none

3 years agoAuto merge of #6382 - giraffate:fix_fp_in_manual_range_contains_when_const_fn, r...
bors [Sat, 12 Dec 2020 21:09:20 +0000 (21:09 +0000)]
Auto merge of #6382 - giraffate:fix_fp_in_manual_range_contains_when_const_fn, r=llogiq

Fix FP of `manual_range_contains` in `const fn`

Fix #6373.

changelog: Fix FP of `manual_range_contains` in `const fn`

3 years agoAuto merge of #6413 - phansch:bless, r=flip1995
bors [Sat, 12 Dec 2020 14:42:28 +0000 (14:42 +0000)]
Auto merge of #6413 - phansch:bless, r=flip1995

Rewrite update-all-references bash scripts in Rust

This replaces the `update-all-references` scripts with a single

    cargo dev bless

command. It should behave mostly the same as the bash scripts. The major difference is, that it can be called from the project root and will always update the files in all of the test suites.

cc #5394

changelog: none

3 years agoFeed the dog :dog2:
Philipp Hansch [Sat, 12 Dec 2020 14:14:54 +0000 (15:14 +0100)]
Feed the dog :dog2:

3 years agoImprove variable naming
Philipp Hansch [Thu, 10 Dec 2020 10:34:22 +0000 (11:34 +0100)]
Improve variable naming

3 years agoRewrite update-all-references bash scripts in Rust
Philipp Hansch [Wed, 2 Dec 2020 17:20:02 +0000 (18:20 +0100)]
Rewrite update-all-references bash scripts in Rust

This replaces the `update-all-references` scripts with a single

    cargo dev bless

command.

cc #5394

3 years agoclone_on_copy: show the type in the lint message
Matthias Krüger [Sat, 12 Dec 2020 00:23:28 +0000 (01:23 +0100)]
clone_on_copy: show the type in the lint message

changelog: clone_on_copy: show the type in the lint message

3 years agoclone_double_ref: print reference type in lint message
Matthias Krüger [Sat, 12 Dec 2020 00:09:30 +0000 (01:09 +0100)]
clone_double_ref: print reference type in lint message

changelog: clone_double_ref: print the type of the reference in lint message

3 years agoAuto merge of #6401 - ebroto:pin_to_a_nightly, r=ebroto
bors [Fri, 11 Dec 2020 16:25:13 +0000 (16:25 +0000)]
Auto merge of #6401 - ebroto:pin_to_a_nightly, r=ebroto

📌 Pin Clippy to a nightly 📌

changelog: Pin Clippy to a specific nightly version (No more master/custom toolchain required to compile Clippy)

Addresses partially #5561. As proposed there in [this comment](https://github.com/rust-lang/rust-clippy/issues/5561#issuecomment-623109095), this kicks off the process, to help us get acquainted with how the syncs should work, before working on improving the tooling.

Open questions:
* When performing a rustup, we will need to exclude the commits that were merged that same day, or else wait until that nightly is released. I did not update the documentation about this part, mainly because I'm not sure about how to do that.
* When should we perform the rustups now? My first idea is to do it at the same time we do the clippyups, to have a clear cadence and to avoid the two copies of the repo to diverge enough to make the process painful.
* Who does the rustups now? If we follow my previous idea and do both rustup and clippyup at the same time, it would be more work for `@flip1995` who currently does the clippyups. I would prefer to establish some kind of rotation to spead the work. Other ideas?
* I'm not sure if this affects the release process in any way.
* ???

`@rust-lang/clippy` thoughts?

r? `@flip1995`

3 years agoFix FP of `manual_range_contains` in `const fn`
Takayuki Nakata [Wed, 25 Nov 2020 08:07:50 +0000 (17:07 +0900)]
Fix FP of `manual_range_contains` in `const fn`

3 years agoAuto merge of #6424 - Suyash458:master, r=flip1995
bors [Fri, 11 Dec 2020 08:38:19 +0000 (08:38 +0000)]
Auto merge of #6424 - Suyash458:master, r=flip1995

Add MSRV to more lints specified in #6097

add MSRV to more lints specified in #6097
add instructions for adding msrv in other lints
update tests

 - [x] `redundant_field_names` requires Rust 1.17 due to suggest feature stablized in that version.
 - [x] `redundant_static_lifetimes` requires Rust 1.17 due to suggest feature stablized in that version.
 - [x] `filter_map_next` requires Rust 1.30 due to suggest `Iterator::find_map`.
 - [x] `checked_conversions` requires Rust 1.34 due to suggest `TryFrom`.
 - [x] `match_like_matches_macro` requires Rust 1.42 due to suggest `matches!`. Addressed in #6201
 - [x] `manual_strip` requires Rust 1.45 due to suggest `str::{strip_prefix, strip_suffix}`. Addressed in #6201
 - [x] `option_as_ref_deref` requires Rust 1.40 due to suggest `Option::{as_deref, as_deref_mut}`. Addressed in #6201
 - [x] `manual_non_exhaustive` requires Rust 1.40 due to suggest `#[non_exhaustive]`. Addressed in #6201
 - [x] `manual_range_contains` requires Rust 1.35 due to suggest `Range*::contains`.
 - [x] `use_self` requires Rust 1.37 due to suggest `Self::Variant on enum`.
 - [x] `mem_replace_with_default` requires Rust 1.40 due to suggest `mem::take`.
 - [x] `map_unwrap_or` requires Rust 1.41 due to suggest `Result::{map_or, map_or_else}`.
 - [x] `missing_const_for_fn` requires Rust 1.46 due to `match/if/loop in const fn` needs that version.

changelog: Add MSRV config to more lints. ^This is now the complete list, AFAWK

3 years agoadd test for missing_const_for_fn. fix test stderr
Suyash458 [Wed, 9 Dec 2020 11:09:33 +0000 (16:39 +0530)]
add test for missing_const_for_fn. fix test stderr

3 years agoadd instructions to include msrv in lints
Suyash458 [Tue, 8 Dec 2020 16:55:20 +0000 (22:25 +0530)]
add instructions to include msrv in lints

3 years agoadd MSRV to more lints specified in #6097
suyash458 [Sat, 5 Dec 2020 12:59:22 +0000 (04:59 -0800)]
add MSRV to more lints specified in #6097
update tests

3 years agoFix integration test runner
flip1995 [Thu, 10 Dec 2020 10:00:05 +0000 (11:00 +0100)]
Fix integration test runner

3 years agoError in integration test, if required toolchain is not installed
flip1995 [Thu, 10 Dec 2020 09:44:33 +0000 (10:44 +0100)]
Error in integration test, if required toolchain is not installed

3 years agoStop caching on CI
flip1995 [Thu, 10 Dec 2020 08:36:19 +0000 (09:36 +0100)]
Stop caching on CI

The only thing we now cache is cargo-cache, which we only use for cache.
That's a catch-22 if I ever seen one. And for Clippy itself we always
want to do a clean build and not cache anything.

3 years agoFix toolchain installation in workflows
flip1995 [Thu, 10 Dec 2020 07:53:27 +0000 (08:53 +0100)]
Fix toolchain installation in workflows

3 years agoEnable internal lints for every test in CI
flip1995 [Thu, 10 Dec 2020 07:51:27 +0000 (08:51 +0100)]
Enable internal lints for every test in CI

3 years agoUse new cache key
Eduardo Broto [Wed, 9 Dec 2020 22:38:15 +0000 (23:38 +0100)]
Use new cache key

3 years agoApply suggestions from PR review
Eduardo Broto [Wed, 9 Dec 2020 16:20:38 +0000 (17:20 +0100)]
Apply suggestions from PR review

Also:
  - Update to latest nightly

3 years agoPin Clippy to a nightly
Eduardo Broto [Sun, 29 Nov 2020 17:08:47 +0000 (18:08 +0100)]
Pin Clippy to a nightly

3 years agoAuto merge of #6218 - korrat:master, r=ebroto
bors [Wed, 9 Dec 2020 17:08:00 +0000 (17:08 +0000)]
Auto merge of #6218 - korrat:master, r=ebroto

Add lint for maps with zero-sized value types

Hi, this is my first time contributing to clippy or rust in general, so I'm not sure about the details of contributing. Please excuse me and let me now if I did anything wrong. I have a couple of questions:

1. I'm not sure what category this lint should be. I've put it in "nursery" for now.
1. Should I squash commits this is reviewed/merged?

changelog: Add lint for maps with zero-sized value types

Fixes #1641

3 years agoAdd a lint for maps with zero-sized values
Korrat [Sat, 24 Oct 2020 14:48:10 +0000 (16:48 +0200)]
Add a lint for maps with zero-sized values

Co-authored-by: Eduardo Broto <ebroto@tutanota.com>
3 years agoAuto merge of #6188 - ebroto:primary_package, r=flip1995
bors [Wed, 9 Dec 2020 15:37:20 +0000 (15:37 +0000)]
Auto merge of #6188 - ebroto:primary_package, r=flip1995

Add --no-deps option to avoid running on path dependencies in workspaces

Since rust-lang/cargo#8758 has hit nightly, this allows us to address the second bullet point and [the concern related to `--fix`](https://github.com/rust-lang/cargo/issues/8143#issuecomment-619289546) in the [RUSTC_WORKSPACE_WRAPPER tracking issue](https://github.com/rust-lang/cargo/issues/8143).

As a reminder stabilizing that env var will solve #4612 (Clippy not running after `cargo check` in stable) and would allow to stabilize the `--fix` option in Clippy.

changelog: Add `--no-deps` option to avoid running on path dependencies in workspaces

Fixes #3025

3 years agoAuto merge of #6367 - justjosias:6348-print-stderr, r=ebroto
bors [Tue, 8 Dec 2020 22:22:49 +0000 (22:22 +0000)]
Auto merge of #6367 - justjosias:6348-print-stderr, r=ebroto

Add lint print_stderr

Resolves #6348
Almost identical to print_stdout, this lint applies to the `eprintln!` and `eprint!` macros rather than `println!` and `print!`.

changelog: Add new lint [`print_stderr`]. [`println_empty_string`] and [`print_with_newline`] now apply to `eprint!()` and `eprintln!()` respectively.

3 years agoFactor out some code in write.rs
Eduardo Broto [Tue, 8 Dec 2020 22:17:12 +0000 (23:17 +0100)]
Factor out some code in write.rs

Get rid of the too-many-lines error.

3 years agoAuto merge of #6432 - giraffate:sync-from-rust, r=flip1995
bors [Tue, 8 Dec 2020 08:11:41 +0000 (08:11 +0000)]
Auto merge of #6432 - giraffate:sync-from-rust, r=flip1995

Rustup

changelog: none

3 years agoMerge remote-tracking branch 'upstream/master' into sync-from-rust
Takayuki Nakata [Tue, 8 Dec 2020 08:01:25 +0000 (17:01 +0900)]
Merge remote-tracking branch 'upstream/master' into sync-from-rust

3 years agoAuto merge of #6330 - camsteffen:redundant-else, r=ebroto
bors [Tue, 8 Dec 2020 00:51:51 +0000 (00:51 +0000)]
Auto merge of #6330 - camsteffen:redundant-else, r=ebroto

Add Redundant else lint

changelog: Add redundant_else lint

It seemed appropriate for "pedantic".

Closes #112 \*blows off dust*

3 years agoAuto merge of #6280 - dp304:assert_in_result_fn, r=ebroto
bors [Mon, 7 Dec 2020 23:16:05 +0000 (23:16 +0000)]
Auto merge of #6280 - dp304:assert_in_result_fn, r=ebroto

Add lint for assertions in functions returning Result

changelog: none
fixes #6082

3 years agoUpdate reference file
Eduardo Broto [Mon, 7 Dec 2020 23:14:05 +0000 (00:14 +0100)]
Update reference file

3 years agoApply suggestions from code review
dp304 [Thu, 3 Dec 2020 22:07:24 +0000 (23:07 +0100)]
Apply suggestions from code review

Use array slice instead of `Vec` in `find_macro_calls` as suggested by @ebroto

Co-authored-by: Eduardo Broto <ebroto@tutanota.com>
3 years agopanic_in_result_fn: Extend to also check usages of [debug_]assert* macros
Dobe Peter [Sat, 31 Oct 2020 19:31:34 +0000 (20:31 +0100)]
panic_in_result_fn: Extend to also check usages of [debug_]assert* macros

Also, the macro-finding logic has been moved to the util module, for
use by future lints.

3 years agoAdd eprint! to print_with_newline lint
Josias [Fri, 4 Dec 2020 14:39:09 +0000 (15:39 +0100)]
Add eprint! to print_with_newline lint

3 years agoFix print_stderr.stderr test
Josias [Tue, 1 Dec 2020 10:29:49 +0000 (11:29 +0100)]
Fix print_stderr.stderr test

3 years agoAdd negative tests
Josias [Sun, 29 Nov 2020 08:55:47 +0000 (09:55 +0100)]
Add negative tests

3 years agoAdd lint print_stderr
Josias [Sun, 22 Nov 2020 18:02:57 +0000 (19:02 +0100)]
Add lint print_stderr

Resolves #6348
Almost identical to print_stdout, this lint applies to the
`eprintln!` and `eprint!` macros rather than `println!` and
`print!`.

3 years agoAuto merge of #6370 - giraffate:fix_fp_in_unnecessary_lazy_evaluations, r=llogiq...
bors [Mon, 7 Dec 2020 15:19:30 +0000 (15:19 +0000)]
Auto merge of #6370 - giraffate:fix_fp_in_unnecessary_lazy_evaluations, r=llogiq,flip1995

Fix FP in `unnecessary_lazy_evaluations`

Fix https://github.com/rust-lang/rust-clippy/issues/6343

changelog: Fix FP in `unnecessary_lazy_evaluations`

3 years agocargo dev fmt
Takayuki Nakata [Mon, 7 Dec 2020 07:45:10 +0000 (16:45 +0900)]
cargo dev fmt

3 years agoFix FP in `unnecessary_lazy_evaluations`
Takayuki Nakata [Sun, 22 Nov 2020 13:04:18 +0000 (22:04 +0900)]
Fix FP in `unnecessary_lazy_evaluations`

3 years agoRetain assembly operands span when lowering AST to HIR
Tomasz Miąsko [Fri, 27 Nov 2020 00:00:00 +0000 (00:00 +0000)]
Retain assembly operands span when lowering AST to HIR

3 years agoMerge commit 'c1664c50b27a51f7a78c93ba65558e7c33eabee6' into clippyup
flip1995 [Sun, 6 Dec 2020 14:01:03 +0000 (15:01 +0100)]
Merge commit 'c1664c50b27a51f7a78c93ba65558e7c33eabee6' into clippyup

3 years agoAuto merge of #6421 - xFrednet:4176-unreadable-literal-lint-fractal-option, r=Manishearth
bors [Sun, 6 Dec 2020 07:18:33 +0000 (07:18 +0000)]
Auto merge of #6421 - xFrednet:4176-unreadable-literal-lint-fractal-option, r=Manishearth

Added a lint-fraction-readability flag to the configuration

This adds an option to disable the `unreadable_literal` lint for floats with a longer fraction. This allows users to write `0.100200300` without getting a warning. Fixes #4176

I have some open questions about this PR:
1. I've named the option `lint-fraction-readability` is this a good name or should I rename it to something else?
2. What should the default configuration value be?
    * The current default value is `true` as this was also the previous default.
3. Do I have to document this new option somewhere else or will it be extracted from the code comment?
4. The current fix option will also rewrite the fraction if the integer part violates the `unreadable_literal` lint it would otherwise also trigger the `inconsistent_digit_grouping` lint. Is this also okay?
    * `1.100200300` will be unaffected by the fix function
    * `100200300.100200300` will be effected and fixed to `100_200_300.100_200_300`

---

The project needed some getting used to but I'm happy with the result. A big thank you to `@flip1995` for giving me some pointers for this implementation and to everyone for the great introduction documentation!

---

changelog: Added the `unreadable-literal-lint-fractions` configuration to disable the `unreadable_literal` lint for fractions

3 years agoRenamed the configuraiton to unreadable-literal-lint-fractions
xFrednet [Sat, 5 Dec 2020 20:59:53 +0000 (20:59 +0000)]
Renamed the configuraiton to unreadable-literal-lint-fractions

3 years agoAuto merge of #6418 - flip1995:apple_wraps_mhm, r=llogiq
bors [Sat, 5 Dec 2020 08:42:21 +0000 (08:42 +0000)]
Auto merge of #6418 - flip1995:apple_wraps_mhm, r=llogiq

Turn unnecessary_wraps applicability to MaybeIncorrect

Fixes: #6417
changelog: Turn [`unnecessary_wraps`] applicability to `MaybeIncorrect`

3 years agoUpdated code for CI
xFrednet [Fri, 4 Dec 2020 22:05:52 +0000 (22:05 +0000)]
Updated code for CI

3 years agoAdded a lint-fraction-readability flag to the configuration
xFrednet [Fri, 4 Dec 2020 21:26:47 +0000 (21:26 +0000)]
Added a lint-fraction-readability flag to the configuration

3 years agoAuto merge of #6419 - giraffate:fix_a_style_of_texts_in_size_of_in_element_count...
bors [Fri, 4 Dec 2020 14:42:07 +0000 (14:42 +0000)]
Auto merge of #6419 - giraffate:fix_a_style_of_texts_in_size_of_in_element_count, r=flip1995

Fix a style of texts in `size_of_in_element_count`

Add missing ` to texts

changelog: none

3 years agoFix a style of texts in `size_of_in_element_count`
Takayuki Nakata [Fri, 4 Dec 2020 14:36:07 +0000 (23:36 +0900)]
Fix a style of texts in `size_of_in_element_count`

3 years agoTurn unnecessary_wraps applicability to MaybeIncorrect
flip1995 [Fri, 4 Dec 2020 09:01:09 +0000 (10:01 +0100)]
Turn unnecessary_wraps applicability to MaybeIncorrect

3 years agoAuto merge of #6416 - deg4uss3r:map_err_restricted, r=ebroto
bors [Fri, 4 Dec 2020 01:04:48 +0000 (01:04 +0000)]
Auto merge of #6416 - deg4uss3r:map_err_restricted, r=ebroto

Moved map_err_ignore to restriction and updated help message

This MR moves map_err_ignore lint from `pedantic` to the `restriction` category of lints and updates the help message to give the user an option to ignore the lint by naming the closure variable e.g. `.map_err(|_ignored| ...`

---

changelog: move map_err_ignore to restriction category

3 years agoAuto merge of #6394 - nico-abram:unsafe_sizeof_count_copies, r=ebroto
bors [Fri, 4 Dec 2020 00:43:00 +0000 (00:43 +0000)]
Auto merge of #6394 - nico-abram:unsafe_sizeof_count_copies, r=ebroto

Add lint size_of_in_element_count

Fixes #6381
changelog: Add lint to check for using size_of::<T> or size_of_val::<T> in the count parameter to ptr::copy or ptr::copy_nonoverlapping, which take a count of Ts (And not a count of bytes)

- \[X] Followed [lint naming conventions][lint_naming]
- \[X] Added passing UI tests (including committed `.stderr` file)
- \[ ] `cargo test` passes locally
- \[X] Executed `cargo dev update_lints`
- \[X] Added lint documentation
- \[X] Run `cargo dev fmt`

[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints

Running `cargo test` locally fails with this error:

```
running 1 test
test fmt ... FAILED

failures:

---- fmt stdout ----
status: exit code: 1
stdout:
stderr: error: unable to unlink old fallback exe
error: caused by: Access is denied. (os error 5)

thread 'fmt' panicked at 'Formatting check failed. Run `cargo dev fmt` to update formatting.', tests\fmt.rs:32:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    fmt

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
```

But I did run `cargo dev fmt`

3 years agoAdded test to make sure ignoring the error with a named wildcard value works
Ricky [Fri, 4 Dec 2020 00:41:44 +0000 (19:41 -0500)]
Added test to make sure ignoring the error with a named wildcard value works

3 years agoAdd more functions to size_of_in_element_count
unknown [Tue, 1 Dec 2020 00:54:50 +0000 (21:54 -0300)]
Add more functions to size_of_in_element_count
Specifically ptr::{sub, wrapping_sub, add, wrapping_add, offset, wrapping_offset} and slice::{from_raw_parts, from_raw_parts_mut}
The lint now also looks for size_of calls through casts (Since offset takes an isize)

3 years agoRename unsafe_sizeof_count_copies to size_of_in_element_count
unknown [Thu, 3 Dec 2020 23:55:38 +0000 (20:55 -0300)]
Rename unsafe_sizeof_count_copies to size_of_in_element_count

Also fix review comments:
 - Use const arrays and iterate them for the method/function names
 - merge 2 if_chain's into one using a rest pattern
 - remove unnecessary unsafe block in test

And make the lint only point to the count expression instead of the entire function call

3 years agoRemove unnecessary unsafe_size_count_copies tests
unknown [Sun, 29 Nov 2020 17:32:11 +0000 (14:32 -0300)]
Remove unnecessary unsafe_size_count_copies tests

3 years agoMake the unsafe_sizeof_count_copies lint work with more functions
unknown [Sun, 29 Nov 2020 17:23:59 +0000 (14:23 -0300)]
Make the unsafe_sizeof_count_copies lint work with more functions
Specifically:
 - find std::ptr::write_bytes
 - find std::ptr::swap_nonoverlapping
 - find std::ptr::slice_from_raw_parts
 - find std::ptr::slice_from_raw_parts_mut
 - pointer_primitive::write_bytes

3 years agoMake the unsafe_sizeof_count_copies lint find copy_{from,to} method calls
unknown [Sun, 29 Nov 2020 04:47:32 +0000 (01:47 -0300)]
Make the unsafe_sizeof_count_copies lint find copy_{from,to} method calls

3 years agoAdd lint unsafe_sizeof_count_copies
unknown [Sat, 28 Nov 2020 01:44:02 +0000 (22:44 -0300)]
Add lint unsafe_sizeof_count_copies

3 years agoUpdate the stderr message in ui tests
Ricky [Thu, 3 Dec 2020 22:49:27 +0000 (17:49 -0500)]
Update the stderr message in ui tests

3 years agoApply suggestions from code review
Ricky [Thu, 3 Dec 2020 22:44:50 +0000 (17:44 -0500)]
Apply suggestions from code review

updated help message for the user

Co-authored-by: Jane Lusby <jlusby42@gmail.com>
3 years agodidn't update lint correctly
Ricky [Thu, 3 Dec 2020 22:22:03 +0000 (17:22 -0500)]
didn't update lint correctly

3 years agoMoved map_err_ignore to restriction and updated help message
Ricky [Thu, 3 Dec 2020 21:11:52 +0000 (16:11 -0500)]
Moved map_err_ignore to restriction and updated help message

3 years agoAuto merge of #6415 - flip1995:rollup-fz7872l, r=flip1995
bors [Thu, 3 Dec 2020 09:23:48 +0000 (09:23 +0000)]
Auto merge of #6415 - flip1995:rollup-fz7872l, r=flip1995

Rollup of 4 pull requests

Successful merges:

 - #6308 (add `internal-lints` feature to enable clippys internal lints (off by default))
 - #6395 (switch Version/VersionReq usages to RustcVersion )
 - #6402 (Add Collapsible match lint)
 - #6407 (CONTRIBUTING: update bors queue url from buildbot2.rlo to bors.rlo)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

changelog: rollup

3 years agoRollup merge of #6407 - matthiaskrgr:bors_website, r=Manishearth
Philipp Krones [Thu, 3 Dec 2020 09:21:34 +0000 (10:21 +0100)]
Rollup merge of #6407 - matthiaskrgr:bors_website, r=Manishearth

CONTRIBUTING: update bors queue url from buildbot2.rlo to bors.rlo

changelog: CONTRIBUTING: update homu links to bors.rust-lang.org

3 years agoRollup merge of #6402 - camsteffen:collapsible-match, r=llogiq
Philipp Krones [Thu, 3 Dec 2020 09:21:33 +0000 (10:21 +0100)]
Rollup merge of #6402 - camsteffen:collapsible-match, r=llogiq

Add Collapsible match lint

changelog: Add collapsible_match lint

Closes #1252
Closes #2521

This lint finds nested `match` or `if let` patterns that can be squashed together. It is designed to be very conservative to only find cases where merging the patterns would most likely reduce cognitive complexity.

Example:

```rust
match result {
    Ok(opt) => match opt {
        Some(x) => x,
        _ => return,
    }
    _ => return,
}
```
to
```rust
match result {
    Ok(Some(x)) => x,
    _ => return,
}
```

These criteria must be met for the lint to fire:

* The inner match has exactly 2 branches.
* Both the outer and inner match have a "wild" branch like `_ => ..`. There is a special case for `None => ..` to also be considered "wild-like".
* The contents of the wild branches are identical.
* The binding which "links" the matches is never used elsewhere.

Thanks to the hir, `if let`'s are easily included with this lint since they are desugared into equivalent `match`'es.

I think this would fit into the style category, but I would also understand changing it to pedantic.

3 years agoRollup merge of #6395 - Suyash458:master, r=flip1995
Philipp Krones [Thu, 3 Dec 2020 09:21:32 +0000 (10:21 +0100)]
Rollup merge of #6395 - Suyash458:master, r=flip1995

switch Version/VersionReq usages to RustcVersion

add `rustc-semver` to dependencies
switch `Version/VersionReq` usages to `RustcVersion`
changelog: none

3 years agoRollup merge of #6308 - matthiaskrgr:internal_lints, r=flip1995
Philipp Krones [Thu, 3 Dec 2020 09:21:31 +0000 (10:21 +0100)]
Rollup merge of #6308 - matthiaskrgr:internal_lints, r=flip1995

add `internal-lints` feature to enable clippys internal lints (off by default)

This PR moves the internal lint tests into a new subdirectory (I couldn't find a different way to compile-time-conditionally exclude them from compiletest) and only builds and tests internal lints if the `internal-lints` feature is enabled.

Fixes #6306

changelog: put internal lints behind a feature ("internal-lints")

3 years agoAuto merge of #6404 - flip1995:rustup, r=flip1995
bors [Thu, 3 Dec 2020 08:55:04 +0000 (08:55 +0000)]
Auto merge of #6404 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

3 years agoCONTRIBUTING: update bors queue url from buildbot2.rlo to bors.rlo
Matthias Krüger [Tue, 1 Dec 2020 00:26:02 +0000 (01:26 +0100)]
CONTRIBUTING: update bors queue url from buildbot2.rlo to bors.rlo

3 years agobump rustc-semver version. use in built method to compare versions
Suyash458 [Mon, 30 Nov 2020 05:54:10 +0000 (11:24 +0530)]
bump rustc-semver version. use in built method to compare versions

3 years agoAuto merge of #79329 - camelid:int-lit-suffix-error, r=davidtwco
bors [Mon, 30 Nov 2020 01:42:14 +0000 (01:42 +0000)]
Auto merge of #79329 - camelid:int-lit-suffix-error, r=davidtwco

Update error to reflect that integer literals can have float suffixes

For example, `1` is parsed as an integer literal, but it can be turned
into a float with the suffix `f32`. Now the error calls them "numeric
literals" and notes that you can add a float suffix since they can be
either integers or floats.

3 years agoSplit tests
Cameron Steffen [Mon, 30 Nov 2020 00:21:21 +0000 (18:21 -0600)]
Split tests

3 years agoEat redundant else dogfood
Cameron Steffen [Fri, 13 Nov 2020 18:46:37 +0000 (12:46 -0600)]
Eat redundant else dogfood

3 years agoAdd redundant else lint
Cameron Steffen [Fri, 13 Nov 2020 18:13:50 +0000 (12:13 -0600)]
Add redundant else lint

3 years agoaddress review comments and rebase
Matthias Krüger [Mon, 16 Nov 2020 11:44:05 +0000 (12:44 +0100)]
address review comments and rebase

ci: always build with internal lints
group up internal lints in lib.rs
dogfood: we already pass --all-features, no need to enable internal-lints again

3 years agoUse LocalUsedVisitor in more places
Cameron Steffen [Sun, 29 Nov 2020 02:41:29 +0000 (20:41 -0600)]
Use LocalUsedVisitor in more places

3 years agoEat collapsible_match dogfood
Cameron Steffen [Wed, 25 Nov 2020 02:57:09 +0000 (20:57 -0600)]
Eat collapsible_match dogfood

3 years agoAdd collapsible_match lint
Cameron Steffen [Wed, 25 Nov 2020 02:37:07 +0000 (20:37 -0600)]
Add collapsible_match lint

3 years agoAdd LocalUseVisitor
Cameron Steffen [Fri, 27 Nov 2020 23:13:19 +0000 (17:13 -0600)]
Add LocalUseVisitor

3 years agoImprove SpanlessEq for blocks
Cameron Steffen [Fri, 27 Nov 2020 18:15:05 +0000 (12:15 -0600)]
Improve SpanlessEq for blocks

3 years agoci: partly clean build artifacts to work around "Found multiple rlibs for crate ...
Matthias Krüger [Fri, 13 Nov 2020 10:36:07 +0000 (11:36 +0100)]
ci: partly clean build artifacts to work around "Found multiple rlibs for crate `clippy_lints`" compiletest error

3 years agofix clippy-dev update_lints
Matthias Krüger [Fri, 13 Nov 2020 01:12:48 +0000 (02:12 +0100)]
fix clippy-dev update_lints

3 years agoadd internal-lints feature to enable clippys internal lints (off by default)
Matthias Krüger [Sun, 8 Nov 2020 12:39:46 +0000 (13:39 +0100)]
add internal-lints feature to enable clippys internal lints (off by default)