Commit graph

6184 commits

Author SHA1 Message Date
bors
f70a07454b Auto merge of #7403 - Anthuang:redundant-method-names, r=Manishearth
New lint: [`self_named_constructor`]

Adds the `self_named_constructor` lint for detecting when an implemented method has the same name as the type it is implemented for.

changelog: [`self_named_constructor`]

closes: #7142
2021-07-19 06:49:51 +00:00
Cameron Steffen
98c500cf83 Factor BinOp utils 2021-07-17 20:49:19 -05:00
Cameron Steffen
efbf7ca61e Use From to convert BinOpKind 2021-07-17 20:25:26 -05:00
flip1995
69fbd64e2a
Merge remote-tracking branch 'upstream/master' into rustup 2021-07-15 10:32:06 +02:00
lyj
e575610fb3 redundant_allocation: add Arc; some refractoring. 2021-07-15 07:10:55 +08:00
bors
2b193e247f 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.
2021-07-14 20:29:56 +00:00
xFrednet
61e280863f Fixed branches_sharing_code FP with block expressions in else
And added `branches_sharing_code` PF note to lint doc for `rust-clippy#7452`
2021-07-14 21:37:17 +02:00
bors
4acbff9eb0 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
2021-07-14 15:15:28 +00:00
Elliot Bobrow
4c398e07e0 suggest &mut for redundant FnMut closures 2021-07-14 07:56:27 -07:00
lyj
10910020ec rename possible_borrowed to possible_origin; pass dogfood 2021-07-14 13:46:33 +08:00
lyj
251c3b64da fix 5707 2021-07-14 10:57:47 +08:00
bors
2fd8dbc8af 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.
2021-07-13 15:06:10 +00:00
bors
8131445e53 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
2021-07-13 14:31:02 +00:00
Yoshitomo Nakanishi
25e4c7d73f default_numeric_fallback: Add rustfix tests 2021-07-13 23:18:31 +09:00
Cameron Steffen
306f9e843d Split a lint message into help 2021-07-13 08:57:16 -05:00
Cameron Steffen
73ffae6ea1 Reduce redundant code 2021-07-13 08:57:16 -05:00
Cameron Steffen
e6ab222b81 Refactor format macro parsing 2021-07-13 08:57:16 -05:00
Cameron Steffen
20dbb277cf Fix useless_format false positive 2021-07-13 08:57:16 -05:00
Cameron Steffen
3fc8dae46c Allow needless_bool in macro 2021-07-13 08:57:16 -05:00
flip1995
f05949f9ce
Add fixed example to unused_unit documentation 2021-07-13 10:54:29 +02:00
Vadim Petrochenkov
075a28996c 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`.
2021-07-10 23:03:35 +03:00
Cameron Steffen
dce274024e clippy: allow default_hash_types on bootstrap 2021-07-09 09:10:45 -05:00
flip1995
d2c8f50bbe
Rename is_allowed -> is_lint_allowed 2021-07-09 15:06:12 +02:00
flip1995
5add651223
Remove lints_enabled function
This function was redundant with the is_allowed function. Now is_allowed
is used everywhere lints_enabled was used before.
2021-07-09 15:00:24 +02:00
Guillaume Gomez
3fc34455f4 Rework SESSION_GLOBALS API to prevent overwriting it 2021-07-08 16:16:28 +02:00
flip1995
795868dd88
Rename run_lints -> lints_enabled 2021-07-08 15:45:19 +02:00
Yoshitomo Nakanishi
3bc5abef62 default_numeric_fallback: Fix FP with floating literal 2021-07-08 11:37:12 +09:00
Ryan Levick
30c5c2ff03 Add s to non_fmt_panic 2021-07-06 20:12:56 +02:00
iobtl
eeefbb7617 fix false positive (panic message) with assert macro using message parameter 2021-07-06 15:14:53 +08:00
Anthony Huang
357a8f0344 Add redundant_method_names lint 2021-07-05 14:15:20 -04:00
Mateusz Gacek
59a164e86c Add new lint: strlen_on_c_strings 2021-07-05 11:10:45 +02:00
bors
3cc6778512 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`]
2021-07-04 16:47:11 +00:00
Devin Ragotzy
1d110f8c2e Fix emitting in nested (proc_)macros for nonstandard_macro_braces lint 2021-07-04 07:06:23 -04:00
Cameron Steffen
cb4670deb3 Fix use_self ICE 2021-07-03 12:40:50 -05:00
bors
c195db7fee 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
2021-07-03 16:53:21 +00:00
Elliot Bobrow
e9a5694597 fix doc_markdown false positive 2021-07-03 09:34:10 -07:00
bors
84209994ad 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>>`
2021-07-03 10:26:03 +00:00
David Tolnay
0f662e5833
Downgrade nonstandard_macro_braces to nursery 2021-07-02 22:16:04 -07:00
lyj
b9cc2feaaa rc_mutex: known problems 2021-07-02 22:10:13 +08:00
flip1995
ebe52869a3 Merge commit '61eb38aeda6cb54b93b872bf503d70084c4d621c' into clippyup 2021-07-01 18:17:38 +02:00
flip1995
a82a744155
Merge remote-tracking branch 'upstream/master' into rustup 2021-07-01 17:41:24 +02:00
bors
753bce30f0 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
2021-07-01 15:02:21 +00:00
flip1995
fae7a09eea
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.
2021-07-01 12:38:30 +02:00
bors
cadb93b6de 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`
2021-06-30 18:14:16 +00:00
Igor Aleksanov
018be41dee Implement 'disallowed_script_idents' lint 2021-06-30 19:06:33 +03:00
bors
3525a6b61a 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
2021-06-30 15:12:55 +00:00
Cameron Steffen
bae76f9c17 Remove a visitor from use_self 2021-06-29 08:17:23 -05:00
Cameron Steffen
6e801e251f Use type_of for impl self type 2021-06-29 08:15:45 -05:00
Cameron Steffen
4913d82175 Simplify in impl check 2021-06-29 08:14:21 -05:00
Cameron Steffen
8827e96303 Make ItemKind check dry 2021-06-29 08:14:21 -05:00