Commit Graph

9817 Commits

Author SHA1 Message Date
rail
31cb110964 add concinient methods to Increment/InitializeVisitor 2020-09-25 08:59:14 +12:00
rail
b2d5b89a1d Check if it's after the loop earlier 2020-09-25 08:59:14 +12:00
rail
116f30dc33 Use else blocks instead of return statements in Increment/InitializeVisitor 2020-09-25 08:59:14 +12:00
rail
dc89bb1135 Use if_chain in Increment/InitializeVisitor 2020-09-25 08:59:14 +12:00
Takayuki Nakata
2892a2b0f5 Fix FP in print_stdout
This lint shouldn't be emitted in `build.rs` as `println!` and `print!` are used for the build script.
2020-09-24 23:22:54 +09:00
bors
cc1998f7b3 Auto merge of #6077 - ebroto:revert_or_fun_call_const, r=matthiaskrgr
Revert: or_fun_call should lint calls to `const fn`s with no args

The changes in #5889 and #5984 were done under the incorrect assumption that a `const fn` with no args was guaranteed to be evaluated at compile time.  A `const fn` is only guaranteed to be evaluated at compile time if it's inside a const context (the initializer of a `const` or a `static`).

See this [zulip conversation](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Common.20misconception.3A.20.60const.20fn.60.20and.20its.20effect.20on.20codegen/near/208059113) for more details on this common misconception.

Given that none of the linted methods by `or_fun_call` can be called in const contexts, the lint should make no exceptions.

changelog: [`or_fun_call`] lints again calls to `const fn` with no args
2020-09-24 14:14:53 +00:00
bors
019c0d5f7f Auto merge of #6076 - rail-rain:fix_fp_explicit_counter_loop, r=matthiaskrgr
Fix a FP in `explicit_counter_loop`

Fixes #4677 and #6074

Fix a false positive in `explicit_counter_loop` where the loop counter is used after incremented, adjust the test so that counters are incremented at the end of the loop and add the test for this false positive.

---

changelog: Fix a false positive in `explicit_counter_loop` where the loop counter is used after incremented
2020-09-24 13:45:24 +00:00
flip1995
d1f9cad102 Merge commit 'e636b88aa180e8cab9e28802aac90adbc984234d' into clippyup 2020-09-24 14:49:22 +02:00
Eduardo Broto
9365660a2f unnecessary sort by: avoid dereferencing closure param 2020-09-23 23:33:50 +02:00
bors
e636b88aa1 Auto merge of #6044 - rschoon:rc-buffer, r=yaahc
Add `rc_buffer` lint for checking Rc<String> and friends

Fixes #2623

This is a bit different from the original PR attempting to implement this type of lint.   Rather than linting against converting into the unwanted types, this PR lints against declaring the unwanted type in a struct or function definition.

I'm reasonably happy with what I have here, although I used the fully qualified type names for the Path and OsString suggestions, and I'm not sure if I should have just used the short versions instead, even if they might not have been declared via use.

Also, I don't know if "buffer type" is the best way to put it or not.  Alternatively I could call it a "growable type" or "growable buffer type", but I was thinking of PathBuf when I started making the lint.

changelog: Add `rc_buffer` lint
2020-09-23 18:35:08 +00:00
Robin Schoonover
6c056d3465 Satisfy rc_buffer lint in Constant::Binary byte string by copying data
We can avoid the data copy again by fixing rustc_ast::ast::LitKind
later.
2020-09-22 20:35:54 -06:00
Eduardo Broto
ce83d8d4d1 Revert "Avoid or_fun_call for const_fn with no args"
This reverts commit 5d66bd7bb3.
2020-09-23 00:39:00 +02:00
Eduardo Broto
3e294b22a4 Revert "or_fn_call: ignore nullary associated const fns"
This reverts commit 7a66e6502d.
2020-09-23 00:34:56 +02:00
rail
5e393c7747 Fix a FP in explicit_counter_loop
Fix a false positive in `explicit_counter_loop` where the loop counter is used after incremented,
adjust the test so that counters are incremented at the end of the loop
and add the test for this false positive.
2020-09-23 08:15:44 +12:00
bors
29b12f22fc Auto merge of #6069 - alex-700:redundant-pattern-matching-in-macro, r=Manishearth
Forbid redundant_pattern_matching triggering in macros

fixes #6065

changelog: forbid redundant_pattern_matching triggering in macros
2020-09-22 16:01:39 +00:00
Aleksei Latyshev
d4f158fa5c
Forbid redundant_pattern_matching triggering in macros
- remove ice-2636 test
2020-09-21 20:49:42 +03:00
bors
78fbb04edb Auto merge of #6071 - ebroto:rustup, r=ebroto
Rustup

r? `@ghost`

changelog: none
2020-09-21 13:43:01 +00:00
Eduardo Broto
4117ae1175 Split redundant_pattern_matching tests
This is to avoid the 200 lines stderr file limit
2020-09-21 15:32:26 +02:00
Eduardo Broto
6e07247578 Merge remote-tracking branch 'upstream/master' into rustup 2020-09-21 15:11:24 +02:00
Christiaan Dirkx
141b9c2890 Remove can_suggest from Clippy.
Removes `can_suggest` from as it is no longer used.
Reverts rust-clippy#5724.
2020-09-21 00:00:33 +02:00
Christiaan Dirkx
ed43385cab Update Clippy testcases
Update the test `redundant_pattern_matching`: check if `is_some` and `is_none` are suggested within const contexts.
2020-09-20 23:59:34 +02:00
bors
a334ae658b Auto merge of #76136 - CDirkx:const-result, r=dtolnay
Stabilize some Result methods as const

Stabilize the following methods of Result as const:
 - `is_ok`
 - `is_err`
 - `as_ref`

A test is also included, analogous to the test for `const_option`.

These methods are currently const under the unstable feature `const_result` (tracking issue: #67520).
I believe these methods to be eligible for stabilization because of the stabilization of #49146 (Allow if and match in constants) and the trivial implementations, see also: [PR#75463](https://github.com/rust-lang/rust/pull/75463) and [PR#76135](https://github.com/rust-lang/rust/pull/76135).

Note: these methods are the only methods currently under the `const_result` feature, thus this PR results in the removal of the feature.

Related: #76225
2020-09-20 13:07:11 +00:00
CDirkx
ac0d069616 Update src/tools/clippy/clippy_lints/src/matches.rs
Co-authored-by: Ralf Jung <post@ralfj.de>
2020-09-20 12:21:23 +02:00
Christiaan Dirkx
292e2f71a7 Remove can_suggest check for is_ok and is_err.
`is_ok` and `is_err` are stabilized as const and can thus always be suggested.
2020-09-20 10:46:30 +02:00
Christiaan Dirkx
10d272b2e2 Update Clippy testcases
Update the test `redundant_pattern_matching`: check if `is_ok` and `is_err` are suggested within const contexts.
Also removes the `redundant_pattern_matching_const_result` test, as it is no longer needed.
2020-09-20 03:32:36 +02:00
bors
d88b9b7543 Auto merge of #6046 - rail-rain:change_criteria_non_copy_const, r=flip1995
Change the criteria of `interior_mutable_const`

This implements my suggestion [here](https://github.com/rust-lang/rust-clippy/issues/5050#issuecomment-680310889), and so hopefully fixes #5050.

* stop linting associated types and generic type parameters
* start linting ones in trait impls
  whose corresponding definitions in the traits are generic
* remove the `is_copy` check
  as presumably the only purpose of it is to allow
  generics with `Copy` bounds as `Freeze` is internal
  and generics are no longer linted
* remove the term 'copy' from the tests
  as being `Copy` no longer have meaning

---

changelog: Change the criteria of `declare_interior_mutable_const` and `borrow_interior_mutable_const` to narrow the lints to only lint things that defenitly is a interior mutable type, not potentially.
2020-09-18 14:34:04 +00:00
rail
d5af360bb2 add WRAPPED_SELF: Option<Self> in the test 2020-09-17 21:14:14 +12:00
rail
2fc9064921 rewrite the test and fix a minor fp
* rewrite the test for `declare_interior_mutable_const from scratch`

* fix a minor false positive where `Cell<"const T>` gets linted twice
2020-09-17 19:48:40 +12:00
rail
d655c0a938 Change the criteria of interior_mutable_const
* stop linting associated types and generic type parameters
* start linting ones in trait impls
  whose corresponding definitions in the traits are generic
* remove the `is_copy` check
  as presumably the only purpose of it is to allow
  generics with `Copy` bounds as `Freeze` is internal
  and generics are no longer linted
* remove the term 'copy' from the tests
  as being `Copy` no longer have meaning
2020-09-17 19:38:37 +12:00
Robin Schoonover
27200855c3 Move rc_buffer lint into perf category 2020-09-16 17:20:36 -06:00
bors
5af88e3c2d Auto merge of #6034 - rail-rain:fix_fp_in_indexing_slicing, r=flip1995
Treat refs to arrays the same as owned arrays in `indexing_slicing` and `out_of_bounds_indexing`

Fixes #6021

...and remove `walk_ptrs_ty` in favour of `peel_refs`, which came in 2019.

---

changelog: Fix a false positive in `indexing_slicing` and `out_of_bounds_indexing` where references to arrays weren't treated as arrays.
2020-09-16 22:45:36 +00:00
rail
ce06472246 replace walk_ptrs_ty with peel_refs 2020-09-17 10:11:59 +12:00
rail
2ce2d6b40e fix a FP in indexing_slicing
treat refs to arrays the same as arrays
in `indexing_slicing` and `out_of_bounds_indexing`
2020-09-17 10:11:10 +12:00
bors
06f1902878 Auto merge of #5937 - montrivo:option_if_let_else, r=flip1995
option_if_let_else - distinguish pure from impure else expressions

Addresses partially #5821.

changelog: improve the lint `option_if_let_else`. Suggest `map_or` or `map_or_else` based on the else expression purity.
2020-09-16 19:36:49 +00:00
bors
44d6439bfd Auto merge of #6025 - thomcc:compare_exchange_atomics, r=flip1995
Extend invalid_atomic_ordering for compare_exchange{,_weak} and fetch_update

changelog: The invalid_atomic_ordering lint can now detect misuse of `compare_exchange`, `compare_exchange_weak`, and `fetch_update`.

---

I was surprised not to find an issue or existing support here, since these are the functions which are always hardest to get the ordering right on for me (as the allowed orderings for `fail` depend on the `success` parameter).

I believe this lint now covers all atomic methods which care about their ordering now, but I could be wrong.

Hopefully I didn't forget to do anything for the PR!
2020-09-16 18:33:38 +00:00
bors
5e60497fb8 Auto merge of #6038 - mikerite:lint-5734, r=matthiaskrgr
Add `manual-strip` lint

Add `manual-strip` lint.

changelog: Add `manual-strip` lint
2020-09-16 18:13:36 +00:00
Tim Nielens
79da7474b1 option_if_let_else - change misleading test file section 2020-09-16 19:59:51 +02:00
bors
b08bbe50ea Auto merge of #6048 - giraffate:add_note_to_shadow_unrelated, r=matthiaskrgr
Add note to `shadow_unrelated`

Fix #5455.

This lint can be disabled at function level.

changelog: none
2020-09-16 17:52:40 +00:00
bors
61dd007536 Auto merge of #6042 - euclio:println-empty, r=flip1995
{print,write}-with-newline: do not suggest empty format string

changelog: do not suggest empty format strings in `print-with-newline` and `write-with-newline`
2020-09-16 17:16:07 +00:00
bors
e7bff507cd Auto merge of #6057 - giraffate:update_doc_about_moving_to_zulip, r=flip1995
Update documentation about moving from Discord to Zulip

Moving from Discord to Zulip was discussed at https://github.com/rust-lang/rust-clippy/issues/5943 and new stream in Zulip was created at https://github.com/rust-lang/rust-clippy/issues/5943#issuecomment-691984366.

changelog: none
2020-09-16 15:39:39 +00:00
Andy Russell
0261e341fd
{print,write}-with-newline: do not suggest empty format string 2020-09-16 11:25:53 -04:00
Takayuki Nakata
b37e3cdd46 Update documentation about moving from Discord to Zulip 2020-09-17 00:10:24 +09:00
bors
4f6d4e68e3 Auto merge of #6056 - rust-lang:flip1995/triagebot, r=flip1995
Add S-* label modifier to triagebot

changelog: none
2020-09-16 14:40:43 +00:00
Philipp Krones
9c546b51d5
Add S-* label modifier to triagebot 2020-09-16 16:38:58 +02:00
bors
74051c4d4b Auto merge of #6055 - lzutao:bump-cmark, r=phansch
Bump pulldown-cmark v0.8

Closes  #6054

changelog: none
2020-09-16 05:26:30 +00:00
Lzu Tao
ad6f8c6354 bump pulldown-cmark v0.8 2020-09-16 12:09:57 +07:00
Robin Schoonover
d0ddbb9d0d Extend testing of rc_buffer lint 2020-09-15 21:11:28 -06:00
Tim Nielens
6ba36bcfd3 option_if_let_else - distinguish pure from impure else expressions 2020-09-16 01:30:50 +02:00
Michael Wright
79a0e5110a manual-strip: Fix formatting 2020-09-15 21:32:27 +02:00
Michael Wright
ecbe9ac0e9 manual-strip: Add additional test 2020-09-15 21:32:27 +02:00