]> git.lizzy.rs Git - rust.git/log
rust.git
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 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 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)

3 years agoadd more tests for msrv
Suyash458 [Sun, 29 Nov 2020 11:38:56 +0000 (17:08 +0530)]
add more tests for msrv

3 years agofix msrv check
suyash458 [Sun, 29 Nov 2020 08:33:07 +0000 (00:33 -0800)]
fix msrv check

3 years agofix dogfood tests
suyash458 [Sun, 29 Nov 2020 07:17:43 +0000 (23:17 -0800)]
fix dogfood tests

3 years agoUpdate tests to remove old numeric constants
bstrie [Sat, 24 Oct 2020 23:21:40 +0000 (19:21 -0400)]
Update tests to remove old numeric constants

Part of #68490.

Care has been taken to leave the old consts where appropriate, for testing backcompat regressions, module shadowing, etc. The intrinsics docs were accidentally referring to some methods on f64 as std::f64, which I changed due to being contrary with how we normally disambiguate the shadow module from the primitive. In one other place I changed std::u8 to std::ops since it was just testing path handling in macros.

For places which have legitimate uses of the old consts, deprecated attributes have been optimistically inserted. Although currently unnecessary, they exist to emphasize to any future deprecation effort the necessity of these specific symbols and prevent them from being accidentally removed.

3 years agofix msrv in test
Suyash458 [Sat, 28 Nov 2020 14:24:28 +0000 (19:54 +0530)]
fix msrv in test

3 years agoadd rustc-semver to dependencies
Suyash458 [Sat, 28 Nov 2020 14:11:27 +0000 (19:41 +0530)]
add rustc-semver to dependencies
switch Version/VersionReq usages to RustcVersion

3 years agoAuto merge of #6377 - CDirkx:redundant-pattern-match-ipaddr, r=ebroto
bors [Sat, 28 Nov 2020 23:02:47 +0000 (23:02 +0000)]
Auto merge of #6377 - CDirkx:redundant-pattern-match-ipaddr, r=ebroto

Enhance `redundant_pattern_matching` to also lint on `std::net::IpAddr`

Follow-up to #6339
r? `@ebroto`

(note: also contains a small cleanup of the other ui tests)

changelog: Enhance [`redundant_pattern_matching`] to also lint on `std::net::IpAddr`

3 years agoAuto merge of #6398 - rajcspsg:issue_6357, r=flip1995
bors [Sat, 28 Nov 2020 22:41:28 +0000 (22:41 +0000)]
Auto merge of #6398 - rajcspsg:issue_6357, r=flip1995

issue_6357 update unreachable macro usage

changelog: none

3 years agoAuto merge of #6397 - matsujika:fix-6384, r=flip1995
bors [Sat, 28 Nov 2020 22:19:47 +0000 (22:19 +0000)]
Auto merge of #6397 - matsujika:fix-6384, r=flip1995

Fix a false positive in `unnecessary_wraps`

Fix #6384

changelog: Fix FP in `unnecessary_wraps` that happens when `Call` expr has `Return` expr inside

3 years agoAuto merge of #6290 - alex-700:fix-match-like-matches, r=flip1995
bors [Sat, 28 Nov 2020 21:58:07 +0000 (21:58 +0000)]
Auto merge of #6290 - alex-700:fix-match-like-matches, r=flip1995

do not trigger MATCH_LIKE_MATCHES_MACRO lint with attrs

fixed #6289
changelog: do not trigger MATCH_LIKE_MATCHES_MACRO lint for arms with attrs

3 years agoFix formatting
Philipp Krones [Sat, 28 Nov 2020 21:40:46 +0000 (22:40 +0100)]
Fix formatting

3 years agoAuto merge of #6390 - pro-grammer1:master, r=ebroto
bors [Sat, 28 Nov 2020 21:37:05 +0000 (21:37 +0000)]
Auto merge of #6390 - pro-grammer1:master, r=ebroto

Added known problem to comparison_chain docs

changelog: Added documentation to comparison_chain that explains a possible performance penalty, according to issue #5354

This is my first PR, I hope everything has been done correctly.

Fixes #5354

3 years agoAuto merge of #6396 - flip1995:rustup, r=ebroto
bors [Sat, 28 Nov 2020 21:14:37 +0000 (21:14 +0000)]
Auto merge of #6396 - flip1995:rustup, r=ebroto

Rustup?

Basically a rustup from an unknown source. I added a regression test (and slightly changed the lint), so this'll need a review.

changelog: Fix bug in [`items_after_statements`] wher it triggered, if items were separated by trailing semicolons.

3 years agoissue_6357 update unreachable macro usage
Rajkumar Natarajan [Sat, 28 Nov 2020 17:19:57 +0000 (12:19 -0500)]
issue_6357 update unreachable macro usage

3 years agoChange formulation of known problems section
Philipp Krones [Sat, 28 Nov 2020 17:58:53 +0000 (18:58 +0100)]
Change formulation of known problems section

3 years agodo not trigger MATCH_LIKE_MATCHES_MACRO lint with attrs
Aleksei Latyshev [Wed, 4 Nov 2020 18:16:25 +0000 (21:16 +0300)]
do not trigger MATCH_LIKE_MATCHES_MACRO lint with attrs

- it can't be solved completely for attrs evaluated into `false`
- change applicability to MaybeIncorrect and mention it in docs

3 years agoMove `contains_return` to utils/mod.rs
Hirochika Matsumoto [Sat, 28 Nov 2020 17:18:05 +0000 (02:18 +0900)]
Move `contains_return` to utils/mod.rs

3 years agoFix a false positive in `unnecessary_wraps`
Hirochika Matsumoto [Sat, 28 Nov 2020 16:55:15 +0000 (01:55 +0900)]
Fix a false positive in `unnecessary_wraps`

3 years agoitems_after_statements: don't lint when they a separated by trailing semicolons
flip1995 [Sat, 28 Nov 2020 16:18:15 +0000 (17:18 +0100)]
items_after_statements: don't lint when they a separated by trailing semicolons

3 years agoFix weird dogfood error
flip1995 [Sat, 28 Nov 2020 16:03:20 +0000 (17:03 +0100)]
Fix weird dogfood error

3 years agoAuto merge of #6086 - Ryan1729:add-suspicious_chained_operators-lint, r=llogiq
bors [Sat, 28 Nov 2020 08:17:25 +0000 (08:17 +0000)]
Auto merge of #6086 - Ryan1729:add-suspicious_chained_operators-lint, r=llogiq

Add suspicious_operation_groupings lint

This is my (<del> currently WIP </del>) attempt to close #6039.

changelog: Added `suspicious_operation_groupings` lint.

3 years agoAuto merge of #6360 - mlegner:mod_one, r=llogiq
bors [Sat, 28 Nov 2020 07:07:25 +0000 (07:07 +0000)]
Auto merge of #6360 - mlegner:mod_one, r=llogiq

Trigger modulo_one lint also on -1.

Fixes #6321.

changelog: trigger `modulo_one` lint also on `-1`

3 years agoUpdate error to reflect that integer literals can have float suffixes
Camelid [Sun, 22 Nov 2020 22:29:46 +0000 (14:29 -0800)]
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 agoadd suspicious_operation_groupings lint
Ryan1729 [Sat, 7 Nov 2020 23:00:42 +0000 (16:00 -0700)]
add suspicious_operation_groupings lint

run `cargo dev new_lint --category correctness --name suspicious_chained_operators --pass early`

add (currently failing) tests for suspicious_chained_operators
add some tests to answer a question that came up during implementation

write usage code for functions we'll need to find or create

Complete left-right tracking TODO

get it compiling with several `todo!` invocations.

refactor to a set of incomplete functions that don't expect to be able to edit a `Span`

create placeholder for `suggestion_with_swapped_ident` function and correct some comments

add `inside_larger_boolean_expression` test

fill out `get_ident` and `suggestion_with_swapped_ident`

Implementi the `IdentIter`

start on implementing the `IdentIter`
handle the `ExprKind::Path` case in `IdentIter`

on second thought, make the iterator type dynamic so we don't need an explicit type for each one we will need

handle `ExprKind::MacCall` in `IdentIter`

Try handling `box x` expressions

restructure `IdentIter`

set `self.done` when returning `None`

Handle `ExprKind::Array`

reduce duplication with a macro that we expect to use several more times

handle ExprKind::Call

add `new_p` convenience method

handle `MethodCall`

handle `Tup` and `Binary`

handle `Unary`

simplify by not returning an additional `Expr` from the `IdentIter`

add cross product test against false positives

rename suspicious_chained_operators to suspicious_operation_groupings within files

For the record, the exact commands run were:
find . -type f -name "*.md" -exec sed -i 's/suspicious_chained_operators/suspicious_operation_groupings/g' {} +

find . -type f -name "*.rs" -exec sed -i 's/suspicious_chained_operators/suspicious_operation_groupings/g' {} +

find . -type f -name "*.rs" -exec sed -i 's/SUSPICIOUS_CHAINED_OPERATORS/SUSPICIOUS_OPERATION_GROUPINGS/g' {} +

find . -type f -name "*.rs" -exec sed -i 's/SuspiciousChainedOperators/SuspiciousOperationGroupings/g' {} +

Also:
rename file to match module name

rename test file to match lint name

start implementing `IdentDifference` creation

add `IdentIter` utility

use `ident_iter::IdentIter`

fix bug in `suggestion_with_swapped_ident`

add `inside_if_statements` test

implement `Add` `todo`s

register `SuspiciousOperationGroupings` lint pass

fill in `chained_binops`, and fill in a stopgap version of `ident_difference_expr`, but then notice that the lint does not seem to ever be run in the tests

run `cargo dev update_lints` and not that the `suspicious_operation_groupings` lint still does not seem to be run

fix base index incrementing bug

fix paired_identifiers bug, and remove ident from `Single`

change help prefix and note our first successful lint messages!

add odd_number_of_pairs test

get the `non_boolean_operators` test passing, with two copies of the error message

extract `is_useless_with_eq_exprs` so we can know when `eq_op` will already handle something

add `not_caught_by_eq_op` tests since `s1.b * s1.b` was (reasonably) not caught by `eq_op`

cover the case where the change should be made on either side of the expression with `not_caught_by_eq_op` tests

produce the expected suggestion on the `not_caught_by_eq_op_middle_change_left` test

confirm that the previous tests still pass and update references

fix early continue bug and get `not_caught_by_eq_op_middle_change_right` passing

note that `not_caught_by_eq_op_start` already passes

fix bugs based on misunderstanding of what `Iterator::skip` does, and note that `not_caught_by_eq_op_end` now passes

add several parens tests and make some of them pass

handle parens inside `chained_binops_helper` and note that this makes several tests pass

get `inside_larger_boolean_expression_with_unsorted_ops` test passing by extracting out `check_same_op_binops` function

also run `cargo dev fmt`

note that `inside_function_call` already passes

add another `if_statement` test

remove the matching op requirement, making `inside_larger_boolean_expression_with_unsorted_ops` pass

prevent non-change suggestions from being emitted

get the `Nested` tests passing, and remove apparently false note about eq_op

add a test to justify comment in `ident_difference_expr_with_base_location` but find that the failure mode seems different than expected

complete `todo` making `do_not_give_bad_suggestions_for_this_unusual_expr` pass and add some more tests that already pass

add test to `eq_op`

note that `inside_fn_with_similar_expression` already passes

fix `inside_an_if_statement` and note that it already passes

attempt to implement if statement extraction and notice that we don't seem to handle unary ops correctly

add `maximum_unary_minus_right_tree` test and make it pass

add two tests and note one of them passes

filter out unary operations in several places, and find that the issue seems to be that we don't currently recognize the error in `multiple_comparison_types_and_unary_minus` even so.

remove filtering that was causing bad suggestions

remove tests that were deemed too much for now

run `cargo dev fmt`

correct eq_op post-merge

fill out the description and delete debugging code

run `cargo dev update_lints`

update eq_op references

add parens to work around rustfmt issue #3666 and run rustfmt

https://github.com/rust-lang/rustfmt/issues/3666#issuecomment-714612257

update references after formatting

fix dogfood issues

fix multi-cursor edit

fix missed dogfood error

fix more dogfood pedantic issues, including function length

even more nesting

insert hidden definition of Vec3 so docs compile

add spaces to second struct def

reword test description comment

Co-authored-by: llogiq <bogusandre@gmail.com>
add local `use BinOpKind::*;`

Apply suggestions from code review

Co-authored-by: llogiq <bogusandre@gmail.com>
switch `SUSPICIOUS_OPERATION_GROUPINGS` to a style lint

run `cargo dev update_lints`

put both usages of `op_types` in the same closure to satisfy `borrowck`

fix compile error

3 years agoAuto merge of #6392 - ebroto:rustup, r=ebroto
bors [Fri, 27 Nov 2020 16:17:07 +0000 (16:17 +0000)]
Auto merge of #6392 - ebroto:rustup, r=ebroto

Rustup

changelog: none

r? `@ghost`

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
Eduardo Broto [Fri, 27 Nov 2020 16:15:10 +0000 (17:15 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agoAuto merge of #79318 - cjgillot:fitem, r=lcnr
bors [Fri, 27 Nov 2020 13:45:22 +0000 (13:45 +0000)]
Auto merge of #79318 - cjgillot:fitem, r=lcnr

Store HIR ForeignItem in a side table

In a similar fashion to Item, ImplItem and TraitItem.

3 years agoFactor out `check_binary` from function `check_expr`.
Markus Legner [Mon, 23 Nov 2020 09:18:27 +0000 (10:18 +0100)]
Factor out `check_binary` from function `check_expr`.

3 years agoRun `cargo dev fmt`.
Markus Legner [Sat, 21 Nov 2020 11:38:21 +0000 (12:38 +0100)]
Run `cargo dev fmt`.

3 years agoTrigger modulo_one lint also on -1.
Markus Legner [Sat, 21 Nov 2020 11:28:53 +0000 (12:28 +0100)]
Trigger modulo_one lint also on -1.

3 years agoAuto merge of #6386 - rust-lang:flip1995-patch-1, r=ebroto
bors [Fri, 27 Nov 2020 07:35:25 +0000 (07:35 +0000)]
Auto merge of #6386 - rust-lang:flip1995-patch-1, r=ebroto

Remove mention of possibility to specify the MSRV with a tilde/caret

As `@taiki-e` explained in https://github.com/rust-lang/rust-clippy/pull/6379#discussion_r530743279, mentioning this might be problematic.

changelog: none

3 years agoAuto merge of #6389 - giraffate:sync-from-rust, r=llogiq
bors [Fri, 27 Nov 2020 06:53:59 +0000 (06:53 +0000)]
Auto merge of #6389 - giraffate:sync-from-rust, r=llogiq

Rustup

changelog: none

3 years agocargo dev fmt
Takayuki Nakata [Fri, 27 Nov 2020 01:32:44 +0000 (10:32 +0900)]
cargo dev fmt

3 years agoMerge remote-tracking branch 'upstream/master' into sync-from-rust
Takayuki Nakata [Fri, 27 Nov 2020 01:25:07 +0000 (10:25 +0900)]
Merge remote-tracking branch 'upstream/master' into sync-from-rust

3 years agoRemove ForeignMod struct.
Camille GILLOT [Wed, 11 Nov 2020 21:40:09 +0000 (22:40 +0100)]
Remove ForeignMod struct.

3 years agoAdded known problem to comparison_chain docs
pro-grammer1 [Thu, 26 Nov 2020 20:07:50 +0000 (20:07 +0000)]
Added known problem to comparison_chain docs

3 years agoAuto merge of #77671 - flip1995:lint_list_always_plugins, r=oli-obk,Manishearth
bors [Thu, 26 Nov 2020 18:51:45 +0000 (18:51 +0000)]
Auto merge of #77671 - flip1995:lint_list_always_plugins, r=oli-obk,Manishearth

Always print lints from plugins, if they're available

Currently you can get a list of lints and lint groups by running `rustc
-Whelp`. This prints an additional line at the end:
```
Compiler plugins can provide additional lints and lint groups. To see a listing of these, re-run `rustc -W help` with a crate filename.
```

Clippy is such a "compiler plugin", that provides additional lints.
Running `clippy-driver -Whelp` (`rustc` wrapper) still only prints the
rustc lints with the above message at the end. But when running
`clippy-driver -Whelp main.rs`, where `main.rs` is any rust file, it
also prints Clippy lints. I don't think this is a good approach from a
UX perspective: Why is a random file necessary to print a help message?

This PR changes this behavior: Whenever a compiler callback
registers lints, it is assumed that these lints come from a plugin and
are printed without having to specify a Rust source file.

Fixes rust-lang/rust-clippy#6122

cc `@Manishearth` `@ebroto` for the Clippy changes.

3 years agoNote that it is possible to omit the patch version
flip1995 [Thu, 26 Nov 2020 09:15:00 +0000 (10:15 +0100)]
Note that it is possible to omit the patch version

3 years agoRemove mention of possibility to specify the MSRV with a tilde/caret
Philipp Krones [Thu, 26 Nov 2020 09:01:02 +0000 (10:01 +0100)]
Remove mention of possibility to specify the MSRV with a tilde/caret

3 years agoAuto merge of #6362 - nico-abram:unnecessary_cast_dot_float_literal, r=ebroto
bors [Thu, 26 Nov 2020 08:41:16 +0000 (08:41 +0000)]
Auto merge of #6362 - nico-abram:unnecessary_cast_dot_float_literal, r=ebroto

Fix rust-lang/rust#79255 - Incorrect try suggestion for float cast

changelog: Fix rust-lang/rust#79255 - Incorrect try suggestion for float literal cast ending in dot

3 years agoFix rust-lang/rust#79255 - Incorrect try suggestion for unnecessary float literal...
unknown [Sun, 22 Nov 2020 00:08:32 +0000 (21:08 -0300)]
Fix rust-lang/rust#79255 - Incorrect try suggestion for unnecessary float literal cast ending in dot

3 years agoAuto merge of #6379 - Suyash458:master, r=flip1995
bors [Wed, 25 Nov 2020 19:41:42 +0000 (19:41 +0000)]
Auto merge of #6379 - Suyash458:master, r=flip1995

update readme for specifying msrv

changelog: add some documentation for the `msrv` feature (#6097)
related PR: https://github.com/rust-lang/rust-clippy/pull/6201

3 years agoFix formatting in README.md
Philipp Krones [Wed, 25 Nov 2020 19:37:32 +0000 (20:37 +0100)]
Fix formatting in README.md

3 years agoupdate README.md
Suyash458 [Wed, 25 Nov 2020 16:39:50 +0000 (22:09 +0530)]
update README.md

3 years agoAuto merge of #6333 - PunitLodha:master, r=flip1995
bors [Wed, 25 Nov 2020 16:02:42 +0000 (16:02 +0000)]
Auto merge of #6333 - PunitLodha:master, r=flip1995

Added lint str_to_string

*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: un-deprecate [`str_to_string`] and [`string_to_string`] and introduce them as `restriction` lints again.
Fixes #5610
Added new lint:- str_to_string
r? `@flip1995`

3 years agoupdate README.md for specifying msrv
Suyash458 [Wed, 25 Nov 2020 15:46:44 +0000 (21:16 +0530)]
update README.md for specifying msrv

3 years agoadded lints str_to_string and string_to_string
PunitLodha [Sat, 14 Nov 2020 13:51:33 +0000 (19:21 +0530)]
added lints str_to_string and string_to_string

3 years agoAuto merge of #6201 - Suyash458:master, r=flip1995
bors [Wed, 25 Nov 2020 11:39:30 +0000 (11:39 +0000)]
Auto merge of #6201 - Suyash458:master, r=flip1995

Add support for minimum supported rust version

add configuration option for minimum supported rust version
add msrv attribute to some lints listed in #6097
add tests
addresses #6097

changelog: Add `msrv` configuration to Clippy. This should get a longer changelog entry.

3 years agoAdd test for multiple defined msrv attrs
flip1995 [Wed, 25 Nov 2020 11:19:42 +0000 (12:19 +0100)]
Add test for multiple defined msrv attrs

3 years agoAdd note where the first definition of msrv attr is
flip1995 [Wed, 25 Nov 2020 11:19:13 +0000 (12:19 +0100)]
Add note where the first definition of msrv attr is

3 years agoImprove extract_msrv_attr! situation
flip1995 [Wed, 25 Nov 2020 10:50:13 +0000 (11:50 +0100)]
Improve extract_msrv_attr! situation

3 years agoadd support for minimum supported rust version.
Suyash458 [Wed, 21 Oct 2020 12:47:34 +0000 (18:17 +0530)]
add support for minimum supported rust version.

add configuration option for minimum supported rust version
add msrv attribute to some lints listed in #6097
add tests

3 years agoChange `redundant_pattern_matching` to also lint `std::net::IpAddr`
Christiaan Dirkx [Wed, 25 Nov 2020 01:01:05 +0000 (02:01 +0100)]
Change `redundant_pattern_matching` to also lint `std::net::IpAddr`

Suggest using utility methods `is_ipv4` and `is_ipv6`.

3 years agoMove lev_distance to rustc_ast, make non-generic
Arlie Davis [Thu, 12 Nov 2020 19:24:10 +0000 (11:24 -0800)]
Move lev_distance to rustc_ast, make non-generic

rustc_ast currently has a few dependencies on rustc_lexer. Ideally, an AST
would not have any dependency its lexer, for minimizing unnecessarily
design-time dependencies. Breaking this dependency would also have practical
benefits, since modifying rustc_lexer would not trigger a rebuild of rustc_ast.

This commit does not remove the rustc_ast --> rustc_lexer dependency,
but it does remove one of the sources of this dependency, which is the
code that handles fuzzy matching between symbol names for making suggestions
in diagnostics. Since that code depends only on Symbol, it is easy to move
it to rustc_span. It might even be best to move it to a separate crate,
since other tools such as Cargo use the same algorithm, and have simply
contain a duplicate of the code.

This changes the signature of find_best_match_for_name so that it is no
longer generic over its input. I checked the optimized binaries, and this
function was duplicated at nearly every call site, because most call sites
used short-lived iterator chains, generic over Map and such. But there's
no good reason for a function like this to be generic, since all it does
is immediately convert the generic input (the Iterator impl) to a concrete
Vec<Symbol>. This has all of the costs of generics (duplicated method bodies)
with no benefit.

Changing find_best_match_for_name to be non-generic removed about 10KB of
code from the optimized binary. I know it's a drop in the bucket, but we have
to start reducing binary size, and beginning to tame over-use of generics
is part of that.

3 years agoAuto merge of #6339 - CDirkx:redundant-pattern-match-poll, r=ebroto
bors [Tue, 24 Nov 2020 23:19:43 +0000 (23:19 +0000)]
Auto merge of #6339 - CDirkx:redundant-pattern-match-poll, r=ebroto

Change `redundant_pattern_matching` to also lint `std::task::Poll`

`reduntant_pattern_matching` currently lints pattern matching on `Option` and `Result` where the `is_variant` utility methods could be used instead: `is_some`, `is_none`, `is_ok`, `is_err`. This PR extends this behaviour to `std::task::Poll`, suggesting the methods `is_pending` and `is_ready`.

Motivation: The current description of `redundant_pattern_matching` mentions

> It's more concise and clear to just use the proper utility function

which in my mind applies to `Poll` as well.

changelog: Enhance [`redundant_pattern_matching`] to also lint on `std::task::Poll`

3 years agoAuto merge of #6374 - flip1995:rustup, r=flip1995
bors [Tue, 24 Nov 2020 16:07:11 +0000 (16:07 +0000)]
Auto merge of #6374 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: [`panic`],[`unimplemented`],[`unreachable`],[`todo`] now also handle the `core::` version of those macros correctly.

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Tue, 24 Nov 2020 15:59:28 +0000 (16:59 +0100)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agoclippy: Remove now obsolete lintlist module
flip1995 [Wed, 7 Oct 2020 14:05:13 +0000 (16:05 +0200)]
clippy: Remove now obsolete lintlist module

Also stop updating the lintlist module in clippy_dev update_lints

3 years agoclippy: Let rustc handle describing lints
flip1995 [Wed, 7 Oct 2020 14:04:22 +0000 (16:04 +0200)]
clippy: Let rustc handle describing lints