Commit graph

91 commits

Author SHA1 Message Date
xFrednet
a6f54f5dfd Renaming the lint to branches_sharing_code and fixing typos 2021-04-05 13:35:51 +02:00
xFrednet
617c65baa9 Moving shared_code_in_if_blocks to clippy::complexity and running lintcheck 2021-04-05 13:35:51 +02:00
xFrednet
c74e49eab9 Adapted the lint to use the new SpanlessEq 2021-04-05 13:35:51 +02:00
xFrednet
d1df73228a A new lint for shared code in if blocks
* Added expression check for shared_code_in_if_blocks
* Finishing touches for the shared_code_in_if_blocks lint
* Applying PR suggestions
* Update lints yay
* Moved test into subfolder
2021-04-05 13:33:45 +02:00
xFrednet
232e2b79f2 Added documentation to the multispan_sugg method 2021-04-05 13:33:45 +02:00
Cameron Steffen
6f31ed6c8d Use DefIdMap and similar aliases 2021-04-03 18:02:49 -05:00
Cameron Steffen
33798bb064 Improve needless_collect output 2021-04-02 10:10:54 -05:00
bors
1931db20b1 Auto merge of #6988 - mikerite:fix-6984, r=camsteffen
Fix hidden variant suggestion on single variant

Fixes #6984

changelog: Fix hidden variant suggestion on `match_wildcard_for_single_variants`
2021-04-02 12:42:40 +00:00
Yoshitomo Nakanishi
6325fe1f54 clippy_utils: fix needless parenthesis output from sugg::Sugg::maybe_par 2021-04-01 10:40:44 +09:00
Michael Wright
8abab5561c Fix hidden variant suggestion on single variant
Fixes #6984
2021-03-31 07:36:09 +02:00
bors
4be72b0936 Auto merge of #7001 - ebobrow:non-octal-file-permissions, r=Manishearth
Add non_octal_unix_permissions lint

fixes #6934

changelog: add new lint that checks for non-octal values used to set unix file permissions
2021-03-30 23:23:50 +00:00
Elliot Bobrow
7fcd155712 Add non_octal_unix_permissions lint 2021-03-30 16:04:16 -07:00
Jason Newcomb
fa689f865e
Fix manual_map at the end of an if chain 2021-03-30 09:58:23 -04:00
flip1995
40e68e5956
Bump Clippy Version -> 0.1.53 2021-03-25 18:48:48 +01:00
flip1995
1f5f184105
Merge remote-tracking branch 'upstream/master' into rustup 2021-03-25 18:38:13 +01:00
Jason Newcomb
6e88900f9e
Rename contains_adt to contains_adt_constructor 2021-03-24 16:23:02 -04:00
Jason Newcomb
99b8a67198
Fix false positive with new_ret_no_self when returning Self with different generic arguments 2021-03-24 16:22:28 -04:00
kadmin
e06731bb28 Add has_default to GenericParamDefKind::Const
This currently creates a field which is always false on GenericParamDefKind for future use when
consts are permitted to have defaults

Update const_generics:default locations

Previously just ignored them, now actually do something about them.

Fix using type check instead of value

Add parsing

This adds all the necessary changes to lower const-generics defaults from parsing.

Change P<Expr> to AnonConst

This matches the arguments passed to instantiations of const generics, and makes it specific to
just anonymous constants.

Attempt to fix lowering bugs
2021-03-23 17:16:20 +00:00
Cameron Steffen
9132dbdf31 Factor out eq_ty_kind 2021-03-23 10:49:12 -05:00
bors
2bc180e888 Auto merge of #79278 - mark-i-m:stabilize-or-pattern, r=nikomatsakis
Stabilize or_patterns (RFC 2535, 2530, 2175)

closes #54883

This PR stabilizes the or_patterns feature in Rust 1.53.

This is blocked on the following (in order):
- [x] The crater run in https://github.com/rust-lang/rust/pull/78935#issuecomment-731564021
- [x] The resolution of the unresolved questions and a second crater run (https://github.com/rust-lang/rust/pull/78935#issuecomment-735412705)
    - It looks like we will need to pursue some sort of edition-based transition for `:pat`.
- [x] Nomination and discussion by T-lang
- [x] Implement new behavior for `:pat` based on consensus (https://github.com/rust-lang/rust/pull/80100).
- [ ] An FCP on stabilization

EDIT: Stabilization report is in https://github.com/rust-lang/rust/pull/79278#issuecomment-772815177
2021-03-22 19:48:27 +00:00
lcnr
731c98b16b update const_eval_resolve 2021-03-20 17:22:24 +01:00
mark
d2f0b27f0a clippy: stabilize or_patterns lint 2021-03-19 19:45:42 -05:00
bors
4d686196b9 Auto merge of #6863 - Jarcho:wild_enum_match, r=llogiq
`match_wildcard` improvements

fixes: #6604
fixes: #5733
fixes: #6862

#5733 is only fixed in the normal case, if different paths are used for the variants then the same problem will occur. It's cause by `def_path_str` returning an utterly useless result. I haven't dug into why yet.

For #6604 there should be some discussion before accepting this. It's easy enough to change the message rather than disable the lint for `Option` and `Result`.

changelog: Attempt to find a common path prefix for `match_wildcard_for_single_variants` and `wildcard_enum_match_arm`
changelog: Don't lint op `Option` and `Result` for `match_wildcard_for_single_variants` and `wildcard_enum_match_arm`
changelog: Consider `or` patterns and `Self` prefix for `match_wildcard_for_single_variants` and `wildcard_enum_match_arm`
2021-03-18 10:39:28 +00:00
Vadim Petrochenkov
2c4570c958 hir: Preserve used syntax in TyKind::TraitObject 2021-03-18 03:02:32 +03:00
Jason Newcomb
f468d82283
Fix manual_map suggestion for if let.. else ... if let.. else chain 2021-03-17 12:57:42 -04:00
bors
56138ad789 Auto merge of #83188 - petrochenkov:field, r=lcnr
ast/hir: Rename field-related structures

I always forget what `ast::Field` and `ast::StructField` mean despite working with AST for long time, so this PR changes the naming to less confusing and more consistent.

- `StructField` -> `FieldDef` ("field definition")
- `Field` -> `ExprField` ("expression field", not "field expression")
- `FieldPat` -> `PatField` ("pattern field", not "field pattern")

Various visiting and other methods working with the fields are renamed correspondingly too.

The second commit reduces the size of `ExprKind` by boxing fields of `ExprKind::Struct` in preparation for https://github.com/rust-lang/rust/pull/80080.
2021-03-17 16:49:46 +00:00
Jason Newcomb
0b7ab90eca
Improvements to match_wildcard_for_single_variants and wildcard_enum_match_arm lints
Don't lint on `Result` and `Option` types.
Considers `or` patterns.
Considers variants prefixed with `Self`
Suggestions will try to find a common prefix rather than just using the full path
2021-03-17 12:04:11 -04:00
flip1995
bdf2dceec1
Get rid of some unused dependecies 2021-03-16 14:51:57 +01:00
Vadim Petrochenkov
e72d28352c ast: Reduce size of ExprKind by boxing fields of ExprKind::Struct 2021-03-16 11:41:24 +03:00
Vadim Petrochenkov
35e8be7407 ast/hir: Rename field-related structures
StructField -> FieldDef ("field definition")
Field -> ExprField ("expression field", not "field expression")
FieldPat -> PatField ("pattern field", not "field pattern")

Also rename visiting and other methods working on them.
2021-03-16 11:41:24 +03:00
bors
1a206fc4ab Auto merge of #6915 - smoelius:docs-link, r=llogiq
Do not show docs link when lint doesn't start with "clippy::"

This small change ensures that if the diagnostic functions are called from outside of Clippy, a docs link is not displayed.

---

*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: restrict docs links
2021-03-16 07:08:48 +00:00
Cameron Steffen
1c3a3e7dc6 Don't re-export clippy_utils::diagnostics::* 2021-03-15 20:06:01 -05:00
Cameron Steffen
6fc52a63d1 Move some utils to clippy_utils::source module 2021-03-15 15:34:15 -05:00
Cameron Steffen
eb7f8d6089 Move some utils to ty_utils 2021-03-15 13:44:09 -05:00
Roxane
7926664876 Add comments with examples and tests 2021-03-15 13:16:04 -04:00
Cameron Steffen
59dba04ccb Improve find_binding_init docs 2021-03-15 08:56:14 -05:00
Samuel E. Moelius III
f7c5742ca6 Do not show docs link when lint doesn't start with "clippy::" 2021-03-15 05:40:21 -04:00
Roxane
0ab2bcd182 Add fake_read() to clippy 2021-03-14 19:45:24 -04:00
Ben Boeckel
ecf0c76c36 Fix suspicious_map false positives 2021-03-14 16:31:55 -05:00
bors
92b9677864 Auto merge of #6820 - mgacek8:issue_6562_enhance_mem_replace_with_default_with_other_ctors, r=phansch
mem_replace_with_default: recognize some std library ctors

fixes #6562
changelog: mem_replace_with_default: recognize some common constructors equivalent to `Default::default()`
2021-03-13 15:43:00 +00:00
Jason Newcomb
a261bc5fad
Make explicit_deref_methods check for multiple deref calls
Fix suggestion for `explicit_deref_methods`. Sometimes `&**` is needed, sometimes nothing is needed.
Allow `explicit_deref_methods` to trigger in a few new contexts.
`explicit_deref_methods` will now consider ufcs calls
2021-03-13 08:39:48 -05:00
Mateusz Gacek
41be515062 mem_replace_with_default: use diagnostic items intead of paths 2021-03-12 13:03:07 -08:00
Mateusz Gacek
c86ba7f92d mem_replace_with_default: recognize some std library ctors 2021-03-12 12:57:54 -08:00
Yoshitomo Nakanishi
93ee80ac3e Use sym::Iterator instead of paths::ITERATOR 2021-03-13 02:10:54 +09:00
flip1995
f2f2a005b4 Merge commit '6ed6f1e6a1a8f414ba7e6d9b8222e7e5a1686e42' into clippyup 2021-03-12 15:30:50 +01:00
flip1995
9c1dd0c227
Fix remaining dogfood errors (internal lints) 2021-03-11 10:57:49 +01:00
flip1995
78c740e2f3
Merge remote-tracking branch 'upstream/master' into rustup 2021-03-11 10:37:58 +01:00
bors
36a27ecaac Auto merge of #79519 - cjgillot:noattr, r=wesleywiser
Store HIR attributes in a side table

Same idea as #72015 but for attributes.
The objective is to reduce incr-comp invalidations due to modified attributes.
Notably, those due to modified doc comments.

Implementation:
- collect attributes during AST->HIR lowering, in `LocalDefId -> ItemLocalId -> &[Attributes]` nested tables;
- access the attributes through a `hir_owner_attrs` query;
- local refactorings to use this access;
- remove `attrs` from HIR data structures one-by-one.

Change in behaviour:
- the HIR visitor traverses all attributes at once instead of parent-by-parent;
- attribute arrays are sometimes duplicated: for statements and variant constructors;
- as a consequence, attributes are marked as used after unused-attribute lint emission to avoid duplicate lints.

~~Current bug: the lint level is not correctly applied in `std::backtrace_rs`, triggering an unused attribute warning on `#![no_std]`. I welcome suggestions.~~
2021-03-10 08:40:51 +00:00
Camille GILLOT
b32cffe493 Remove hir::Crate::attrs. 2021-03-09 19:22:55 +01:00
kadmin
cb8bc0b6e6 Switch to changing cp_non_overlap in tform
It was suggested to lower this in MIR instead of ssa, so do that instead.
2021-03-09 16:54:14 +00:00