Commit Graph

141 Commits

Author SHA1 Message Date
xFrednet
e0eb29c936 Applying PR suggestions (mostly typos)
Co-authored-by: flip1995 <hello@philkrones.com>
Co-authored-by: phansch <dev@phansch.net>
2021-05-05 18:58:57 +02:00
xFrednet
4fc960301b Metadata collection: Rounding up the implementation 2021-05-05 18:38:26 +02:00
xFrednet
35844d0a48 Metadata collection: Resolve lint from locals 2021-05-05 18:35:33 +02:00
xFrednet
6658db1044 Metadata collection: processing emission closures (417/455) 2021-05-05 18:35:33 +02:00
xFrednet
ee8a99a114 Metadata collection: Collecting Applicability assign values 2021-05-05 18:35:33 +02:00
xFrednet
8dca1b8f61 Metadata collection: Collecting Applicability assign values 2021-05-05 18:35:33 +02:00
xFrednet
060e0e9f93 Metadata collection lint: Basic applicability collection 2021-05-05 18:35:33 +02:00
Cameron Steffen
1c3c54a6ef SpanlessHash Pat 2021-05-04 08:43:20 -05:00
bors
5e49c4bd67 Auto merge of #6951 - Jarcho:implicit_return_fp, r=flip1995
`implicit_return` improvements

fixes: #6940

changelog: Fix `implicit_return` suggestion for async functions
changelog: Improve `implicit_return` suggestions when returning the result of a macro
changelog: Check for `break` expressions inside a loop which are then implicitly returned
changelog: Allow all diverging functions in `implicit_return`, not just panic functions
2021-04-30 14:55:56 +00:00
bors
7c7683c8ef Auto merge of #7128 - Jarcho:const_fn_ice, r=flip1995
Fix ICE checking for feature gated const fn

fixes: #7126
changelog: Fix ICE in `missing_const_for_fn` when using a feature-gated `const fn`
2021-04-27 14:21:11 +00:00
Cameron Steffen
340b570ea0 Refactor MSRV aliases 2021-04-26 16:07:48 -05:00
Jason Newcomb
db7ad648e7
Fix ICE checking for feature gated const fn 2021-04-25 10:18:15 -04:00
Jason Newcomb
ef9ad80617
Add examples to better explain walk_span_to_context 2021-04-22 09:36:46 -04:00
Jason Newcomb
74cf5f2fc6
Fix implicit_return suggestion for async functions 2021-04-22 09:36:32 -04:00
Jason Newcomb
22f8c13cf5
Improve implicit_return
Better suggestions when returning macro calls.
Suggest changeing all the break expressions in a loop, not just the final statement.
Don't lint divergent functions.
Don't suggest returning the result of any divergent fuction.
2021-04-22 09:13:06 -04:00
bors
bbc22e2ef3 Auto merge of #7083 - GuillaumeGomez:bool-assert-eq, r=camsteffen
Add lint to check for boolean comparison in assert macro calls

This PR adds a lint to check if an assert macro is using a boolean as "comparison value". For example:

```rust
assert_eq!("a".is_empty(), false);
```

Could be rewritten as:

```rust
assert!(!"a".is_empty());
```

PS: The dev guidelines are amazing. Thanks a lot for writing them!

changelog: Add `bool_assert_comparison` lint
2021-04-21 13:58:53 +00:00
Guillaume Gomez
e2e104b993 Add lint to check for boolean comparison in assert macro calls 2021-04-19 22:15:51 +02:00
Cameron Steffen
5af078ac1b Add flat_map_option lint 2021-04-16 15:23:49 -05:00
bors
eaf0f3df15 Auto merge of #7075 - xFrednet:7054-fp-branches-sharing-code, r=camsteffen,flip1995
Fixing FPs for the `branches_sharing_code` lint

Fixes #7053
Fixes #7054
And an additional CSS adjustment to support dark mode for every inline code. It currently only works in paragraphs, which was an oversight on my part 😅. [Current Example](https://rust-lang.github.io/rust-clippy/master/index.html#blacklisted_name)

This also includes ~50 lines of doc comments and is therefor not as big as the changes would indicate. 🐧

---

changelog: none

All of these bugs were introduced in this dev version and are therefor not worth a change log entry.

r? `@phansch`
cc: `@camsteffen` since you have a pretty good overview of the `SpanlessEq` implementation 🙃
2021-04-16 18:33:45 +00:00
Cameron Steffen
b049c88fbe Eat dogfood 2021-04-16 11:39:31 -05:00
Cameron Steffen
0462666c70 Add cloned_instead_of_copied lint 2021-04-16 11:39:31 -05:00
bors
1e0a3ff55c Auto merge of #6937 - Jarcho:map_entry_suggestion, r=giraffate
Improve `map_entry` suggestion

fixes: #5176
fixes: #4674
fixes: #4664
fixes: #1450

Still need to handle the value returned by `insert` correctly.

changelog: Improve `map_entry` suggestion. Will now suggest `or_insert`, `insert_with` or `match _.entry(_)` as appopriate.
changelog: Fix `map_entry` false positives where the entry api can't be used. e.g. when the map is used for multiple things.
2021-04-16 13:23:23 +00:00
Jason Newcomb
f6c5d8d599
Remove all usages of match_path, match_qpath and match_path_ast except the author lint.
Add note to fix `MATCH_TYPE_ON_DIAG_ITEM`
Add false negative test for `uninit_assumed_init`
2021-04-15 19:27:25 -04:00
Jason Newcomb
bcf3488007
Minor cleanup of map_entry and a few additional tests. 2021-04-15 08:25:24 -04:00
Jason Newcomb
3323ff7145
map_entry improvements
Suggest using `or_insert_with` when possible
2021-04-15 08:22:40 -04:00
Jason Newcomb
ce5e927713
Improve map_entry lint
Fix false positives where the map is used before inserting into the map.
Fix false positives where two insertions happen.
Suggest using `if let Entry::Vacant(e) = _.entry(_)` when `or_insert` might be a semantic change
2021-04-15 08:19:40 -04:00
xFrednet
0b4af7257d PR suggestions and removing utils::parent_node_is_if_expr 2021-04-14 20:11:08 +02:00
xFrednet
2992b19c82 Added inferred local type comparion to SpanlessEq 2021-04-14 20:06:26 +02:00
xFrednet
cbde4f2c67 parent_node_is_if_expr now also recognizes if let as parent if 2021-04-14 20:06:26 +02:00
bors
19740d9334 Auto merge of #7076 - rail-rain:missing_const_for_fn, r=phansch
Fix a FP in `missing_const_for_fn`

where a function that calls a standard library function whose constness
is unstable is considered as being able to be a const function. Fixes #5995.

The core change is the move from `rustc_mir::const_eval::is_min_const_fn` to `rustc_mir::const_eval::is_const_fn`. I'm not clear about the difference in their purpose between them so I'm not sure if it's acceptable to call `qualify_min_const_fn::is_min_const_fn` this way now.

---

changelog: `missing_const_for_fn`: No longer lints when an unstably const function is called
2021-04-14 04:39:25 +00:00
rail
26a1989041 Fix a FP in missing_const_for_fn
where a function that calls a standard library function whose constness
is unstable is considered as being able to be a const function
2021-04-14 09:23:44 +12:00
Cameron Steffen
76bd5d232c Refactor diagnostic item methods 2021-04-13 14:10:40 -05:00
boxdot
d6beb18411
Remove paths::STD_PTR_NULL 2021-04-12 18:35:47 +02:00
bors
aecccbc579 Auto merge of #7047 - camsteffen:lang-ctor, r=flip1995
Introduce `is_lang_ctor`

changelog: none

Replaces `is_some_ctor` and `is_ok_ctor`. Removes many path usages.
2021-04-12 08:52:10 +00:00
Cameron Steffen
a45faf66f3 Deprecate filter_map 2021-04-10 16:59:59 -05:00
bors
75efc144e7 Auto merge of #7023 - boxdot:invalid-null-usage-v2, r=camsteffen
Invalid null usage v2

This is continuation of #6192 after inactivity.

I plan to move paths into the compiler as diagnostic items after this is merged.

fixes #1703
changelog: none
2021-04-08 21:00:48 +00:00
boxdot
4f7fc11ef1
Add invalid null pointer usage lint. 2021-04-08 22:49:48 +02:00
flip1995
ffa2b7da29
Merge remote-tracking branch 'upstream/master' into rustup 2021-04-08 17:36:41 +02:00
Dylan DPC
cde58f7174 Rollup merge of #83916 - Amanieu:asm_anonconst, r=petrochenkov
Use AnonConst for asm! constants

This replaces the old system which used explicit promotion. See #83169 for more background.

The syntax for `const` operands is still the same as before: `const <expr>`.

Fixes #83169

Because the implementation is heavily based on inline consts, we suffer from the same issues:
- We lose the ability to use expressions derived from generics. See the deleted tests in `src/test/ui/asm/const.rs`.
- We are hitting the same ICEs as inline consts, for example #78174. It is unlikely that we will be able to stabilize this before inline consts are stabilized.
2021-04-07 13:07:14 +02:00
Cameron Steffen
7468542328 Introduce is_lang_ctor 2021-04-06 15:05:00 -05:00
Cameron Steffen
47f0c15f67 Symbol optimizations 2021-04-06 13:00:36 -05:00
bors
624e8aad32 Auto merge of #7044 - camsteffen:match-path, r=Manishearth
Soft deprecate match_path and match_qpath

changelog: none

From zulip [disucssion](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/match_.5Bq.5Dpath.20is.20bad.3F).
2021-04-06 17:41:34 +00:00
Cameron Steffen
a342de3bcb Soft deprecate match_path and match_qpath 2021-04-06 11:46:27 -05:00
Cameron Steffen
79d3082cd7 Remove paths::PATH_BUF 2021-04-06 11:33:59 -05:00
Cameron Steffen
1efb551369 Remove get_node_span 2021-04-06 11:33:59 -05:00
Amanieu d'Antras
879bfeca54 Use AnonConst for asm! constants 2021-04-06 12:35:41 +01:00
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