Commit graph

4627 commits

Author SHA1 Message Date
jrqc
96efaee552 cargo dev update_lints 2020-08-16 00:24:27 +03:00
jrqc
a7d5c2f967 Modifications according to the code review 2020-08-16 00:24:27 +03:00
jrqc
cd6ca72e0e Known problems changed 2020-08-16 00:24:27 +03:00
jrqc
65d10c7abf Borrow checker added 2020-08-16 00:24:27 +03:00
jrqc
85f4ef0fbd Visitor added 2020-08-16 00:24:27 +03:00
jrqc
6d18fe730e Make needless_return a late lint pass 2020-08-16 00:24:27 +03:00
bors
f0cc006964 Auto merge of #5910 - flip1995:rustup, r=flip1995
Rustup

r? @ghost

changelog: none
2020-08-15 12:05:11 +00:00
Christoph Walcher
b381ade179
elide lifetimes 2020-08-15 01:40:55 +02:00
Christoph Walcher
ae56e988a2
Merge lint with single_char_pattern 2020-08-15 01:40:55 +02:00
Christoph Walcher
72d2c2eab4
Lint push_str with a single-character string literal
Fixes #5875
2020-08-15 01:40:55 +02:00
Takayuki Nakata
f98ffa271d Fix FP for same_item_push
Don't emit a lint when `pushed_item` was declared as mutable variable.
2020-08-14 22:54:12 +09:00
chansuke
8e549978e5 Don't use to_string in impl Display 2020-08-14 21:38:11 +09:00
Christoph Walcher
8514b8407a
appreciative too_large_for_stack in useless vec!
Fixes: #5847
2020-08-14 14:29:16 +02:00
Erich Gubler
48a142559d
docs: typo in temporary_cstring_as_ptr: s/point/&s 2020-08-13 13:52:21 -06:00
Bastian Kauschke
429a1cedfa merge as_local_hir_id with local_def_id_to_hir_id 2020-08-13 16:55:16 +02:00
bors
d5f5487252 Auto merge of #5899 - JarredAllen:rc-box-suggestion, r=yaahc
Change Rc<Box<T>> recommendation to be Rc<T> instead of Box<T>

Fixes #5722

changelog: Suggest `Rc<Box<T>>` -> `Rc<T>` in [`redundant_allocation`] lint
2020-08-13 13:31:55 +00:00
bors
fc4fd91914 Auto merge of #5900 - ThibsG:ParensUselessConversion4750, r=phansch
Fix: keep parenthesis for suggestion in `useless_conversion` lint

Note: this lint was previously named `identity_conversion`.

fixes: #4750

changelog: fix parenthesis for `useless_conversion` lint suggestion
2020-08-13 05:27:29 +00:00
JarredAllen
4e28d99f41 Replace panics with early returns 2020-08-12 13:24:55 -07:00
ThibsG
5634c8da02 Fix: keep parenthesis for suggestion in useless_conversion lint 2020-08-12 21:44:02 +02:00
bors
dc1e09bdc1 Auto merge of #5897 - matthiaskrgr:no_clone_tts, r=flip1995
write.rs: don't clone TokenStream

changelog: none
2020-08-12 17:36:23 +00:00
JarredAllen
480ccc3dbe Change Rc<Box<T>> recommendation to be Rc<T> instead of Box<T> 2020-08-12 10:35:08 -07:00
bors
439bae62a4 Auto merge of #5884 - Ryan1729:patch-1, r=flip1995
Add the other overloadable operations to suspicious_arithmetic_impl

In #2268 I idly mused that the other user-overloadable operations could be added to this lint. Knowing that the lint was arguably incomplete was gnawing at the back of my mind, so I figured that I might as well make this PR, particularly given the change needed was so small.

changelog: Start warning on suspicious implementations of the `BitAnd`, `BitOr`, `BitXor`, `Rem`, `Shl`, and `Shr` traits.
2020-08-12 17:00:48 +00:00
bors
c73cf9f387 Auto merge of #5893 - matthiaskrgr:lint_msg, r=yaahc
fix remaining lint messages

r? @yaahc

changelog:  make remaining lint messages adhere to rustc dev guide lint message convention.
2020-08-12 16:33:57 +00:00
Ryan Wiedemann
c70581732d trailing comma
Should have actually ran rustfmt on it, rather than attempting to fix it manually
2020-08-12 10:33:16 -06:00
Ryan Wiedemann
616682deb7 formatting 2020-08-12 10:33:16 -06:00
Ryan Wiedemann
0fc61becb5 Add the other overloadable operations to suspicious_arithmetic_impl
In #2268 I idly mused that the other user-overloadable operations could be added to this lint. Knowing that the lint was arguably incomplete was gnawing at the back of my mind, so I figured that I might as well make this PR, particularly given the change needed was so small.
2020-08-12 10:33:16 -06:00
bors
2f4de2fc75 Auto merge of #5885 - Ryan1729:patch-2, r=flip1995
Add example of false positive to PTR_ARG docs.

Addresses #214

changelog: Add example of false positive to `ptr_arg` docs.
2020-08-12 15:51:39 +00:00
flip1995
318c74af2b
Merge remote-tracking branch 'upstream/master' into rustup 2020-08-12 17:03:54 +02:00
Ryan Wiedemann
7d2e42daec
fix typo pointed out in review comment
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-08-12 08:54:32 -06:00
Matthias Krüger
8a96b9cdfe write.rs: don't clone TokenStream 2020-08-12 14:35:31 +02:00
bors
fdc2f879f1 Auto merge of #75405 - flip1995:clippyup, r=Manishearth
Update Clippy

Biweekly Clippy update (2 days late, since I wanted to wait for https://github.com/rust-lang/rust/pull/75098)

r? @Manishearth
2020-08-12 00:34:19 +00:00
flip1995
027780ca2c Merge commit '09bd400243ed6f7059fedc0c1623aae3792521d6' into clippyup 2020-08-11 17:50:45 +02:00
Matthias Krüger
be3e695b60 if_not_else: make lint adhere to lint message convention 2020-08-11 16:43:53 +02:00
Matthias Krüger
605e027fda if_let_some_result: make lint adhere to lint message convention 2020-08-11 16:40:45 +02:00
Matthias Krüger
89591a78b8 enum-variant-names: make lint adhere to lint message convention 2020-08-11 16:38:20 +02:00
Matthias Krüger
db390f5e6a enum-clike-unportable-variant: tweak message a bit (Clike -> C-like) 2020-08-11 16:35:09 +02:00
Matthias Krüger
2de290d5c5 duration-subsec: make lint adhere to lint message convention 2020-08-11 16:31:02 +02:00
Matthias Krüger
423615693b pub-enum-variant-names: make lint adhere to lint message convention 2020-08-11 16:28:05 +02:00
Matthias Krüger
1f17c3b02b multiple_inherent_impl: make lint adhere to lint message convention 2020-08-11 15:28:51 +02:00
Matthias Krüger
bdf4dc3abd implicit-saturating-sub: make lint adhere to lint message convention 2020-08-11 15:22:59 +02:00
Matthias Krüger
f171f89aed int_plus_one: make lint adhere to lint message convention 2020-08-11 15:15:26 +02:00
Matthias Krüger
6af297f80e iter-next-slice: make lint adhere to lint message convention 2020-08-11 15:15:26 +02:00
Matthias Krüger
04867e004e mutex-atomic: make lint adhere to lint message convention 2020-08-11 15:15:26 +02:00
Matthias Krüger
ac194cafc1 map_clone: make lint adhere to lint message convention 2020-08-11 15:15:26 +02:00
Matthias Krüger
c0a9d64818 stable-sort-primitive: make lint adhere to lint message convention 2020-08-11 15:15:26 +02:00
bors
3337f7956c Auto merge of #5892 - matthiaskrgr:redundant_mut, r=flip1995
unnecessary-mut-passed: make lint message say if fn is a function or a method

changelog: refine "unnecessary-mut-passed" lint message
2020-08-11 12:52:41 +00:00
bors
09bd400243 Auto merge of #5891 - flip1995:rustup, r=flip1995
Rustup

r? @ghost

Sync back rust-lang/rust#75098

changelog: none
2020-08-11 12:32:10 +00:00
flip1995
9311c11d7c
Fix sync fallout 2020-08-11 14:21:27 +02:00
Matthias Krüger
b8713e3854 unnecessary-mut-passed: make lint message say if fn is a function or a method. 2020-08-11 14:16:56 +02:00
Yuki Okushi
91aa55d891 Rollup merge of #75226 - pnadon:miri-undef-uninit, r=RalfJung
Miri: Renamed "undef" to "uninit"

Renamed remaining references to "undef" to "uninit" when referring to Miri.

Impacted directories are:

- `src/librustc_codegen_llvm/consts.rs`
- `src/librustc_middle/mir/interpret/`
- `src/librustc_middle/ty/print/pretty.rs`
- `src/librustc_mir/`
- `src/tools/clippy/clippy_lints/src/consts.rs`

Upon building Miri based on the new changes it was verified that no changes needed to be made with the Miri project.

Related issue #71193
2020-08-11 16:23:47 +09:00
Dylan DPC
9e73d33680 Rollup merge of #75098 - Ryan1729:clippy-pointer-cast-lint-experiment, r=oli-obk
Clippy pointer cast lint experiment

This PR is an experiment about exposing more parts of `rustc_typeck` for use in `clippy`. In particular, the code that checks where a cast is valid or not was exposed, which necessitated exposing [`FnCtxt`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_typeck/check/struct.FnCtxt.html), and figuring out how to create an instance of that type inside `clippy`.

This was prompted by [this clippy issue](https://github.com/rust-lang/rust-clippy/issues/2064).

r? @oli-obk
2020-08-11 01:56:30 +02:00
bors
cc5bfd473c Auto merge of #5888 - matthiaskrgr:lints, r=yaahc
make a bunch of lints texts adhere to rustc dev guide

According to the rustc-dev guide: "The text should be matter of fact and avoid capitalization and periods, unless multiple sentences are needed"

changelog: make some lint output adhere to the rustc-dev guide
2020-08-10 22:40:42 +00:00
Matthias Krüger
1b46e485b2 Update clippy_lints/src/unwrap.rs
Co-authored-by: Jane Lusby <jlusby42@gmail.com>
2020-08-10 23:57:08 +02:00
Matthias Krüger
c514ff0c93 Update clippy_lints/src/neg_cmp_op_on_partial_ord.rs
Co-authored-by: Jane Lusby <jlusby42@gmail.com>
2020-08-10 23:57:08 +02:00
Matthias Krüger
dabf989195 neg-cmp-op-on-partial-ord: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
178da9b2ef neg-multiply: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
e519bb3c85 overflow-check-conditional: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
9178363574 path-buf-push-overwrite: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
81f77a411e range-zip-with-len: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
3e1e0c9bdb redundant-static-lifetimes: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
5d69ca5e11 also change "deprecated-attribute" message 2020-08-10 23:49:06 +02:00
Matthias Krüger
fe37ddbd11 suspicious-arithmetic-impl: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
7954c22a99 unknown: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
b36a6c9594 ref_in_deref: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
4418ff122f unneeded-field-pattern: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
2792260636 empty-liner-after-outer-attr: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
0db5cb1393 drop_bounds: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
590b91d8d4 double-parens: make lint adhere to lint message convention and do minor refactoring 2020-08-10 23:49:06 +02:00
Matthias Krüger
ba7a01a6a8 double-comparisons: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
6b0a6a70f8 default-trait-access: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
3d592b5154 cmp_null: make lint adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
8679dd375b unnecessary_unwrap, panicking_unwrap: make lints adhere to lint message convention 2020-08-10 23:49:06 +02:00
Matthias Krüger
9b7ab1d38b checked-conversions: make lint adhere to lint message convention 2020-08-10 23:48:57 +02:00
Eduardo Broto
5d66bd7bb3 Avoid or_fun_call for const_fn with no args 2020-08-10 23:38:58 +02:00
Matthias Krüger
40416c0fa8 naive_bytecount: make lint adhere to lint message convention 2020-08-10 20:55:23 +02:00
Matthias Krüger
fd379a889e builtin-type-shadow: make lint adhere to lint message convention 2020-08-10 20:55:23 +02:00
Matthias Krüger
0876f17d77 bool-comparison: make lint adhere to lint message convention 2020-08-10 20:55:23 +02:00
Matthias Krüger
e57aafe33f too-many-lines: make lint adhere to lint message convention 2020-08-10 20:55:23 +02:00
Ryan Wiedemann
fbf637d12c
formatting 2020-08-10 09:19:40 -06:00
Ryan Wiedemann
3e3e50bf0f
Add example of false positive to PTR_ARG docs.
Fixes #214
2020-08-10 08:50:20 -06:00
Philipp Krones
ee8db50e13
Rollup merge of #5871 - wiomoc:feature/methodcall-minmax, r=flip1995
Lint .min(x).max(y) with x < y

Fixes  #5854

changelog: Also lint `ord.min(a).max(b)`, where `a < b` in [`min_max`] lint
2020-08-10 14:56:29 +02:00
Philipp Krones
08ab29bed1
Rollup merge of #5870 - ebroto:5789_allow_unsafe_derive_deserialize, r=flip1995
enable #[allow(clippy::unsafe_derive_deserialize)]

Before this change this lint could not be allowed as the code we are checking is automatically generated.

changelog: Enable using the `allow` attribute on top of an ADT linted by [`unsafe_derive_deserialize`].

Fixes: #5789
2020-08-10 14:56:27 +02:00
Philipp Krones
8ee57eed79
Rollup merge of #5869 - wiomoc:feature/implicit-self, r=ebroto,flip1995
New lint against `Self` as an arbitrary self type

Fixes #5861

changelog: * [`needless_arbitrary_self_type`] [#5869](https://github.com/rust-lang/rust-clippy/pull/5869)
2020-08-10 14:56:26 +02:00
Philipp Krones
9da5b6d1d0
Rollup merge of #5825 - giraffate:same_item_push, r=Manishearth
Add the new lint `same_item_push`

changelog: Add the new lint `same_item_push`

Fixed #4078. As I said in https://github.com/rust-lang/rust-clippy/issues/4078#issuecomment-658184195, I referrerd to https://github.com/rust-lang/rust-clippy/pull/4647.
2020-08-10 14:56:25 +02:00
Tim Nielens
f9ba829f67 should_impl_trait - self linting 2020-08-09 16:09:08 +02:00
Tim Nielens
166c520e9a should_impl_trait - pr comments 2020-08-09 15:10:00 +02:00
Tim Nielens
7cc1a2ed87 should_implement_trait - filter on explicit lifetime param only 2020-08-09 15:10:00 +02:00
Tim Nielens
e6b2254f9e should_implement_trait - pr remarks 2020-08-09 15:10:00 +02:00
Tim Nielens
2bc0ecd44b should_implement_trait - add test cases for every checked trait method 2020-08-09 15:10:00 +02:00
Tim Nielens
a77e881ec9 should_impl_trait - ignore methods with lifetime params 2020-08-09 15:10:00 +02:00
bors
70c46de012 Auto merge of #5877 - ebroto:5872_loops_ice, r=Manishearth
Fix ICE in `loops` module

changelog: Fix ICE related to `needless_collect` when a call to `iter()` was not present.

I went for restoring the old suggestion of `next().is_some()` over `get(0).is_some()` given that `iter()` is not necessarily present (could be e.g. `into_iter()` or `iter_mut()`)  and that the old suggestion could change semantics, e.g. a call to `filter()` could be present between `iter()` and the collect part.

Fixes #5872
2020-08-08 18:44:48 +00:00
bors
3899d6001c Auto merge of #5878 - flip1995:rustup, r=flip1995
Rustup

r? @ghost

changelog: none
2020-08-08 17:28:34 +00:00
flip1995
fd87cdb357
Run fmt 2020-08-08 19:20:34 +02:00
Eduardo Broto
888657e09a Fix ICE in loops module 2020-08-08 18:13:43 +02:00
Philippe Nadon
2d1515a2c5 Miri: Renamed "undef" to "uninit"
Renamed remaining references to "undef" to "uninit" when referring to Miri.

Impacted directories are:

- src/librustc_codegen_llvm/consts.rs
- src/librustc_middle/mir/interpret/
- src/librustc_middle/ty/print/pretty.rs
- src/librustc_mir/
- src/tools/clippy/clippy_lints/src/consts.rs

Upon building Miri based on the new changes it was verified that no changes needed to be made with the Miri project.

Related issue #71193
2020-08-08 07:53:47 -06:00
Nicholas Nethercote
01bba2c532 Eliminate the SessionGlobals from librustc_ast.
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This
means they are accessed via the `Session`, rather than via TLS. A few
`Attr` methods and `librustc_ast` functions are now methods of
`Session`.

All of this required passing a `Session` to lots of functions that didn't
already have one. Some of these functions also had arguments removed, because
those arguments could be accessed directly via the `Session` argument.

`contains_feature_attr()` was dead, and is removed.

Some functions were moved from `librustc_ast` elsewhere because they now need
to access `Session`, which isn't available in that crate.
- `entry_point_type()` --> `librustc_builtin_macros`
- `global_allocator_spans()` --> `librustc_metadata`
- `is_proc_macro_attr()` --> `Session`
2020-08-08 12:03:42 +10:00
Christoph Walcher
87e740921a
check impl Ord / is_float 2020-08-07 18:30:20 +02:00
Christoph Walcher
bfe610cc8d
ignore mutable self reference parameters 2020-08-07 18:08:51 +02:00
Christoph Walcher
e03f73e627
fix nits 2020-08-07 18:08:51 +02:00
Christoph Walcher
d635b76eaf
adopt comments from review 2020-08-07 18:08:51 +02:00
Christoph Walcher
737f62cb6e
fix doc 2020-08-07 18:08:51 +02:00
Christoph Walcher
e0a4988fcc
Lint against Self as an arbitrary self type
Fixes #5861
2020-08-07 18:08:51 +02:00
Vadim Petrochenkov
a285b58368 Add some comments for magic numbers + Add tests 2020-08-06 22:55:26 +03:00
Vadim Petrochenkov
d642c3b6f8 Fix clippy 2020-08-06 22:13:11 +03:00
Ryan Wiedemann
49c7e39d03 Apply suggestions from code review
Co-authored-by: Philipp Krones <hello@philkrones.com>
2020-08-06 07:57:31 -06:00
Ryan1729
42f3d39a54 run clippy_dev fmt
This seemed to overdo it a bit, affecting multiple submodules, and changing a file I didn't touch, so I didn't commit those changes
2020-08-06 06:15:57 -06:00
Ryan1729
0d2a378547 run clippy_dev update_lints 2020-08-06 06:11:23 -06:00
Ryan1729
8997c558d8 change filter to assert, and update comments 2020-08-06 04:24:25 -06:00
Ryan1729
94340d6e17 add documentation to functions that call do_check and add a test against lint ordering changing 2020-08-06 04:24:25 -06:00
Ryan1729
19f36bc2f3 add description to assert 2020-08-06 04:24:25 -06:00
Ryan1729
d38766ed96 address some review comments 2020-08-06 04:24:25 -06:00
Ryan1729
ccc4747f46 get the expected number of errors by acknowledging that other lints are covering the same ground 2020-08-06 04:24:25 -06:00
Ryan1729
de05212987 try putting the can_be_expressed_as_pointer_cast at the top and find that we still get an ICE 2020-08-06 04:24:24 -06:00
Ryan1729
34d3a0086c accidentally cause an ICE by putting the TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS handling after the match
The reason I did this in the first place was to try and figure out why I don't see my expected 7 error messages
2020-08-06 04:24:24 -06:00
Ryan1729
069f851671 initial compiling version of TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS 2020-08-06 04:24:24 -06:00
Ryan1729
5e84b8c2fb run cargo dev new_lint then move transmutes_expressible_as_ptr_casts into transmute module 2020-08-06 04:24:24 -06:00
Christoph Walcher
0abc4833e5
Lint .min(x).max(y) with x < y
Fixes #5854
2020-08-06 02:56:07 +02:00
Eduardo Broto
50a86d4927 enable #[allow(clippy::unsafe_derive_deserialize)] 2020-08-06 00:45:30 +02:00
bors
2d4c3379d3 Auto merge of #5809 - JarredAllen:stable_sort_primitive, r=Manishearth
Stable sort primitive

changelog: Implements #5762
2020-08-05 20:41:21 +00:00
bors
2eab060ab7 Auto merge of #5859 - ebroto:5765_manual_async_fn_fp, r=yaahc
manual_async_fn: take input lifetimes into account

The anonymous future returned from an `async fn` captures all input
lifetimes. This was not being taken into account.

See https://github.com/rust-lang/rfcs/blob/master/text/2394-async_await.md#lifetime-capture-in-the-anonymous-future

changelog: Take input lifetimes into account in [`manual_async_fn`].

Fixes #5765
2020-08-05 17:52:28 +00:00
Takayuki Nakata
610d4e3c8b rustfmt 2020-08-05 23:10:30 +09:00
Takayuki Nakata
e48685edef Just check if it contains _ in for pat 2020-08-05 23:00:03 +09:00
Takayuki Nakata
228f668282 Use mutated_variables 2020-08-05 23:00:03 +09:00
Takayuki Nakata
b7ceb4d3d7 rustfmt 2020-08-05 23:00:03 +09:00
Takayuki Nakata
14a4e3bcc8 Fix a lint message 2020-08-05 22:59:12 +09:00
Takayuki Nakata
1543e117cc cargo dev update_lints 2020-08-05 22:51:38 +09:00
Takayuki Nakata
2beb9090d1 Rename TypeckTables to TypeckResults 2020-08-05 22:51:38 +09:00
Takayuki Nakata
161f475100 Add test case for same_item_push 2020-08-05 22:51:38 +09:00
Takayuki Nakata
1e8ada3cab Add lint same_item_push 2020-08-05 22:51:38 +09:00
bors
3d7e3fdffd Auto merge of #5857 - tmiasko:try-err-poll, r=matthiaskrgr
try_err: Consider Try impl for Poll when generating suggestions

There are two different implementation of `Try` trait for `Poll` type:
`Poll<Result<T, E>>` and `Poll<Option<Result<T, E>>>`. Take them into
account when generating suggestions.

For example, for `Err(e)?` suggest either `return Poll::Ready(Err(e))` or
`return Poll::Ready(Some(Err(e)))` as appropriate.

Fixes #5855

changelog: try_err: Consider Try impl for Poll when generating suggestions
2020-08-05 08:43:37 +00:00
JarredAllen
542740c2ec Run cargo dev fmt 2020-08-04 17:53:29 -07:00
bors
2ceb8c6c2d Auto merge of #5865 - camsteffen:unnecessary-fold-known-probs, r=Manishearth
Remove obsolete known problems unnecessary_fold

The known problems looks to be obsolete since NLL is stable.

changelog: none
2020-08-04 23:09:35 +00:00
Philipp Krones
fb7ad956f6
Rollup merge of #5856 - phansch:remove-symbol-reexport, r=flip1995
Remove old Symbol reexport

I couldn't really tell what it was meant to improve. It seems more clear
without the renaming to `Name`?

changelog: none
2020-08-04 12:06:43 +02:00
Philipp Krones
84455b211f
Rollup merge of #5852 - wiomoc:feature/lint-duplicate-trait, r=Manishearth
Add lint for duplicate methods of trait bounds

rel: #5777

changelog: Add [`trait_duplication_in_bounds`] lint
2020-08-04 12:06:41 +02:00
Philipp Krones
888067c623
Rollup merge of #5848 - Ryan1729:add-derive_ord_xor_partial_ord-lint, r=matthiaskrgr
Add derive_ord_xor_partial_ord lint

Fix #1621

Some remarks:
This PR follows the example of the analogous derive_hash_xor_partial_eq lint where possible.
I initially tried using the `match_path` function to identify `Ord` implementation like the derive_hash_xor_partial_eq lint currently does, for `Hash` implementations but that didn't work.

Specifically, the structs at the top level were getting paths that matched `&["$crate", "cmp", "Ord"]` instead of `&["std", "cmp", "Ord"]`. While trying to figure out what to do instead I saw the comment at the top of [clippy_lints/src/utils/paths.rs](f5d429cd76/clippy_lints/src/utils/paths.rs (L5)) that mentioned [this issue](https://github.com/rust-lang/rust-clippy/issues/5393) and suggested to use diagnostic items instead of hardcoded paths whenever possible. I looked for a way to identify `Ord` implementations with diagnostic items, but (possibly because this was the first time I had heard of diagnostic items,) I was unable to find one.

Eventually I tried using `get_trait_def_id` and comparing `DefId` values directly and that seems to work as expected. Maybe there's a better approach however?

changelog: new lint: derive_ord_xor_partial_ord
2020-08-04 12:06:40 +02:00
Philipp Krones
378ba2e03e
Rollup merge of #5846 - dima74:map_flatten.map_to_option, r=flip1995
Handle mapping to Option in `map_flatten` lint

Fixes #4496

The existing [`map_flatten`](https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten) lint suggests changing `expr.map(...).flatten()` to `expr.flat_map(...)` when `expr` is `Iterator`. This PR changes suggestion to `filter_map` instead of `flat_map` when mapping to `Option`, because it is more natural

Also here are some questions:
* If expression has type which implements `Iterator` trait (`match_trait_method(cx, expr, &paths::ITERATOR) == true`), how can I get type of iterator elements? Currently I use return type of closure inside `map`, but probably it is not good way
* I would like to change suggestion range to cover only `.map(...).flatten()`, that is from:
```
    let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect();
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `flat_map` instead: `vec![5_i8; 6].into_iter().flat_map
```
to
```
    let _: Vec<_> = vec![5_i8; 6].into_iter().map(|x| 0..x).flatten().collect();
                                             ^^^^^^^^^^^^^^^^^^^^^^^^ help: try using `flat_map` instead: `.flat_map(|x| 0..x)`
```
Is it ok?
* Is `map_flatten` lint intentionally in `pedantic` category, or could it be moved to `complexity`?

changelog: Handle mapping to Option in [`map_flatten`](https://rust-lang.github.io/rust-clippy/master/index.html#map_flatten) lint
2020-08-04 12:06:39 +02:00
Philipp Krones
ca2a25d966
Rollup merge of #5837 - JarredAllen:needless_collect, r=phansch
needless_collect: catch x: Vec<_> = iter.collect(); x.into_iter() ...

changelog: Expand the needless_collect lint as suggested in #5627 (WIP).

This PR is WIP because I can't figure out how to make the multi-part suggestion include its changes in the source code (the fixed is identical to the source, despite the lint making suggestions). Aside from that one issue, I think this should be good.
2020-08-04 12:06:38 +02:00
bors
1968aede0f Auto merge of #5867 - flip1995:rustup, r=flip1995
Rustup

r? @ghost

changelog: none
2020-08-04 09:25:05 +00:00
Vadim Petrochenkov
52a9c157d0 rustc_ast: (Nested)MetaItem::check_name -> has_name
For consistency with `Attribute::has_name` which doesn't mark the attribute as used either.

Replace all uses of `check_name` with `has_name` outside of rustc
2020-08-04 00:34:11 +03:00
Cameron Steffen
0ccdf2913a
Remove obsolete known problems unnecessary_fold 2020-08-03 16:23:20 -05:00
Tomasz Miąsko
e9677105bf try_err: Consider Try impl for Poll when generating suggestions
There are two different implementation of Try trait for Poll type;
Poll<Result<T, E>> and Poll<Option<Result<T, E>>>. Take them into
account when generating suggestions.

For example, for Err(e)? suggest either return Poll::Ready(Err(e)) or
return Poll::Ready(Some(Err(e))) as appropriate.
2020-08-03 20:48:18 +02:00
JarredAllen
25abd7ae76 Create stable_sort_primitive lint 2020-08-03 11:17:43 -07:00
Christoph Walcher
e521c67e5f
early return on empty parameters/where clause 2020-08-03 12:32:23 +02:00
JarredAllen
5e10b039a3 Implement review suggestions 2020-08-02 21:46:18 -07:00
JarredAllen
bb2c14e92b Fix a bug causing it to be too trigger-happy 2020-08-02 21:34:17 -07:00
JarredAllen
a849483294 Fix formatting and dogfood fallout 2020-08-02 21:34:17 -07:00
JarredAllen
3657c92ac9 Check for other things which can be used indirectly 2020-08-02 21:34:17 -07:00
JarredAllen
3ee61373fe Write the lint and write tests 2020-08-02 21:34:17 -07:00
Eduardo Broto
e336fe80d2 manual_async_fn: take input lifetimes into account
The anonymous future returned from an `async fn` captures all input
lifetimes. This was not being taken into account.

See https://github.com/rust-lang/rfcs/blob/master/text/2394-async_await.md#lifetime-capture-in-the-anonymous-future
2020-08-03 00:36:28 +02:00
Philipp Hansch
bb6e857980
fmt 2020-08-02 14:22:54 +02:00
Philipp Hansch
cb00cdf0d7
Remove old Symbol reexport
I couldn't really tell what it was meant to improve. It seems more clear
without the renaming to `Name`?
2020-08-02 11:25:03 +02:00
Valentin Lazureanu
aa3d9ca0e9 Rename HAIR to THIR (Typed HIR). 2020-07-31 22:15:12 +00:00
Dmitry Murzin
d4ba561aaf
Review fixes 2020-07-31 00:28:21 +03:00
Dmitry Murzin
a427c99f3d
Handle mapping to Option in map_flatten lint 2020-07-30 23:23:33 +03:00
Christoph Walcher
2b7fde6a4b
typo fix 2020-07-29 16:10:15 +02:00
bors
2e0f8b6cc6 Auto merge of #5843 - dima74:iter_skip_next.add-suggestion, r=phansch
Add suggestion for `iter_skip_next` lint

changelog: Add suggestion for [`iter_skip_next`](https://rust-lang.github.io/rust-clippy/master/index.html#iter_skip_next) lint
2020-07-29 06:10:55 +00:00
flip1995
04f4471761
Merge remote-tracking branch 'upstream/master' into rustup 2020-07-29 03:17:23 +02:00
Christoph Walcher
94c50bc8c9
Lint duplicate methods of trait bounds
Fixes #5777
2020-07-28 16:42:26 +02:00
Bastian Kauschke
133e1d6773 clippy 2020-07-27 21:17:28 +02:00
Bastian Kauschke
6ce37fab95 introduce PredicateAtom 2020-07-27 21:07:37 +02:00
Bastian Kauschke
88787083f4 this might be unqualified, but at least it's now quantified 2020-07-27 21:06:36 +02:00
Bastian Kauschke
dfa1af2059 clippy 2020-07-27 21:06:36 +02:00
Takayuki Nakata
3a9ccffed8 chmod 644 clippy_lints/src/utils/ast_utils.rs 2020-07-27 22:27:54 +09:00
Ryan1729
94b10a6e5a run cargo dev update_lints 2020-07-27 00:31:09 -06:00
Ryan1729
12a6eee045 fill in lint description for DERIVE_ORD_XOR_PARTIAL_ORD 2020-07-27 00:22:39 -06:00
Ryan1729
ca03f2b650 s/pord/partial_ord/ to fix dogfood failure 2020-07-27 00:21:11 -06:00
Ryan1729
668b7474b4 run cargo dev fmt and fix overly long line 2020-07-26 23:30:00 -06:00
Ryan1729
431924ccf6 add description for derive_ord_xor_partial_ord 2020-07-26 23:15:36 -06:00
Ryan1729
7dc974815e remove is_local check since getting the def_id directly makes it unnecessary 2020-07-26 23:06:36 -06:00
Ryan1729
a8d6eda930 use get_trait_def_id to check for Ord trait 2020-07-26 23:04:04 -06:00
Ryan1729
068acbd27b initial implementation based on code for derive_hash_xor_partial_eq which is showing one error when there should be four 2020-07-26 22:04:46 -06:00
Ryan1729
fc20ee63a1 move derive_ord_xor_partial_ord into derive mod so we can reuse derive_hash_xor_partial_eq code later 2020-07-26 20:54:04 -06:00
Ryan1729
5a644964fc run cargo dev new_lint
specifically:
cargo dev new_lint --name derive_ord_xor_partial_ord --category correctness --pass late
2020-07-26 20:40:57 -06:00
bors
f5d429cd76 Auto merge of #5820 - ThibsG:FixSuspiciousArithmeticImpl, r=flip1995
Fix FP for `suspicious_arithmetic_impl` from `suspicious_trait_impl` …

As discussed in #3215, the `suspicious_trait_impl` lint causes too many false positives, as it is complex to find out if binary operations are suspicious or not.

This PR restricts the number of binary operations to at most one, otherwise we don't lint.
This can be seen as very conservative, but at least FP can be reduced to bare minimum.

Fixes: #3215

changelog: limit the `suspicious_arithmetic_impl` lint to one binop, to avoid many FPs
2020-07-26 19:48:17 +00:00
flip1995
d164ab65f7 Merge commit 'da5a6fb1b65ec6581a67e942a3850f6bc15a552c' into clippyup 2020-07-26 21:07:07 +02:00
Takayuki Nakata
c81bbd05b9 Fix FP useless_conversion
Fix #5833.
2020-07-25 23:58:22 +09:00
Dmitry Murzin
b375f1dd20
Add suggestion for iter_skip_next lint 2020-07-25 17:11:55 +03:00
bors
79f948ec0a Auto merge of #5829 - JohnTitor:epsilon, r=flip1995
Use `(std::)f64::EPSILON` in the examples as suggested in the lints

`float_cmp(_const)` suggests using `{f32|f64}::EPSILON` and it'd be great if the docs mentioned it.

changelog: none
2020-07-23 18:48:35 +00:00
bors
8c83d5f484 Auto merge of #5830 - flip1995:rustup, r=flip1995
trait_sel: only test predicates w/ no substs

r? @ghost
changelog: none
2020-07-21 22:10:04 +00:00
Yuki Okushi
142a273441
Use (std::)f64::EPSILON in the examples as suggested in the lints 2020-07-22 05:23:55 +09:00
David Wood
b7c8b96e66 trait_sel: only test predicates w/ no substs
This commit modifies the `substitute_normalize_and_test_predicates`
query, renaming it to `impossible_predicates` and only checking
predicates which do not require substs. By making this change,
polymorphization doesn't have to explicitly support vtables.

Signed-off-by: David Wood <david@davidtw.co>
2020-07-20 11:23:26 +01:00
bors
61e3d8a55c Auto merge of #5824 - tmiasko:manually-drop-clone, r=Manishearth
Ignore not really redundant clones of ManuallyDrop

"Redundant" clones of `ManuallyDrop` are sometimes used for the side effect of
invoking the clone, without running the drop implementation of the inner type.
In other words, they aren't really redundant. For example, futures-rs crate:

```rust
#[allow(clippy::redundant_clone)] // The clone here isn't actually redundant.
unsafe fn increase_refcount<T: ArcWake>(data: *const ()) {
    // Retain Arc, but don't touch refcount by wrapping in ManuallyDrop
    let arc = mem::ManuallyDrop::new(Arc::<T>::from_raw(data as *const T));
    // Now increase refcount, but don't drop new refcount either
    let _arc_clone: mem::ManuallyDrop<_> = arc.clone();
}
```

changelog: Ignore redundant clone lint for ManuallyDrop.
2020-07-20 01:36:21 +00:00
Tomasz Miąsko
a5cdd4aeb1 Ignore not really redundant clones of ManuallyDrop
"Redundant" clones of `ManuallyDrop` are sometimes used for the side effect of
invoking the clone, without running the drop implementation of the inner type.
In other words, they aren't really redundant. For example, futures-rs crate:

```rust
#[allow(clippy::redundant_clone)] // The clone here isn't actually redundant.
unsafe fn increase_refcount<T: ArcWake>(data: *const ()) {
    // Retain Arc, but don't touch refcount by wrapping in ManuallyDrop
    let arc = mem::ManuallyDrop::new(Arc::<T>::from_raw(data as *const T));
    // Now increase refcount, but don't drop new refcount either
    let _arc_clone: mem::ManuallyDrop<_> = arc.clone();
}
```

Ignore redundant clone lint for ManuallyDrop.
2020-07-20 00:56:27 +02:00
Tim Nielens
1ac8b85c9f redundant_closure_call - pr review 2020-07-20 00:36:31 +02:00
Tim Nielens
9603d9652b redundant_closure_call - add support for shadowed closures 2020-07-20 00:30:43 +02:00
Tim Nielens
0fecaf1abc redundant_closure_call - extract lint from misc_early.rs, adapt to LatePass 2020-07-20 00:30:43 +02:00
Tim Nielens
c720d823e1 redundant_closure_call - don't lint when used more than once 2020-07-20 00:30:43 +02:00
ThibsG
442c8ae23b Fix FP for suspicious_arithmetic_impl from suspicious_trait_impl lint 2020-07-19 00:00:17 +02:00
bors
8cf4219c16 Auto merge of #5815 - JarredAllen:redundant_pattern_bugfix, r=flip1995
Redundant pattern bugfix

changelog: Fixes the bug reported #5766
2020-07-18 14:43:36 +00:00
flip1995
0f501ac1db
Merge remote-tracking branch 'upstream/master' into rustup 2020-07-18 15:09:58 +02:00
bors
9a945c7413 Auto merge of #5817 - flip1995:rustup, r=flip1995
Rustup

r? @ghost

Preparation for emergency Clippyup to fix an ICE #5816

changelog: none
2020-07-17 19:41:39 +00:00
flip1995
3d3a13d871
Fix sync fallout (fmt) 2020-07-17 21:39:05 +02:00
JarredAllen
e85b590936 Fix bug in lint 2020-07-17 10:40:01 -07:00
Takayuki Nakata
e5105e82d3 Fix typo 2020-07-17 22:51:57 +09:00
Valentin Lazureanu
5a20489c5c Rename TypeckTables to TypeckResults. 2020-07-17 08:47:04 +00:00
bors
57678c8315 Auto merge of #5811 - JarredAllen:panic_multiple_args, r=phansch
Panic multiple args

changelog: Fixes bug with `panic` lint reported in #5767. I also did the same changes to the lints for `todo`, `unimplemented` and `unreachable`, so those lints should now also detect calls to those macros with a message.
2020-07-17 06:41:20 +00:00
Matthias Krüger
3618b97f59 fix typos (found by codespell) 2020-07-17 01:58:41 +02:00
JarredAllen
07867fde59 Clean up dogfood fallout 2020-07-16 16:58:21 -07:00
JarredAllen
70a41a9281 Enable detecting multiple-argument panics 2020-07-16 16:51:12 -07:00
Nicholas Nethercote
62db617e40 Avoid storing SymbolStr in a struct.
It's intended only for very temporary use.
2020-07-17 08:28:22 +10:00
bors
9349441863 Auto merge of #5788 - Leulz:shadow-unrelated-fix-rhs, r=flip1995
Removing RHS snippet from SHADOW_UNRELATED message.

Fixes #5703

I am not sure if I reinvented the wheel here, but I could not really find a snippet function that did this truncation, so I created the function. Please tell me if there was a more obvious way to do this, I am new here. 😄

changelog: Truncates multi-line RHS in shadow_unrelated message if it has more than 5 lines.
2020-07-15 19:09:21 +00:00
flip1995
d9bf74e2f2
Merge remote-tracking branch 'upstream/master' into rustup 2020-07-15 20:15:57 +02:00
Leo Meira Vital
a0640457a9 Removing snippet from SHADOW_UNRELATED message. 2020-07-15 11:12:38 -03:00
Bastian Kauschke
bf3104ec24 WithOptConstParam::dummy -> WithOptConstParam::unknown 2020-07-15 13:06:47 +02:00
Bastian Kauschke
c5b9463d26 improve naming 2020-07-15 13:06:47 +02:00
Bastian Kauschke
29de25b8a2 const_eval_resolve 2020-07-15 12:58:32 +02:00
Nicholas Nethercote
f2f99be2ff Remove lots of Symbol::as_str() calls.
In various ways, such as changing functions to take a `Symbol` instead
of a `&str`.
2020-07-15 09:01:35 +10:00
bors
128c5dec92 Auto merge of #5793 - warner:5783-nth-zero-next, r=flip1995
improve advice in iter_nth_zero

fixes #5783

*Please keep the line below*
changelog:  For iter_nth_zero, the "use .next()" replacement advice is on the last line of the code snippet, where it is vulnerable to truncation. Display that advice at the beginning instead.
2020-07-14 16:58:23 +00:00
Brian Warner
e83b3eb993 formatting nits 2020-07-14 09:20:19 -07:00
Matthias Krüger
126790999a new lint: Returning unit from closures expecting Ord
This lint catches cases where the last statement of a closure expecting
an instance of Ord has a trailing semi-colon. It compiles since the
closure ends up return () which also implements Ord but causes
unexpected results in cases such as sort_by_key.

Fixes #5080

reprise: rebase, update and address all concerns
2020-07-14 15:54:04 +02:00
flip1995
6f25adbd5a Merge commit '2ca58e7dda4a9eb142599638c59dc04d15961175' into clippyup 2020-07-14 14:59:59 +02:00
bors
2ca58e7dda Auto merge of #5732 - bjorn3:patch-1, r=flip1995
Rename collapsable_if fix suggestion to "collapse nested if block"

The name "try" is confusing when shown as quick fix by rust-analyzer

changelog: Rename `collapsable_if` fix suggestion to "collapse nested if block"
2020-07-14 09:39:01 +00:00
bors
12df6384b9 Auto merge of #5773 - giraffate:repeat_once, r=flip1995
Add a lint for `.repeat(1)`

changelog: New lint `repeat_once`

fix #3028.
2020-07-14 09:13:58 +00:00
Takayuki Nakata
b4091032ab Use .is_some() not Some(_) 2020-07-14 08:08:13 +09:00
Brian Warner
201999ccfd improve advice in iter_nth_zero
The "use .next()" replacement advice is on the last line of the code snippet,
where it is vulnerable to truncation. Display that advice at the beginning
instead.

closes #5783
2020-07-13 10:59:45 -07:00
bjorn3
ff796b6d70 Rename collapsable_if fix suggestion to "collapse nested if block"
The name "try" is confusing when shown as quick fix by rust-analyzer
2020-07-13 17:54:57 +02:00
Takayuki Nakata
f2419b9d62 Refactoring to use `constant_context
Use `constant_context`, `.is_str()` and `builtin_index()` to simplify.
2020-07-14 00:23:20 +09:00
bors
4b8700879c Auto merge of #5792 - flip1995:rollup-torc1we, r=flip1995
Rollup of 5 pull requests

Successful merges:

 - #5443 (Some accuracy lints for floating point operations)
 - #5752 (Move range_minus_one to pedantic)
 - #5756 (unnecessary_sort_by: avoid linting if key borrows)
 - #5784 (Fix out of bounds access by checking length equality BEFORE accessing by index.)
 - #5786 (fix phrase in new_lint issue template)

Failed merges:

r? @ghost

changelog: rollup
2020-07-13 14:21:20 +00:00
Philipp Krones
26ede3115f
Rollup merge of #5784 - matthiaskrgr:ice_5780, r=phansch
Fix out of bounds access by checking length equality BEFORE accessing by index.

Fixes #5780

changelog: fix out of bounds access in unnested_or_patterns lint.

Edit: I did not bother reducing a testcase from `librustc_typeck` crate but I can confirm that with the change the crash no longer occurs.
2020-07-13 15:59:45 +02:00
Philipp Krones
32ef448bdb
Rollup merge of #5756 - ebroto:5754_sort_by, r=flip1995
unnecessary_sort_by: avoid linting if key borrows

changelog: Avoid linting if key borrows in [`unnecessary_sort_by`]

Fixes #5754
Closes #2313
2020-07-13 15:59:44 +02:00
Philipp Krones
019e281d15
Rollup merge of #5752 - chrisduerr:pedantic_ranges, r=flip1995
Move range_minus_one to pedantic

This moves the range_minus_one lint to the pedantic category, so there
will not be any warnings emitted by default. This should work around
problems where the suggestion is impossible to resolve due to the range
consumer only accepting a specific range implementation, rather than the
`RangeBounds` trait (see #3307).

While it is possible to work around this by extracting the boundary into
a variable, I don't think clippy should encourage people to disable or
work around lints, but instead the lints should be fixable. So hopefully
this will help until a proper implementation checks what the range is
used for.

*Please keep the line below*
changelog: move [`range_minus_one`] to pedantic
2020-07-13 15:59:42 +02:00
Philipp Krones
75d43aac73
Rollup merge of #5443 - thiagoarrais:issue-2040, r=flip1995
Some accuracy lints for floating point operations

This will add some lints for accuracy on floating point operations suggested by @clarfon in #2040 (fixes #2040).

These are the remaining lints:

- [x] x.powi(2) => x * x
- [x] x.logN() / y.logN() => x.logbase(y)
- [x] x.logbase(E) => x.log()
- [x] x.logbase(10) => x.log10()
- [x] x.logbase(2) => x.log2().
- [x] x * PI / 180 => x.to_radians()
- [x] x * 180 / PI => x.to_degrees()
- [x] (x + 1).log() => x.log_1p()
- [x] sqrt(x * x + y * y) => x.hypot(y)

changelog: Included some accuracy lints for floating point operations
2020-07-13 15:59:41 +02:00
bors
fa4a737fba Auto merge of #5790 - flip1995:rustup, r=flip1995
Rustup

r? @ghost

changelog: none
2020-07-13 13:53:11 +00:00
Matthias Krüger
1b3bc16533 Fix out of bounds access by checking length equality BEFORE accessing by index.
Fixes #5780
2020-07-11 12:30:18 +02:00
bors
7d611d9224 Auto merge of #5769 - robojumper:match_like_matches_macro, r=phansch
new lint: match_like_matches_macro

Suggests using the `matches!` macro from `std` where appropriate.

`redundant_pattern_matching` has been moved into the `matches` pass to allow suppressing the suggestion where `is_some` and friends are a better replacement.

changelog: new lint: `match_like_matches_macro`
2020-07-10 18:10:08 +00:00
Takayuki Nakata
780a4c87de Fix typo 2020-07-10 23:53:15 +09:00
Christian Duerr
ba2a85dadc
Run update_lints 2020-07-10 15:20:00 +02:00
Christian Duerr
298a1fa3bd
Move range_minus_one to pedantic
This moves the range_minus_one lint to the pedantic category, so there
will not be any warnings emitted by default. This should work around
problems where the suggestion is impossible to resolve due to the range
consumer only accepting a specific range implementation, rather than the
`RangeBounds` trait (see #3307).

While it is possible to work around this by extracting the boundary into
a variable, I don't think clippy should encourage people to disable or
work around lints, but instead the lints should be fixable. So hopefully
this will help until a proper implementation checks what the range is
used for.
2020-07-10 15:20:00 +02:00
Tamir Duberstein
cf91c54cc6 Avoid "whitelist"
Other terms are more inclusive and precise.
2020-07-10 07:39:28 -04:00
bors
45eea9a822 Auto merge of #5771 - montrivo:bugfix/single-match-else, r=matthiaskrgr
single_match_else - single expr/stmt else block corner case

One approach to fix #3489.
See discussion in the issue.

changelog: single_match_else - single expr/stmt else block corner case fix
2020-07-09 12:03:14 +00:00
Tim Nielens
dac19e3afc single_match_else - single expr/stmt else block corner case 2020-07-09 12:04:27 +02:00
Eduardo Broto
db1c946aaa unnecessary_sort_by: avoid linting if key borrows 2020-07-08 21:31:59 +02:00
robojumper
37d75da266 make match_like_matches_macro only apply to matches with a wildcard 2020-07-08 18:37:20 +02:00
bors
e12a316b01 Auto merge of #5776 - flip1995:rustup, r=flip1995
Rustup

changelog: none

r? @ghost
2020-07-08 15:56:23 +00:00
Takayuki Nakata
5307cb5614 Add a lint for .repeat(1)
fix #3028.
2020-07-07 23:13:39 +09:00
bors
c41fcad908 Auto merge of #74117 - Manishearth:rollup-ds7z0kx, r=Manishearth
Rollup of 14 pull requests

Successful merges:

 - #70563 ([rustdoc] Page hash handling)
 - #73856 (Edit librustc_lexer top-level docs)
 - #73870 (typeck: adding type information to projection)
 - #73953 (Audit hidden/short code suggestions)
 - #73962 (libstd/net/tcp.rs: #![deny(unsafe_op_in_unsafe_fn)])
 - #73969 (mir: mark mir construction temporaries as internal)
 - #73974 (Move A|Rc::as_ptr from feature(weak_into_raw) to feature(rc_as_ptr))
 - #74067 (rustdoc: Restore underline text decoration on hover for FQN in header)
 - #74074 (Fix the return type of Windows' `OpenOptionsExt::security_qos_flags`.)
 - #74078 (Always resolve type@primitive as a primitive, not a module)
 - #74089 (Add rust-analyzer to the build manifest)
 - #74090 (Remove unused RUSTC_DEBUG_ASSERTIONS)
 - #74102 (Fix const prop ICE)
 - #74112 (Expand abbreviation in core::ffi description)

Failed merges:

r? @ghost
2020-07-07 00:56:44 +00:00
Manish Goregaokar
245b006a2e Rollup merge of #73870 - sexxi-goose:projection-ty, r=nikomatsakis
typeck: adding type information to projection

This commit modifies the Place as follow:
* remove 'ty' from ProjectionKind
* add type information into to Projection
* replace 'ty' in Place with 'base_ty'
* introduce 'ty()' in `Place` to return the final type of the `Place`
* introduce `ty_before_projection()` in `Place` to return the type of
  a `Place` before i'th projection is applied

Closes https://github.com/rust-lang/project-rfc-2229/issues/5
2020-07-06 17:45:20 -07:00
bors
4705037374 Auto merge of #73978 - Mark-Simulacrum:shrink-paramenv, r=nnethercote
Shrink ParamEnv to 16 bytes

r? @nnethercote

x.py check passes but I haven't tried running perf or tests
2020-07-06 20:44:16 +00:00
Thiago Arrais
3065201eb3 Includes TODO for constants equivalent to π/180 2020-07-06 13:45:43 -03:00
Thiago Arrais
6be9491eac Reclassify powi(2) lint under suboptimal_flops 2020-07-06 13:45:43 -03:00
Thiago Arrais
db7bc6b3bd Place radian lints under suboptimal_flops 2020-07-06 13:45:43 -03:00
Thiago Arrais
f5596826fa Better copy for lint message
Since x.log(y) is actually implemented as x.ln() / y.ln()
2020-07-06 13:45:43 -03:00
Thiago Arrais
076ec872ce Lint for to_radians and to_degrees 2020-07-06 13:45:39 -03:00
robojumper
1740dda763 fix match_like_matches_macro in clippy 2020-07-06 18:35:58 +02:00
Thiago Arrais
0c8afa39ce Lint x.log(b) / y.log(b) => x.log(y) 2020-07-06 13:32:31 -03:00
robojumper
2e8a1be444 new lint: match_like_matches_macro 2020-07-06 18:25:20 +02:00
Thiago Arrais
f62798454c Lint (x * x + y * y).sqrt() => x.hypot(y) 2020-07-06 13:23:17 -03:00
Thiago Arrais
a6f1af75d7 Lint for x.powi(2) => x * x 2020-07-06 13:23:17 -03:00
Mark Rousskov
3503247c11 Shrink ParamEnv to 16 bytes 2020-07-05 09:51:42 -04:00
JarredAllen
c8f700ea69 Fixed compile errors 2020-07-03 21:22:23 -07:00
JarredAllen
1c32263176 Formatted updates to lints 2020-07-03 16:51:44 -07:00
JarredAllen
6ce981225b Clean existing lint code to match new lint 2020-07-03 16:51:44 -07:00
JarredAllen
ccb999851a Fix compile error from library change 2020-07-03 16:50:45 -07:00
JarredAllen
93f0f5d37b Last few tweaks 2020-07-03 16:50:45 -07:00
JarredAllen
5150277a4f Used clippy to clean itself 2020-07-03 16:50:45 -07:00
JarredAllen
5e20475e47 Don't lint if contains a macro 2020-07-03 16:47:38 -07:00
JarredAllen
7c4de9d3de Refactoring pt. 2 2020-07-03 16:47:38 -07:00
JarredAllen
f73b455b99 Refactoring 2020-07-03 16:47:38 -07:00
JarredAllen
88c8afdddf Handle ref, mut, &, and &mut on the option 2020-07-03 16:47:38 -07:00
JarredAllen
b85796fe36 Properly parenthesize to avoid operator precedence errors 2020-07-03 16:47:38 -07:00
JarredAllen
82f8d4d6f1 Stop linting on macros and correctly use braces for constructs 2020-07-03 16:47:38 -07:00
JarredAllen
bf48a2d50d Lint for if let Some(x) = ... instead of Option::map_or 2020-07-03 16:47:38 -07:00
bors
57cdf2dc16 Auto merge of #4841 - phaylon:pattern-type-mismatch, r=flip1995
Added restriction lint: pattern-type-mismatch

changelog: Added a new restriction lint `pattern-type-mismatch`. This lint is especially helpful for beginners learning about the magic behind pattern matching. (This explanation might be worth to include in the next changelog.)
2020-07-03 16:41:26 +00:00
Robert Sedlacek
c0fd452840 fmt fix 2020-07-03 18:23:36 +02:00
Robert Sedlacek
aa4bee228f LateContext has only one lifetime parameter now 2020-07-03 18:20:19 +02:00
Robert Sedlacek
d617551a6a Expanded lint documentation 2020-07-03 18:12:29 +02:00
Robert Sedlacek
92ecc53691 Catching up with rustc changes 2020-07-03 18:12:29 +02:00
flip1995
6447507ab1 Fix rebase fallout 2020-07-03 18:12:29 +02:00
Robert Sedlacek
55877d7b4a span_help_and_lint -> span_lint_and_help 2020-07-03 18:12:29 +02:00
Robert Sedlacek
c3c402783f Added restriction lint: pattern-type-mismatch 2020-07-03 18:12:29 +02:00
ThibsG
2d5930a3da Don't lint for predicates generated in macros 2020-07-03 17:29:54 +02:00
ThibsG
d5a8f03a35 Take generic args into account for bounded type 2020-07-03 17:29:54 +02:00
ThibsG
754bfb1dc8 Add configurable threshold for type_repetition_in_bounds lint 2020-07-03 17:29:54 +02:00
flip1995
a7c58e66d4
Merge remote-tracking branch 'upstream/master' into rustup 2020-07-03 12:50:41 +02:00
Eduard-Mihai Burtescu
30c046ede4 Use 'tcx for references to AccessLevels wherever possible. 2020-07-03 00:04:48 +03:00
Eduard-Mihai Burtescu
590e07bbc2 rustc_lint: avoid using TypeckTables::empty for LateContext. 2020-07-02 16:51:04 +03:00
Philipp Hansch
d347d0cf59
Deprecate regex_macro lint 2020-07-01 13:05:41 +02:00
bors
36b7983580 Auto merge of #5758 - ebroto:5704_unnested_or_pats, r=flip1995
Require `or_patterns` to suggest nesting them

changelog: Require `#![feature(or_patterns)]` to trigger [`unnested_or_patterns`]

Fixes #5704
2020-06-30 22:23:23 +00:00
Eduardo Broto
bff6c435ef Require or_patterns to suggest nesting them 2020-07-01 00:15:21 +02:00
Eduardo Broto
c5d8f530e0 Move blanket_clippy_restriction_lints to "style" 2020-06-30 21:56:19 +02:00
Eduardo Broto
814349f941 Lint enabling the whole restriction group 2020-06-30 21:56:19 +02:00
flip1995
1e861a2663
Merge remote-tracking branch 'upstream/master' into rustup2 2020-06-30 15:40:22 +02:00
Azhng
dfecaef914 typeck: adding type information to projection
This commit modifies the Place as follow:
* remove 'ty' from ProjectionKind
* add type information into to Projection
* replace 'ty' in Place with 'base_ty'
* introduce 'ty()' in `Place` to return the final type of the `Place`
* introduce `ty_before_projection()` in `Place` to return the type of
  a `Place` before i'th projection is applied

Closes https://github.com/rust-lang/project-rfc-2229/issues/5
2020-06-29 16:46:52 -04:00
bors
81810fa8f4 Auto merge of #73756 - Manishearth:rollup-aehswb2, r=Manishearth
Rollup of 13 pull requests

Successful merges:

 - #72620 (Omit DW_AT_linkage_name when it is the same as DW_AT_name)
 - #72967 (Don't move cursor in search box when using arrows to navigate results)
 - #73102 (proc_macro: Stop flattening groups with dummy spans)
 - #73297 (Support configurable deny-warnings for all in-tree crates.)
 - #73507 (Cleanup MinGW LLVM linkage workaround)
 - #73588 (Fix handling of reserved registers for ARM inline asm)
 - #73597 (Record span of `const` kw in GenericParamKind)
 - #73629 (Make AssocOp Copy)
 - #73681 (Update Chalk to 0.14)
 - #73707 (Fix links in `SliceIndex` documentation)
 - #73719 (emitter: column width defaults to 140)
 - #73729 (disable collectionbenches for android)
 - #73748 (Add code block to code in documentation of `List::rebase_onto`)

Failed merges:

r? @ghost
2020-06-26 10:11:43 +00:00
Manish Goregaokar
a671ea4d3f Rollup merge of #73597 - ayazhafiz:i/const-span, r=ecstatic-morse
Record span of `const` kw in GenericParamKind

Context: this is needed for a fix of https://github.com/rust-lang/rustfmt/issues/4263,
which currently records the span of a const generic param incorrectly
because the location of the `const` kw is not known.

I am not sure how to add tests for this; any guidance in how to do so
would be appreciated 🙂
2020-06-26 00:39:08 -07:00
Eduard-Mihai Burtescu
f5ce0e5fe9 rustc_lint: only query typeck_tables_of when a lint needs it. 2020-06-26 02:56:23 +03:00
Carol (Nichols || Goulding)
fa0f1d3e53
Change a noun to a verb to make the sentence complete 2020-06-25 11:25:21 -04:00
bors
46d33043d5 Auto merge of #5701 - ebroto:4874_cmp_owned_fp, r=flip1995
cmp_owned: handle when PartialEq is not implemented symmetrically

changelog: Handle asymmetrical implementations of PartialEq in [`cmp_owned`].

Fixes #4874
2020-06-24 12:48:24 +00:00
bors
a14eab389f Auto merge of #5745 - montrivo:copy_on_clone, r=phansch
clone_on_copy - add machine applicability

Fix #4826.
Change the applicability of the lint clone_on_copy. Split a test file and run rustfix on the clone_on_copy part.

changelog: clone_on_copy - add machine applicability
2020-06-24 07:11:07 +00:00
Tim Nielens
6bf5434e19 copy_on_clone - add machine applicability 2020-06-24 01:01:44 +02:00
Eduardo Broto
b498e1d715 cmp_owned: reverse operands if necessary 2020-06-23 22:14:45 +02:00
Eduardo Broto
5987c7d404 cmp_owned: avoid FP when PartialEq is not implemented symmetrically 2020-06-23 22:14:45 +02:00
Ayaz Hafiz
7c1b3aa0dd Record span of const kw in GenericParamKind
Context: this is needed to fix https://github.com/rust-lang/rustfmt/issues/4263,
which currently records the span of a const generic param incorrectly
because the location of the `const` kw is not known.

I am not sure how to add tests for this; any guidance in how to do so
would be appreciated 🙂
2020-06-23 09:25:46 -07:00
bors
583d644934 Auto merge of #5694 - wangtheo:issue-5626, r=matthiaskrgr
#5626: lint iterator.map(|x| x)

changelog: adds a new lint for iterator.map(|x| x) (see https://github.com/rust-lang/rust-clippy/issues/5626)

The code also lints for result.map(|x| x) and option.map(|x| x). Also, I'm not sure if I'm checking for type adjustments correctly and I can't think of an example where .map(|x| x) would apply type adjustments.
2020-06-23 15:59:27 +00:00
Teddy_Wang
fb4f9a0ad7 Fix pattern match of ExprKind::MethodCall 2020-06-23 11:40:38 -04:00
flip1995
80bcbf521c Merge commit 'c2c07fa9d095931eb5684a42942a7b573a0c5238' into clippyup 2020-06-23 17:05:22 +02:00
bors
c2c07fa9d0 Auto merge of #5740 - lzutao:unused-unused, r=flip1995
Remove unused allowed unused attributes

changelog: none
2020-06-23 14:34:18 +00:00
bors
c420382ac2 Auto merge of #5738 - mikerite:loops-20200623-2, r=matthiaskrgr
Improve end of expression check in for loop lints

changelog: none
2020-06-23 14:05:45 +00:00
Lzu Tao
7374185b36 Remove unused allowed unused attributes 2020-06-23 20:59:35 +07:00
Philipp Krones
e4cbd1df4e
Rollup merge of #5726 - sozysozbot:patch-1, r=flip1995
Fix typo

changelog: extending it's lifetime -> extending its lifetime
2020-06-23 14:39:50 +02:00