Commit graph

2598 commits

Author SHA1 Message Date
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
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
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
Andy Russell
0261e341fd
{print,write}-with-newline: do not suggest empty format string 2020-09-16 11:25:53 -04:00
Tim Nielens
6ba36bcfd3 option_if_let_else - distinguish pure from impure else expressions 2020-09-16 01:30:50 +02:00
Michael Wright
ecbe9ac0e9 manual-strip: Add additional test 2020-09-15 21:32:27 +02:00
Michael Wright
8b04c2d6e8 Merge branch 'master' into lint-5734 2020-09-15 21:21:35 +02:00
bors
0695f21994 Auto merge of #6043 - HaramanJohal:margin_of_error, r=matthiaskrgr
clarify margin of error in wording of float comparison operator lint messages

fixes #6040

changelog: change wording of float comparison operator to make margin of error less ambiguous
2020-09-15 17:17:31 +00:00
Eduardo Broto
d0b5663d30 Fix usage of backquotes in suggestion 2020-09-15 10:45:57 +02:00
Eduardo Broto
8afa7ed6ae Add internal lint MatchTypeOnDiagItem 2020-09-15 10:29:53 +02:00
Haraman Johal
4d73ccaa94 clarify margin of error in wording of float comparison operator lint messages 2020-09-15 00:20:31 +01:00
bors
f82e84c894 Auto merge of #5998 - deg4uss3r:master, r=yaahc
Add map_err_ignore lint

In a large code base a lot of times errors are ignored by using something like:

```rust
foo.map_err(|_| Some::Enum)?;
```

This drops the original error in favor of a enum that will not have the original error's context. This lint helps catch throwing away the original error in favor of an enum without its context.

---

*Please keep the line below*
changelog: Added map_err_ignore lint
2020-09-14 19:56:47 +00:00
Michael Wright
15244a88df Fix manual-strip dogfood errors 2020-09-14 06:11:35 +02:00
Michael Wright
d1f0f04a48 New lint: manual-strip
Add a new lint, `manual-strip`, that suggests using the `str::strip_prefix`
and `str::strip_suffix` methods introduced in Rust 1.45 when the same
functionality is performed 'manually'.

Closes #5734
2020-09-14 06:11:35 +02:00
bors
231444d989 Auto merge of #6035 - matthiaskrgr:try_into_show_type, r=flip1995
useless_conversion: show type in error message.

changelog: useless_conversion: show type in error message.
2020-09-13 18:57:55 +00:00
Takayuki Nakata
9ff7e5d984 Downgrade verbose_bit_mask to pedantic 2020-09-13 23:23:45 +09:00
Matthias Krüger
7ba1a8fec4 useless_conversion: show type in error message.
changelog: useless_conversion: show type in error message.
2020-09-13 12:50:39 +02:00
Matthias Krüger
2487f8f461 into_iter_on_ref: rephrase lint message: will not move the x -> will not consume the x
imo that's a bit clearer.
2020-09-11 16:52:25 +02:00
bors
0ab75c37b6 Auto merge of #5977 - xvschneider:AddLintPanicInResult, r=matthiaskrgr
Add lint panic in result

### Change
Adding a new "restriction" lint that will emit a warning when using "panic", "unimplemented" or "unreachable" in a function of type option/result.

### Motivation
Some codebases must avoid crashes at all costs, and hence functions of type option/result must return an error instead of crashing.

### Test plan
Running:
TESTNAME=panic_in_result cargo uitest ---

changelog: none
2020-09-10 16:22:20 +00:00
bors
5034d47f72 Auto merge of #5980 - matsujika:create-dir, r=flip1995
Add a lint to prevent `create_dir` from being used

This closes #5950
changelog: none
2020-09-10 14:34:22 +00:00
bors
55efa96659 Auto merge of #5931 - montrivo:unit-arg, r=flip1995
improve the suggestion of the lint `unit-arg`

Fixes #5823
Fixes #6015

Changes
```
help: move the expression in front of the call...
  |
3 |     g();
  |
help: ...and use a unit literal instead
  |
3 |     o.map_or((), |i| f(i))
  |
```
into
```
help: move the expression in front of the call and replace it with the unit literal `()`
  |
3 |     g();
  |     o.map_or((), |i| f(i))
  |
```
changelog: improve the suggestion of the lint `unit-arg`
2020-09-10 14:11:27 +00:00
bors
87a4495b5d Auto merge of #6027 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2020-09-10 13:25:39 +00:00
flip1995
2d56512580
Cleanup of rustup 2020-09-10 15:23:38 +02:00
Thom Chiovoloni
3a072131da Ah, right, rerun the scripts 2020-09-09 23:22:01 -07:00
Thom Chiovoloni
159178e5d4 Separate compare_exchange and compare_exchange_weak uitests 2020-09-09 14:32:38 -07:00
Thom Chiovoloni
61671a2268 Detect fetch_update misuse in invalid_atomic_ordering too 2020-09-09 14:15:54 -07:00
Thom Chiovoloni
6211599cca Extend invalid_atomic_ordering to detect misuse of compare_exchange{,_weak} 2020-09-09 14:15:54 -07:00
Vali Schneider
3550568a54 removing if chain and renaming lint 2020-09-09 14:02:34 -07:00
Matthias Krüger
de195f2d3d print the unit type () in related lint messages. 2020-09-09 17:59:13 +02:00
Ricky
d719b48543 Move map_err_ignore from style to pedantic 2020-09-08 19:37:14 -04:00
Aaron Hill
f23670ed68 Adjust Clippy for CONST_ITEM_MUTATION lint
We no longer lint assignments to const item fields in the
`temporary_assignment` lint, since this is now covered by the
`CONST_ITEM_MUTATION` lint.

Additionally, we `#![allow(const_item_mutation)]` in the
`borrow_interior_mutable_const.rs` test. Clippy UI tests are run with
`-D warnings`, which seems to cause builtin lints to prevent Clippy
lints from running.
2020-09-08 17:59:56 -04:00
Ricky
4f1c4a99d4 Fixed typo in lint and test 2020-09-08 12:05:18 -04:00
Hirochika Matsumoto
a899ad2e12 Change suggestion to create_dir_all({}) from std::fs::create_dir_all({}) 2020-09-08 23:35:19 +09:00
Takayuki Nakata
952c04674e Refactoring: tests in same_item_push 2020-09-08 23:03:15 +09:00
Takayuki Nakata
2c9f82e7d2 Add some tests to same_item_push
Add tests in which the variable is initialized with a match expression and function call
2020-09-08 22:45:27 +09:00
Takayuki Nakata
3d30ef7818 Restrict same_item_push to suppress false positives
It emits a lint when the pushed item is a literal, a constant and an immutable binding that are initialized with those.
2020-09-07 23:46:43 +09:00
Eduardo Broto
9fa9208bd5 Restrict unnecessary_sort_by to non-ref copy types 2020-09-07 00:19:17 +02:00
bors
e9440cbcde Auto merge of #5997 - giraffate:fix_fp_about_clone_in_same_item_push, r=ebroto
Fix FP in `same_item_push`

Don't emit a lint when the pushed item doesn't have Clone trait

Fix #5979

changelog: Fix FP in `same_item_push` not to emit a lint when the pushed item doesn't have Clone trait
2020-09-05 20:27:17 +00:00
Takayuki Nakata
96b31a5b36 Fix FP when coercion kicks in 2020-09-06 00:02:35 +09:00
Ryan1729
db16fa26ce run tests/ui/update-all-references.sh 2020-09-04 20:16:02 -06:00
Eduardo Broto
23646e6583 Merge remote-tracking branch 'upstream/master' into sync-from-rust 2020-09-04 23:27:01 +02:00
bors
8829214764 Auto merge of #5994 - taiki-e:useless_attribute, r=phansch
useless_attribute: Permit wildcard_imports and enum_glob_use

Fixes #5918

changelog: `useless_attribute`: Permit `wildcard_imports` and `enum_glob_use` on `use` items
2020-09-03 05:33:03 +00:00
Michael Wright
93ce686b5d Update ui stderr with improved rustc output
Related rust pull request: rust-lang/rust#76160
2020-09-03 04:58:14 +02:00
Ricky
2387f68e43 Removed map_err suggestion in lint, and updated lint documentation example 2020-09-02 19:21:34 -04:00
Tim Nielens
b1f0e019fe Merge branch 'master' into unit-arg 2020-09-02 19:39:54 +02:00
bors
7f27b12288 Auto merge of #5996 - Koxiaet:master, r=ebroto
Allow GraphQL in docs without backticks

changelog: Allow "GraphQL" in [`doc_markdown`] without backticks.
2020-09-02 12:24:31 +00:00