]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #7460 - camsteffen:run-from-source, r=Manishearth
bors [Thu, 15 Jul 2021 21:53:17 +0000 (21:53 +0000)]
Auto merge of #7460 - camsteffen:run-from-source, r=Manishearth

Add instructions to run from source

changelog: none

We often get messages on Zulip asking how to install and run Clippy from source. This adds instructions to the readme. I also added a note explaining that `cargo install --path . --force` is bad, which I just decided after some investigating. I use macOS. It would be nice to get some tests on other platforms to see if this is correct.

2 years agoAdd instructions to run from source
Cameron Steffen [Tue, 13 Jul 2021 15:09:24 +0000 (10:09 -0500)]
Add instructions to run from source

2 years agoAuto merge of #7468 - flip1995:rustup, r=flip1995
bors [Thu, 15 Jul 2021 08:37:36 +0000 (08:37 +0000)]
Auto merge of #7468 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

2 years agoBump nightly version -> 2021-07-15
flip1995 [Thu, 15 Jul 2021 08:32:21 +0000 (10:32 +0200)]
Bump nightly version -> 2021-07-15

2 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 15 Jul 2021 08:21:01 +0000 (10:21 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

2 years agoAuto merge of #7308 - lengyijun:redundant_allocation_arc, r=xFrednet,flip1995
bors [Thu, 15 Jul 2021 07:20:37 +0000 (07:20 +0000)]
Auto merge of #7308 - lengyijun:redundant_allocation_arc, r=xFrednet,flip1995

add Arc to `redundant_allocation`

 fixes #7303
changelog:  add Arc to `redundant_allocation`

2 years agoredundant_allocation: add Arc; some refractoring.
lyj [Wed, 2 Jun 2021 05:41:52 +0000 (13:41 +0800)]
redundant_allocation: add Arc; some refractoring.

2 years agoAuto merge of #7462 - xFrednet:7369-branches-sharing-code-else-expr-fp, r=camsteffen
bors [Wed, 14 Jul 2021 20:29:56 +0000 (20:29 +0000)]
Auto merge of #7462 - xFrednet:7369-branches-sharing-code-else-expr-fp, r=camsteffen

FP fix and documentation for `branches_sharing_code` lint

Closes rust-lang/rust-clippy#7369

Related rust-lang/rust-clippy#7452 I'm still thinking about the best way to fix this. I could simply add another visitor to ensure that the moved expressions don't modify values being used in the condition, but I'm not totally happy with this due to the complexity. I therefore only documented it for now

changelog: [`branches_sharing_code`] fixed false positive where block expressions would sometimes be ignored.

2 years agoFixed `branches_sharing_code` FP with block expressions in else
xFrednet [Tue, 13 Jul 2021 21:27:19 +0000 (23:27 +0200)]
Fixed `branches_sharing_code` FP with block expressions in else

And added `branches_sharing_code` PF note to lint doc for `rust-clippy#7452`

2 years agoAuto merge of #7437 - ebobrow:redundant-closure-move, r=flip1995
bors [Wed, 14 Jul 2021 15:15:28 +0000 (15:15 +0000)]
Auto merge of #7437 - ebobrow:redundant-closure-move, r=flip1995

suggest `&mut` for redundant FnMut closures

fixes #6903

changelog: suggest `&mut` for redundant FnMut closures

2 years agosuggest `&mut` for redundant FnMut closures
Elliot Bobrow [Sat, 3 Jul 2021 03:25:55 +0000 (20:25 -0700)]
suggest `&mut` for redundant FnMut closures

2 years agoAuto merge of #7346 - lengyijun:redundant_clone_5707, r=oli-obk
bors [Wed, 14 Jul 2021 10:10:14 +0000 (10:10 +0000)]
Auto merge of #7346 - lengyijun:redundant_clone_5707, r=oli-obk

fix 5707

changelog: ``[`redundant_clone`]``, fix #5707

# Root problem of #5707 :
```
&2:&mut HashMap = &mut _4;
&3:&str = & _5;
_1 = HashMap::insert(move _2,move _3, _);
```

generate PossibleBorrower(_2,_1) and PossibleBorrower(_3,_1).

However, it misses PossibleBorrower(_3,_2).

# My solution to #5707 :

When meet a function call, we should:
1. build PossibleBorrower between borrow parameters and return value (currently)
2. build PossibleBorrower between immutable borrow parameters and mutable borrow parameters (*add*)
3. build PossibleBorrower inside mutable borrow parameters (*add*)

For example:
```
_2: &mut _22;
_3: &mut _;
_4: & _;
_5: & _;
_1 = call(move _2, move _3, move _4, move _5);
```
we need to build
1. return value with parameter(current implementataion)
 PossibleBorrower(_2,_1)
 PossibleBorrower(_3,_1)
 PossibleBorrower(_4,_1)
 PossibleBorrower(_5,_1)

2. between mutable borrow and immutable borrow
PossibleBorrower(_4,_2)
PossibleBorrower(_5,_2)
PossibleBorrower(_4,_3)
PossibleBorrower(_5,_3)

3. between mutable borrow and mutable borrow
PossibleBorrower(_3,_2)
PossibleBorrower(_2,_3)

  But that's not enough.
 Modification to _2 actually apply to _22.
  So I write a `PossibleBorrowed` visitor, which tracks (borrower => possible borrowed) relation.
  For example (_2 => _22).
  However, a lot of problems exist here.

## Known Problems:
  1. not sure all `&mut`'s origin are collected.
  I'm not sure how to deal with `&mut` when meet a function call, so I didn't do it currently.
  Also, my implement is not flow sensitive, so it's not accurate.

```
foo(_2:&mut _, _3: &_)
```
This pr doesn't count _3 as origin of _2.

 2. introduce false negative
`foo(_2, _3)` will  emit PossibleBorrower(_3,_2) in this pr, but _3 and _2 may not have relation.
Clippy may feel that _3 is still in use because of _2, but actually, _3 is on longer needed and can be moved.

## Insight
  The key problem is determine where every `&mut` come from accurately.
  I think Polonius is an elegant solution to it. Polonius is flow sensitive and accurate.
  But I'm uncertain about whether we can import Polonius in rust-clippy currently.
  This pr actually is part of Polonius' functionality, I think.

# TODO
1. `cargo test` can't pass yet due to similar variable name

2 years agorename possible_borrowed to possible_origin; pass dogfood
lyj [Wed, 14 Jul 2021 03:29:39 +0000 (11:29 +0800)]
rename possible_borrowed to possible_origin; pass dogfood

2 years agofix 5707
lyj [Fri, 11 Jun 2021 12:57:11 +0000 (20:57 +0800)]
fix 5707

2 years agoAuto merge of #86827 - camsteffen:hash-lint-resolved, r=oli-obk
bors [Tue, 13 Jul 2021 15:06:10 +0000 (15:06 +0000)]
Auto merge of #86827 - camsteffen:hash-lint-resolved, r=oli-obk

Fix internal `default_hash_types` lint to use resolved path

I run into false positives now and then (mostly in Clippy) when I want to name some util after HashMap.

2 years agoAuto merge of #7446 - Y-Nak:fix-7445, r=xFrednet,flip1995
bors [Tue, 13 Jul 2021 14:31:02 +0000 (14:31 +0000)]
Auto merge of #7446 - Y-Nak:fix-7445, r=xFrednet,flip1995

`default_numeric_fallback`: Fix FP with floating literal

Fix #7445

changelog: `default_numeric_fallback`: Fix FP with floating literal

2 years ago`default_numeric_fallback`: Add rustfix tests
Yoshitomo Nakanishi [Tue, 13 Jul 2021 13:57:47 +0000 (22:57 +0900)]
`default_numeric_fallback`: Add rustfix tests

2 years agoAuto merge of #7442 - camsteffen:format-args, r=xFrednet
bors [Tue, 13 Jul 2021 13:58:38 +0000 (13:58 +0000)]
Auto merge of #7442 - camsteffen:format-args, r=xFrednet

Refactor `format_args!` expansion parsing

Introduces `FormatExpn::parse` and `FormatArgsExpn::parse`. Motivated by rust-lang/rust#83302, so I only have to change Clippy in one place. Fixed an FP along the way.

I also allowed `needless_bool` in macros because I often want to do `if_chain! { .. then { true } else { false } }`.

changelog: Fix false positive in `useless_format` when some text is appended or prepended to a single string with some useless formatting params
changelog: Allow `needless_bool` in macros

2 years agoSplit a lint message into help
Cameron Steffen [Mon, 12 Jul 2021 01:30:19 +0000 (20:30 -0500)]
Split a lint message into help

2 years agoReduce redundant code
Cameron Steffen [Mon, 12 Jul 2021 01:21:21 +0000 (20:21 -0500)]
Reduce redundant code

2 years agoRefactor format macro parsing
Cameron Steffen [Tue, 6 Jul 2021 16:51:15 +0000 (11:51 -0500)]
Refactor format macro parsing

2 years agoFix useless_format false positive
Cameron Steffen [Sun, 4 Jul 2021 21:34:22 +0000 (16:34 -0500)]
Fix useless_format false positive

2 years agoAllow needless_bool in macro
Cameron Steffen [Wed, 9 Jun 2021 19:44:42 +0000 (14:44 -0500)]
Allow needless_bool in macro

2 years agoFix `NumericLiteral::format` that may produce a invalid literal
Yoshitomo Nakanishi [Tue, 13 Jul 2021 13:56:41 +0000 (22:56 +0900)]
Fix `NumericLiteral::format` that may produce a invalid literal

2 years agoAuto merge of #7458 - flip1995:unused_unit-doc, r=giraffate
bors [Tue, 13 Jul 2021 13:43:12 +0000 (13:43 +0000)]
Auto merge of #7458 - flip1995:unused_unit-doc, r=giraffate

Add fixed example to unused_unit documentation

changelog: none

(don't think this is worth a changelog mention)

2 years agoAdd fixed example to unused_unit documentation
flip1995 [Tue, 13 Jul 2021 08:54:29 +0000 (10:54 +0200)]
Add fixed example to unused_unit documentation

2 years agorustc_span: Revert addition of `proc_macro` field to `ExpnKind::Macro`
Vadim Petrochenkov [Sat, 10 Jul 2021 19:14:52 +0000 (22:14 +0300)]
rustc_span: Revert addition of `proc_macro` field to `ExpnKind::Macro`

The flag has a vague meaning and is used for a single diagnostic change that is low benefit and appears only under `-Z macro_backtrace`.

2 years agoclippy: allow default_hash_types on bootstrap
Cameron Steffen [Thu, 8 Jul 2021 17:59:16 +0000 (12:59 -0500)]
clippy: allow default_hash_types on bootstrap

2 years agoAuto merge of #7449 - flip1995:remove-lints_enabled, r=camsteffen
bors [Fri, 9 Jul 2021 14:00:52 +0000 (14:00 +0000)]
Auto merge of #7449 - flip1995:remove-lints_enabled, r=camsteffen

Remove lints_enabled

r? `@camsteffen`

cc https://github.com/rust-lang/rust-clippy/pull/7448#issuecomment-876497862

I haven't added a variant with `last_node_with_lint_attrs` yet, since I didn't see a usecase for this. Also this field is not documented, so I'm wondering how it behaves with command line lints and so on.

changelog: none

2 years agoRename `is_allowed` -> `is_lint_allowed`
flip1995 [Fri, 9 Jul 2021 13:06:12 +0000 (15:06 +0200)]
Rename `is_allowed` -> `is_lint_allowed`

2 years agoRemove lints_enabled function
flip1995 [Fri, 9 Jul 2021 13:00:24 +0000 (15:00 +0200)]
Remove lints_enabled function

This function was redundant with the is_allowed function. Now is_allowed
is used everywhere lints_enabled was used before.

2 years ago`default_numeric_fallback`: Add more tests for floating literal
Yoshitomo Nakanishi [Fri, 9 Jul 2021 05:51:16 +0000 (14:51 +0900)]
`default_numeric_fallback`: Add more tests for floating literal

2 years agoAuto merge of #7448 - flip1995:run_lints-rename, r=llogiq
bors [Fri, 9 Jul 2021 06:39:56 +0000 (06:39 +0000)]
Auto merge of #7448 - flip1995:run_lints-rename, r=llogiq

Rename run_lints -> lints_enabled

Just a quick rename of a utilities function. `run_lints` kinda suggested that the lints were run by this function. But the only thing this function does is to check if the lints are enabled in the context of the `hir_id`

changelog: none

2 years agoRework SESSION_GLOBALS API to prevent overwriting it
Guillaume Gomez [Wed, 5 May 2021 19:31:25 +0000 (21:31 +0200)]
Rework SESSION_GLOBALS API to prevent overwriting it

2 years agoRename run_lints -> lints_enabled
flip1995 [Thu, 8 Jul 2021 13:45:19 +0000 (15:45 +0200)]
Rename run_lints -> lints_enabled

2 years agodefault_numeric_fallback: Fix FP with floating literal
Yoshitomo Nakanishi [Thu, 8 Jul 2021 02:37:12 +0000 (11:37 +0900)]
default_numeric_fallback: Fix FP with floating literal

2 years agoAuto merge of #86920 - JohnTitor:rollup-buvzpkr, r=JohnTitor
bors [Wed, 7 Jul 2021 03:31:23 +0000 (03:31 +0000)]
Auto merge of #86920 - JohnTitor:rollup-buvzpkr, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #80918 (Add Integer::log variants)
 - #86717 (Rename some Rust 2021 lints to better names )
 - #86819 (Clean up rustdoc IDs)
 - #86880 (Test ManuallyDrop::clone_from.)
 - #86906 (Replace deprecated compare_and_swap and fix typo in core::sync::atomic::{fence, compiler_fence} docs)
 - #86907 (Migrate `cpu-usage-over-time.py` to Python 3)
 - #86916 (rewrote documentation for thread::yield_now())
 - #86919 (Update books)

Failed merges:

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

2 years agoMake type_implements_trait not a query
Aman Arora [Tue, 6 Jul 2021 09:38:15 +0000 (05:38 -0400)]
Make type_implements_trait not a query

2 years agoAdd s to non_fmt_panic
Ryan Levick [Tue, 29 Jun 2021 18:33:31 +0000 (20:33 +0200)]
Add s to non_fmt_panic

2 years agoAuto merge of #7439 - iobtl:assert_msg_panic_fp, r=flip1995
bors [Tue, 6 Jul 2021 08:22:57 +0000 (08:22 +0000)]
Auto merge of #7439 - iobtl:assert_msg_panic_fp, r=flip1995

Fix false-positive `assert` in `panic`

This PR fixes a false-positive in `clippy::panic` when using the `assert` macro with its optional message parameter.

Fixes: #7433
changelog: `panic_unimplemented.rs`: added condition to exclude `assert` macro, similar to `debug_assert`
changelog: `panicking_macros.rs`: relevant tests to check for `assert` usage.

2 years agofix false positive (panic message) with assert macro using message parameter
iobtl [Tue, 6 Jul 2021 07:14:53 +0000 (15:14 +0800)]
fix false positive (panic message) with assert macro using message parameter

2 years agoAuto merge of #7243 - mgacek8:issue7145_strlen_on_c_strings, r=giraffate
bors [Mon, 5 Jul 2021 13:12:43 +0000 (13:12 +0000)]
Auto merge of #7243 - mgacek8:issue7145_strlen_on_c_strings, r=giraffate

Add new lint: `strlen_on_c_strings`

~~This is WIP, linting in case of `CString` has been added, but for `CStr`, its diagnostic item needs to be available for clippy.
[PR that adds diagnostic item for CStr on rust repo](https://github.com/rust-lang/rust/pull/85439).~~
Ready for the review. Please take a look.
fixes #7145
changelog: Add new lint: `strlen_on_c_strings`, that lints on `libc::strlen(some_cstring.as_ptr())`

2 years agoAdd new lint: strlen_on_c_strings
Mateusz Gacek [Tue, 18 May 2021 13:19:56 +0000 (15:19 +0200)]
Add new lint: strlen_on_c_strings

2 years agorevert broken formatting
Niko Matsakis [Sun, 4 Jul 2021 16:50:41 +0000 (12:50 -0400)]
revert broken formatting

2 years agoAuto merge of #7431 - DevinR528:fix-macro-brace, r=llogiq
bors [Sun, 4 Jul 2021 16:47:11 +0000 (16:47 +0000)]
Auto merge of #7431 - DevinR528:fix-macro-brace, r=llogiq

Fix emitting in nested (proc_)macros for nonstandard_macro_braces lint

fixes #7422

changelog: fixes false positives in [`nonstandard_macro_braces`]

2 years agoallow inference vars in type_implements_trait
Niko Matsakis [Sun, 4 Jul 2021 15:26:32 +0000 (11:26 -0400)]
allow inference vars in  type_implements_trait

3 years agoFix emitting in nested (proc_)macros for nonstandard_macro_braces lint
Devin Ragotzy [Sun, 4 Jul 2021 11:06:23 +0000 (07:06 -0400)]
Fix emitting in nested (proc_)macros for nonstandard_macro_braces lint

3 years agoAuto merge of #7428 - camsteffen:use-self-ice, r=flip1995
bors [Sat, 3 Jul 2021 19:09:05 +0000 (19:09 +0000)]
Auto merge of #7428 - camsteffen:use-self-ice, r=flip1995

Fix use_self ICE

changelog: Fix ICE #7423

r? `@flip1995`

3 years agoFix use_self ICE
Cameron Steffen [Sat, 3 Jul 2021 17:40:50 +0000 (12:40 -0500)]
Fix use_self ICE

3 years agoAuto merge of #7426 - ebobrow:doc-markdown-fp, r=llogiq
bors [Sat, 3 Jul 2021 16:53:21 +0000 (16:53 +0000)]
Auto merge of #7426 - ebobrow:doc-markdown-fp, r=llogiq

fix doc_markdown false positive

fixes #7421

changelog: don't lint unbalanced tick marks in code blocks

3 years agofix doc_markdown false positive
Elliot Bobrow [Sat, 3 Jul 2021 16:34:10 +0000 (09:34 -0700)]
fix doc_markdown false positive

3 years agoAuto merge of #7316 - lengyijun:rc_mutex, r=llogiq
bors [Sat, 3 Jul 2021 10:26:03 +0000 (10:26 +0000)]
Auto merge of #7316 - lengyijun:rc_mutex, r=llogiq

Add new lint: `rc_mutex`

changelog: Add new lint `rc_mutex`.

It lints on `Rc<Mutex<T>>`.

`Rc<Mutex<T>>` should be corrected to `Rc<RefCell<T>>`

3 years agoAuto merge of #7424 - dtolnay-contrib:macrobraces, r=llogiq
bors [Sat, 3 Jul 2021 10:14:01 +0000 (10:14 +0000)]
Auto merge of #7424 - dtolnay-contrib:macrobraces, r=llogiq

Downgrade nonstandard_macro_braces to nursery

Due to the large number of crates impacted by #7422, I don't think this lint can be enabled by default right now until the false positive is fixed.

---

changelog: remove [`nonstandard_macro_braces`] from default set of enabled lints

3 years agoDowngrade nonstandard_macro_braces to nursery
David Tolnay [Sat, 3 Jul 2021 05:14:32 +0000 (22:14 -0700)]
Downgrade nonstandard_macro_braces to nursery

3 years agorc_mutex: known problems
lyj [Fri, 2 Jul 2021 14:10:13 +0000 (22:10 +0800)]
rc_mutex: known problems

3 years agoAuto merge of #86782 - flip1995:clippyup, r=Manishearth
bors [Fri, 2 Jul 2021 02:56:45 +0000 (02:56 +0000)]
Auto merge of #86782 - flip1995:clippyup, r=Manishearth

Update Clippy

Biweekly Clippy Update

r? `@Manishearth`

3 years agoMerge commit '61eb38aeda6cb54b93b872bf503d70084c4d621c' into clippyup
flip1995 [Thu, 1 Jul 2021 16:17:38 +0000 (18:17 +0200)]
Merge commit '61eb38aeda6cb54b93b872bf503d70084c4d621c' into clippyup

3 years agoAuto merge of #7418 - flip1995:rustup, r=flip1995
bors [Thu, 1 Jul 2021 15:43:14 +0000 (15:43 +0000)]
Auto merge of #7418 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none

3 years agoBump nightly version -> 2021-07-01
flip1995 [Thu, 1 Jul 2021 15:41:34 +0000 (17:41 +0200)]
Bump nightly version -> 2021-07-01

3 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Thu, 1 Jul 2021 15:17:19 +0000 (17:17 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

3 years agoAuto merge of #7407 - m-ou-se:doc-hidden-variants, r=flip1995
bors [Thu, 1 Jul 2021 15:02:21 +0000 (15:02 +0000)]
Auto merge of #7407 - m-ou-se:doc-hidden-variants, r=flip1995

Don't suggest doc(hidden) or unstable variants in wildcard lint

Clippy's wildcard lint would suggest doc(hidden) and unstable variants for non_exhaustive enums, even though those aren't part of the public interface (yet) and should only be matched on using a `_`, just like potential future additions to the enum. There was already some logic to exclude a *single* doc(hidden) variant. This extends that to all hidden variants, and also hides `#[unstable]` variants.

See https://github.com/rust-lang/rust/pull/85746#issuecomment-868886893

This PR includes https://github.com/rust-lang/rust-clippy/pull/7406 as the first commit.

Here's the diff that this PR adds on top of that PR: https://github.com/m-ou-se/rust-clippy/compare/std-errorkind...m-ou-se:doc-hidden-variants

---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: No longer suggest unstable and doc(hidden) variants in wildcard lint. wildcard_enum_match_arm, match_wildcard_for_single_variants

3 years agoRename all_crate_nums query to crates and remove useless wrapper
bjorn3 [Mon, 7 Jun 2021 09:03:17 +0000 (11:03 +0200)]
Rename all_crate_nums query to crates and remove useless wrapper

3 years agomatch_wildcard_for_single_variants: don't produce bad suggestion
flip1995 [Thu, 1 Jul 2021 10:35:16 +0000 (12:35 +0200)]
match_wildcard_for_single_variants: don't produce bad suggestion

This fixes a bug where match_wildcard_for_single_variants produced a
bad suggestion where besides the missing variant, one or more hidden
variants were left.

This also adds tests to the ui-tests match_wildcard_for_single_variants
and wildcard_enum_match_arm to make sure that the correct suggestion is
produced.

3 years agoSimplify wildcard_enum_match_arm test
flip1995 [Thu, 1 Jul 2021 09:47:56 +0000 (11:47 +0200)]
Simplify wildcard_enum_match_arm test

3 years agoAuto merge of #7400 - popzxc:restrict-locales, r=Manishearth
bors [Wed, 30 Jun 2021 18:14:16 +0000 (18:14 +0000)]
Auto merge of #7400 - popzxc:restrict-locales, r=Manishearth

New lint: `disallowed_script_idents`

This PR implements a new lint to restrict locales that can be used in the code,
as proposed in #7376.

Current concerns / unresolved questions:

- ~~Mixed usage of `script` (as a Unicode term) and `locale` (as something that is easier to understand for the broad audience). I'm not sure whether these terms are fully interchangeable and whether in the current form it is more confusing than helpful.~~ `script` is now used everywhere.
- ~~Having to mostly copy-paste `AllowedScript`. Probably it's not a big problem, as the list of scripts is standardized and is unlikely to change, and even if we'd stick to the `unicode_script::Script`, we'll still have to implement custom deserialization, and I don't think that it will be shorter in terms of the amount of LoC.~~ `unicode::Script` is used together with a filtering deserialize function.
- Should we stick to the list of "recommended scripts" from [UAX #31](http://www.unicode.org/reports/tr31/#Table_Recommended_Scripts) in the configuration?

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: ``[`disallowed_script_idents`]``

r? `@Manishearth`

3 years agoImplement 'disallowed_script_idents' lint
Igor Aleksanov [Wed, 30 Jun 2021 16:06:33 +0000 (19:06 +0300)]
Implement 'disallowed_script_idents' lint

3 years agoAuto merge of #7390 - popzxc:issue-7331, r=flip1995
bors [Wed, 30 Jun 2021 15:12:55 +0000 (15:12 +0000)]
Auto merge of #7390 - popzxc:issue-7331, r=flip1995

Improve lint message for match-same-arms lint

fixes #7331

Follow-up to #7377

This PR improves the lint message for `match-same-arms` lint and adds `todo!(..)`  example to the lint docs.

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: None

3 years agoAuto merge of #7411 - camsteffen:use-self-visitor, r=flip1995
bors [Tue, 29 Jun 2021 13:23:04 +0000 (13:23 +0000)]
Auto merge of #7411 - camsteffen:use-self-visitor, r=flip1995

Simplify use_self impl

changelog: none

Mainly to remove an extra visit and simplify the "in body?" logic.

3 years agoRemove a visitor from use_self
Cameron Steffen [Wed, 16 Jun 2021 17:14:23 +0000 (12:14 -0500)]
Remove a visitor from use_self

3 years agoUse type_of for impl self type
Cameron Steffen [Wed, 16 Jun 2021 20:43:48 +0000 (15:43 -0500)]
Use type_of for impl self type

3 years agoSimplify in impl check
Cameron Steffen [Wed, 16 Jun 2021 17:23:09 +0000 (12:23 -0500)]
Simplify in impl check

3 years agoMake ItemKind check dry
Cameron Steffen [Thu, 17 Jun 2021 16:19:33 +0000 (11:19 -0500)]
Make ItemKind check dry

3 years agoAuto merge of #7405 - jyn514:fix-stable, r=camsteffen
bors [Tue, 29 Jun 2021 13:03:45 +0000 (13:03 +0000)]
Auto merge of #7405 - jyn514:fix-stable, r=camsteffen

Stabilize `cargo clippy --fix`

This has been unstable since it was first introduced in
https://github.com/rust-lang/rust-clippy/pull/5363. In that time, I have
been using it successfully in nightly without issues. I don't think
there are any blocking issues now that RUSTC_WORKSPACE_WRAPPER is
stabilized, so this can be stabilized.

changelog: Stabilize `cargo clippy --fix`

3 years agoAuto merge of #7409 - xFrednet:5394-vs-code-tasks, r=giraffate,flip1995
bors [Tue, 29 Jun 2021 08:53:59 +0000 (08:53 +0000)]
Auto merge of #7409 - xFrednet:5394-vs-code-tasks, r=giraffate,flip1995

Added `cargo dev setup vscode-tasks` for simplicity

This PR adds a setup command to `clippy dev` that installs tasks into the Clippy vscode workspace. These might be useful as they be used via shortcuts and are accessible over the GUI. The available tasks are:
* `cargo check` (standard Linux shortcut `[ctrl] + [shift] + b`)
* `cargo dev fmt`
* `cargo uitest` (with a comment how to add the `TESTNAME` environment value)
* `cargo test`
* `cargo dev bless`

---

changelog: none

only internal changes again. cc #5394

r? `@flip1995` This should be pretty much the same as the other `cargo dev setup` commands. Would you mind reviewing this? :upside_down_face:

3 years agoStabilize `cargo clippy --fix`
Joshua Nelson [Sat, 26 Jun 2021 01:41:56 +0000 (21:41 -0400)]
Stabilize `cargo clippy --fix`

This has been unstable since it was first introduced in
https://github.com/rust-lang/rust-clippy/pull/5363. In that time, I have
been using it successfully in nightly without issues. I don't think
there are any blocking issues now that RUSTC_WORKSPACE_WRAPPER is
stabilized, so this can be stabilized.

3 years agoUpdated `clippy_dev` ui message and vscode task name
xFrednet [Mon, 28 Jun 2021 18:40:09 +0000 (20:40 +0200)]
Updated `clippy_dev` ui message and vscode task name

Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
3 years agoAuto merge of #7350 - camsteffen:suspicious, r=flip1995
bors [Mon, 28 Jun 2021 08:35:51 +0000 (08:35 +0000)]
Auto merge of #7350 - camsteffen:suspicious, r=flip1995

Add suspicious group

changelog: Introduce `clippy::suspicious` ðŸ¤” group and move several lints into the group

Closes #6366. CC #6626.

A number of lints are moved from each of `correctness`, `style` and `complexity` groups. Notably I didn't move `suspicious_splitn` since I think that is a `correctness` lint despite the name.

Lints moved to `clippy::suspicious`:
* `blanket_clippy_restriction_lints` (was `clippy::style`)
* `empty_loop` (was `clippy::style`)
* `eval_order_dependence` (was `clippy::complexity`)
* `float_equality_without_abs` (was `clippy::correctness`)
* `for_loops_over_fallibles` (was `clippy::correctness`)
* `misrefactored_assign_op` (was `clippy::complexity`)
* `mut_range_bound` (was `clippy::complexity`)
* `mutable_key_type` (was `clippy::correctness`)
* `suspicious_arithmetic_impl` (was `clippy::correctness`)
* `suspicious_assignment_formatting` (was `clippy::style`)
* `suspicious_else_formatting` (was `clippy::style`)
* `suspicious_map` (was `clippy::complexity`)
* `suspicious_op_assign_impl` (was `clippy::correctness`)
* `suspicious_unary_op_formatting` (was `clippy::style`)

3 years agoAdded `cargo dev setup vscode-tasks` for simplicity
xFrednet [Sun, 27 Jun 2021 14:59:17 +0000 (16:59 +0200)]
Added `cargo dev setup vscode-tasks` for simplicity

3 years agoDon't suggest unstable and doc(hidden) variants.
Mara Bos [Sat, 26 Jun 2021 13:22:15 +0000 (15:22 +0200)]
Don't suggest unstable and doc(hidden) variants.

3 years agoDon't use exact definition of std's ErrorKind in test.
Mara Bos [Sat, 26 Jun 2021 12:50:42 +0000 (14:50 +0200)]
Don't use exact definition of std's ErrorKind in test.

Every time we add something to this enum in std, this test breaks.

3 years agoAdd remark-gfm to workflow job
Cameron Steffen [Fri, 25 Jun 2021 15:24:44 +0000 (10:24 -0500)]
Add remark-gfm to workflow job

3 years agoMove some lints to suspicious
Cameron Steffen [Mon, 14 Jun 2021 19:09:17 +0000 (14:09 -0500)]
Move some lints to suspicious

3 years agoAdd suspicious group
Cameron Steffen [Mon, 14 Jun 2021 15:01:43 +0000 (10:01 -0500)]
Add suspicious group

3 years agoFix clippy test
Ryan Levick [Fri, 25 Jun 2021 13:29:14 +0000 (15:29 +0200)]
Fix clippy test

3 years agoAuto merge of #7379 - popzxc:issue-7305, r=flip1995
bors [Fri, 25 Jun 2021 10:12:05 +0000 (10:12 +0000)]
Auto merge of #7379 - popzxc:issue-7305, r=flip1995

Do not spawn blacklisted_name lint in test context

---

fixed #7305

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: `blacklisted_name` lint is not spawned in the test context anymore.

3 years agoDo not spawn blacklisted_name lint in test context
Igor Aleksanov [Sat, 19 Jun 2021 18:14:05 +0000 (21:14 +0300)]
Do not spawn blacklisted_name lint in test context

Fix detecting of the 'test' attribute

Update UI test to actually check that warning is not triggered in the test code

Fix approach for detecting the test module

Add nested test case

Remove code duplication by extracting 'is_test_module_or_function' into 'clippy_utils'

Cleanup the code

3 years agoImprove lint message for match-same-arms lint
Igor Aleksanov [Tue, 22 Jun 2021 12:34:46 +0000 (15:34 +0300)]
Improve lint message for match-same-arms lint

Simplify error message producing & remove extra example

3 years agoAuto merge of #7361 - xFrednet:5394-expand-setup-command, r=flip1995
bors [Fri, 25 Jun 2021 09:22:04 +0000 (09:22 +0000)]
Auto merge of #7361 - xFrednet:5394-expand-setup-command, r=flip1995

Added `cargo dev setup git-hook` and updated `cargo dev setup intellij` including a `remove` command

This PR enables our dev tool to install a git hook that formats the code before each commit and also runs `update_lints` to make sure that everything is registered correctly. The script is located at `util/etc/pre-commit.sh`. I found it reasonable to locate it in the `util` folder and decided to add a `etc` in correlation to the main rust repo and to bring a bit of structure into it.

* The hook can be installed via: `cargo dev setup git-hook`
* And removed via: `cargo dev remove git-hook`

cc: #5394

The refactoring of `src/ide_setup.rs` to `src/setup/intellij.rs` is an extra commit to simplify the review.

---

Changes:
* Added `cargo dev setup git-hook` for formatting before every commit
* Added `cargo dev remove git-hook` to remove the hook again
* Added `cargo dev remove intellij` to remove rustc source path dependencies
* Changed `cargo dev ide_setup` to `cargo dev setup intellij`

changelog: none

This is only an internal change and therefore not worth an entry in the general change log.

---

Tested on:
* [x] Linux (by `@xFrednet)`
* [ ] Windows (All used commands run inside the git bash, so it's very likely to work as well `@xFrednet)`
* [ ] macOS

3 years agoUpdated several clippy_dev messages and types (PR suggestions)
xFrednet [Wed, 23 Jun 2021 17:04:09 +0000 (19:04 +0200)]
Updated several clippy_dev messages and types (PR suggestions)

Co-authored-by: Philipp Krones <hello@philkrones.com>
3 years agoAdded `cargo dev remove intellij`
xFrednet [Tue, 22 Jun 2021 18:13:05 +0000 (20:13 +0200)]
Added `cargo dev remove intellij`

3 years agoUpdated `cargo dev setup intellij` for cleaner user messages
xFrednet [Mon, 21 Jun 2021 22:25:10 +0000 (00:25 +0200)]
Updated `cargo dev setup intellij` for cleaner user messages

3 years agoAdded the `cargo dev remove` command for convenience
xFrednet [Wed, 16 Jun 2021 16:59:28 +0000 (18:59 +0200)]
Added the `cargo dev remove` command for convenience

3 years agoPrint cargo dev help on missing arg and updated setup documentation
xFrednet [Tue, 15 Jun 2021 22:21:13 +0000 (00:21 +0200)]
Print cargo dev help on missing arg and updated setup documentation

3 years agoAdjust pre-commit script to readd files after formatting
xFrednet [Tue, 15 Jun 2021 22:04:50 +0000 (00:04 +0200)]
Adjust pre-commit script to readd files after formatting

3 years agoAdded `cargo dev setup git-hook`
xFrednet [Thu, 10 Jun 2021 23:05:51 +0000 (01:05 +0200)]
Added `cargo dev setup git-hook`

3 years agoMoved dev `ide_setup` to `setup/intellij.rs`
xFrednet [Thu, 10 Jun 2021 18:45:03 +0000 (20:45 +0200)]
Moved dev `ide_setup` to `setup/intellij.rs`

3 years agoAuto merge of #7300 - DevinR528:import-rename, r=camsteffen
bors [Thu, 24 Jun 2021 20:23:13 +0000 (20:23 +0000)]
Auto merge of #7300 - DevinR528:import-rename, r=camsteffen

Add import_rename lint, this adds a field on the Conf struct

fixes #7276

changelog: Add ``[`import_rename`]`` a lint that enforces import renaming defined in the config file.

3 years agoAdd import_rename lint, this adds a field on the Conf struct
Devin Ragotzy [Mon, 31 May 2021 18:15:17 +0000 (14:15 -0400)]
Add import_rename lint, this adds a field on the Conf struct

Rename lint and fix review issues

3 years agoAuto merge of #7396 - ranweiler:zero-offset, r=Manishearth
bors [Wed, 23 Jun 2021 22:22:39 +0000 (22:22 +0000)]
Auto merge of #7396 - ranweiler:zero-offset, r=Manishearth

Fix invocation of `zst_offset` lint

The `zst_offset` lint was broken by a refactoring regression in 21083875d211c29fcfa4a21fcd66d4601d2b618b. In the invocation of the `zst_offset` check [here](https://github.com/rust-lang/rust-clippy/commit/21083875d211c29fcfa4a21fcd66d4601d2b618b#diff-7f73f6fe28c04b654223c09c42fe02937d2351fc58a91d21ab812aaf6f9b185dR1927), we shadow the already-destructured receiver `recv`, and accidentally pass the first argument of the method as if it were the receiver.

This was not caught because the UI test expectation was never correct (a bad cast obscured the actual test result).

This PR:
- Fixes the existing test expectation
- Tests both `const` and `mut` raw pointers
- Passes the actual receiver to the lint's implementation

Fixes #7395.

changelog: Fix [`zst_offset`] invocation and test

3 years agoAuto merge of #7394 - ehuss:update-opener, r=ehuss
bors [Wed, 23 Jun 2021 18:49:31 +0000 (18:49 +0000)]
Auto merge of #7394 - ehuss:update-opener, r=ehuss

Update opener.

This updates the opener dependency, to try to reduce the duplicate dependencies in the rust-lang/rust repo.  The changelog is [here](https://github.com/Seeker14491/opener/blob/master/CHANGELOG.md#050---2021-06-11), and I don't expect it to have much of a change to anyone.

changelog: none