Commit graph

2971 commits

Author SHA1 Message Date
Manish Goregaokar
7eb8018554 Rename in_macro to in_macro_or_desugar 2019-05-11 21:39:02 -07:00
Manish Goregaokar
19cfb84405 Start handling desugarings in author lint 2019-05-10 23:43:58 -07:00
Manish Goregaokar
0499184201 Ignore desugarings in macro checks 2019-05-10 23:40:42 -07:00
Manish Goregaokar
5661e5947f Add IfDesugar to desugaring_name 2019-05-10 23:40:42 -07:00
Manish Goregaokar
26ebc3e9a1 Fix consts.rs 2019-05-10 23:40:42 -07:00
Manish Goregaokar
c9ed92ce20 More uses of higher::if_block 2019-05-10 23:40:42 -07:00
Manish Goregaokar
69b1da4d82 Remove some unnecessary If arms 2019-05-10 23:40:42 -07:00
Manish Goregaokar
da8b56d99a Fix needless_bool.rs 2019-05-10 23:40:42 -07:00
Manish Goregaokar
09a93291ec Fix question_mark.rs 2019-05-10 23:40:42 -07:00
Manish Goregaokar
f40c77a776 Fix shadow.rs 2019-05-10 23:40:42 -07:00
Manish Goregaokar
62897747fd Fix unwrap.rs 2019-05-10 23:40:42 -07:00
Manish Goregaokar
e7af60f258 Add util function for desugaring if block 2019-05-10 23:40:42 -07:00
Andy Russell
9ede56f383
use derive feature over serde_derive crate 2019-05-09 13:05:34 -04:00
Matthias Krüger
857c2c53bf rustup https://github.com/rust-lang/rust/pull/60586
cc https://github.com/rust-lang/rust/issues/60623
2019-05-08 06:58:37 +02:00
Matthias Krüger
d618637c05 Rustup to rustc 1.36.0-nightly (13fde05b1 2019-05-03) 2019-05-03 22:28:34 -07:00
Jean Mertz
ff244b6c43
Fix link in into_iter_on_array documentation
The non-inline variant wasn't being rendered correctly.

see: https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_array
2019-05-03 17:38:13 +02:00
bors
8b906f94f3 Auto merge of #4053 - euclio:too-many-args-span, r=flip1995
remove function body from "too many args" span

changelog: Remove the function body from the "too many arguments" span.
2019-05-03 07:26:55 +00:00
Andy Russell
9253506112
remove function body from "too many args" span 2019-05-02 10:36:59 -04:00
bors
8151a17422 Auto merge of #4049 - airt:fix-4033-search_is_some, r=flip1995
Fix #4033 search_is_some

Fixes #4033.

Suggest `any(|x| ..)` instead of `any(|&x| ..)` for `find(|&x| ..).is_some()` (Lint [search_is_some](https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some))

FnDecl of `find`:

```rust
fn find<P>(&mut self, mut p: P) -> Option<Self::Item> where
    P: FnMut(&Self::Item) -> bool
```

FnDecl of `any`:

```rust
fn any<F>(&mut self, mut f: F) -> bool where
    F: FnMut(Self::Item) -> bool
```

If match on `|&_|` in closure of `find`, only use `|_|` in the suggestion.

PS. It's the first time that I have used the `hir` API, please correct me if there is any mistake 😺
2019-05-02 08:45:02 +00:00
bors
1cf5d7f04c Auto merge of #4035 - JoshMcguigan:useless_let_if_seq-3043, r=oli-obk
useless_let_if_seq handle interior mutability

fixes #3043

This passes all tests, including a new one specifically dealing with a type with interior mutability. The main thing I'm unsure of is whether the span I used in the call to `is_freeze` is the most appropriate span to use, or if it matters.
2019-05-02 07:03:28 +00:00
Matthias Krüger
f195680edb more Use->DropTemps fixes 2019-05-01 23:04:35 +02:00
Matthias Krüger
24e856f10a rustup https://github.com/rust-lang/rust/pull/60417/
cc https://github.com/rust-lang/rust/issues/60448
2019-05-01 22:18:16 +02:00
Matthias Krüger
6967cf59a4 clippy-driver: use rustc_tools_util to get version info.
This will add git hash information to `clippy-driver -V` output.
2019-05-01 10:43:16 +02:00
airt
d063516c85 check closure arguments before use it 2019-05-01 04:41:00 +08:00
airt
5d6a100f81 format code 2019-05-01 04:03:51 +08:00
André Luis Leal Cardoso Junior
e428862c95 Update find(p).map(p) occurrences to use find_map(p) 2019-04-30 16:45:32 -03:00
André Luis Leal Cardoso Junior
b411391f8e Add lints for find_map 2019-04-30 16:45:28 -03:00
airt
c3fde34fd5 fix suggestion for search_is_some 2019-05-01 03:11:58 +08:00
airt
bd0b75f6c3 fix suggestion for search_is_some naively 2019-05-01 01:08:16 +08:00
Manish Goregaokar
83519d3ca0 Rustup to rustc 1.36.0-nightly (f843ad60e 2019-04-30) 2019-04-29 22:31:39 -07:00
Manish Goregaokar
79f48d0573 Rustup to rustc 1.36.0-nightly (c7fcbfbf1 2019-04-29)
See https://github.com/rust-lang/rust/pull/60317
2019-04-28 22:42:16 -07:00
bors
78d13e007f Auto merge of #4043 - rust-lang:map-clone-iter, r=matthiaskrgr
Suggest .copied() for map_clone on iterators too

fixes https://github.com/rust-lang/rust-clippy/issues/3958

changelog: Make `map_clone` suggest the newly-stable `Iterator::copied()` when applicable

r? @mikerite @matthiaskrgr
2019-04-28 18:39:00 +00:00
Manish Goregaokar
770de14505 Suggest .copied() for map_clone on iterators too 2019-04-28 11:14:39 -07:00
Matthias Krüger
e01caad2a8 deps: bump toml from 0.4 to 0.5 2019-04-28 19:24:36 +02:00
Michael Wright
5ad79c2b3d Fix breakage due to rust-lang/rust#60225 2019-04-28 09:11:20 +02:00
Josh Mcguigan
2bbe8be8d0 useless_let_if_seq handle interior mutability 2019-04-25 19:07:01 -07:00
bors
910d538ef1 Auto merge of #4008 - g-bartoszek:boxed-fnmut, r=phansch
Do not trigger redundant_closure for non-function types

fixes #3898

Added a check for the entity being called in the closure body to be a FnDef. This way lint does not trigger for ADTs (Box) but I'm not sure if it's correct and not too restrictive.

<!--
Thank you for making Clippy better!

We're collecting our changelog from pull request descriptions.
If your PR only updates to the latest nightly, you can leave the
`changelog` entry as `none`. Otherwise, please write a short comment
explaining your change.

If your PR fixes an issue, you can add "fixes #issue_number" into this
PR description. This way the issue will be automatically closed when
your PR is merged.

If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.

- [ ] Followed [lint naming conventions][lint_naming]
- [ ] Added passing UI tests (including committed `.stderr` file)
- [ ] `cargo test` passes locally
- [ ] Executed `util/dev update_lints`
- [ ] Added lint documentation
- [ ] Run `cargo fmt`

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

Delete this line and everything above before opening your PR -->

changelog: Fix false positive in `redundant_closure` pertaining to non-function types
2019-04-25 18:13:47 +00:00
bors
6a0105e59f Auto merge of #4026 - cemiloten:working-on-#3981, r=flip1995
Attempt to fix #3981

Fixes #3981

Hi, hopefully this is correct, happy to have feedback.

changelog: Don't trigger `unnecessary_cast` inside a macro
2019-04-25 10:37:30 +00:00
cemil
8eae2d3707 Ignore unnecessary cast if inside macro 2019-04-25 12:06:20 +02:00
bors
8c0e038f6f Auto merge of #4029 - phansch:update_pulldown_cmark, r=oli-obk
Update pulldown_cmark to 0.5

We now no longer have to use our own wrapper around `Parser` and can use
the new `OffsetIter`.

changelog: none
2019-04-25 09:16:46 +00:00
Philipp Hansch
1f5a3c6e52
Rustup for https://github.com/rust-lang/rust/pull/59042 2019-04-25 07:29:23 +02:00
Philipp Hansch
32e877ce13
Update pulldown_cmark to 0.5
We now no longer have to use our own wrapper around `Parser` and can use
the new `OffsetIter`.
2019-04-24 22:54:12 +02:00
Matthew Kraai
5c7349d430 Remove approx_constant known problems
Fixes #4025.
2019-04-24 09:29:45 -07:00
bors
253601a91c Auto merge of #4024 - kraai:suppress-let_and_return-if-let-has-attributes, r=flip1995
Suppress let_and_return if let has attributes

Fixes #3882.

changelog: suppress `let_and_return` if `let` has attributes
2019-04-24 07:29:35 +00:00
Matthew Kraai
c0479402e4 Suppress let_and_return if let has attributes
Fixes #3882.
2019-04-23 23:32:16 -07:00
Matthew Kraai
9a43e09d77 Change "if types change" to "if you later change the type"
Fixes #3964.
2019-04-23 16:53:09 -07:00
bors
9897442f27 Auto merge of #4018 - rust-lang:or_fn_call_variants, r=oli-obk
Ignore non-const ctor expressions in or_fn_call

Fixes https://github.com/rust-lang/rust-clippy/issues/1338

Should have been fixed by #919, however that focuses on const ctor expressions only, and `.or(Some(local))` isn't const.

This also automatically ignores things like `.or(Some(local.clone())` which we don't actually want to do; I need to figure out what to do here.

changelog: Fixed false positive in [`or_fn_call`] pertaining to enum variant constructors

r? @oli-obk @phansch
2019-04-23 18:24:10 +00:00
Manish Goregaokar
f3455cda81 Rustup to rustc 1.36.0-nightly (fe0a415b4 2019-04-23) 2019-04-23 08:25:45 -07:00
Manish Goregaokar
7e2043de2f Ignore all enum and struct constructors in lints about *or(call()) 2019-04-23 08:01:42 -07:00
bors
d420589e1a Auto merge of #4013 - kraai:move-path_buf_push_overwrite-to-nursery, r=matthiaskrgr
Move path_buf_push_overwrite to nursery

See #4012.

changelog: move `path_buf_push_overwrite` to the nursery
2019-04-21 20:44:03 +00:00
Igor Matuszewski
930f1e6129 Use newly-introduced mutability query for statics
Fixes fallout from https://github.com/rust-lang/rust/pull/60124.
cc https://github.com/rust-lang/rust/issues/60154
2019-04-21 21:15:34 +02:00
Matthew Kraai
4171299632 Move path_buf_push_overwrite to nursery
See #4012.
2019-04-21 10:24:51 -07:00
Grzegorz
4f801a278d redundant closure triggers for fnptrs and closures 2019-04-20 22:20:14 +02:00
bors
54e80c7b34 Auto merge of #4007 - phansch:fix_allowing_toplevel_ref_arg, r=flip1995
Allow allowing of toplevel_ref_arg lint

I'm not sure why some lints need the `HirId` to be able to recognize the
lint level attributes, but this commit makes the lint level attributes
work for `toplevel_ref_arg`.

Fixes #2332

changelog: Allow allowing of `toplevel_ref_arg` lint
2019-04-20 18:22:53 +00:00
bors
7a6d5c00d3 Auto merge of #4006 - phansch:fix_module_name_repetitions_fp, r=flip1995
Fix false positive in module_name_repetitions lint

This lint was triggering on modules inside expanded attrs, like
for example `#[cfg(test)]` and possibly more.

It was not reporting a location in #3892 because `span.lo()` and `span.hi()` both were 0.

Fixes #3892

changelog: Fix false positive in `module_name_repetitions` lint
2019-04-20 16:58:51 +00:00
Philipp Hansch
158aa39a7c
Allow allowing of toplevel_ref_arg lint
I'm not sure why some lints need the `HirId` to be able to recognize the
lint level attributes, but this commit makes the lint level attributes
work for `toplevel_ref_arg`.
2019-04-19 15:18:32 +02:00
Grzegorz
aa9cf07d56 redundant closure for functions restricted to FnDefs 2019-04-19 15:14:49 +02:00
Philipp Hansch
850c24edd3
Fix false positive in module_name_repetitions lint
This lint was triggering on modules inside expanded attrs, like
for example `#[cfg(test)]` and possibly more.
2019-04-19 12:53:03 +02:00
bors
12e8075d91 Auto merge of #3989 - flip1995:assert_on_const, r=phansch
Don't trigger assertions_on_constants on debug_assert!(false)

Fixes #3948
Fixes #3765

changelog: Fix `debug_assert!` false positive on `assertions_on_constants` lint
2019-04-19 09:57:35 +00:00
Felix Rabe
b4f2200d5c
Typo 2019-04-18 15:08:14 +02:00
flip1995
10cd28900f
Fix dogfood error 2019-04-18 13:37:20 +02:00
André Luis Leal Cardoso Junior
7e9cb5b84a Add lint PathBufPushOverwrite 2019-04-18 08:05:55 -03:00
flip1995
834ad76806
Remove code duplication 2019-04-18 12:04:46 +02:00
flip1995
40218bae0c
Format code 2019-04-18 11:50:45 +02:00
flip1995
be98df5ac3
Don't lint debug_assert!(false) 2019-04-18 11:47:39 +02:00
bors
b834dbb2d5 Auto merge of #3984 - phansch:bytecount_sugg, r=flip1995
Change naive_bytecount applicability to MaybeIncorrect

We can't use `MachineApplicable` here as applying the fix will cause
another error because `bytecount` would first have to be added to the
Cargo.toml.

Example:

```
error: You appear to be counting bytes the naive way
  --> $DIR/bytecount.rs:5:13
   |
LL |     let _ = x.iter().filter(|&&a| a == 0).count(); // naive byte count
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider using the bytecount crate: `bytecount::count(x, 0)`
```

Just replacing it with the suggestion is not enough.

cc #3630
2019-04-18 07:49:09 +00:00
Philipp Hansch
01ea9bd9d8
Change naive_bytecount applicability MaybeIncorrect
We can't use `MachineApplicable` here as applying the fix will cause
another error because `bytecount` would first have to be added to the
Cargo.toml.
2019-04-17 20:46:42 +02:00
Matthew Kraai
753c39672e Use lint pass macros
Fixes #3917.
2019-04-17 09:35:22 -07:00
flip1995
ce87051779 Fix lint_without_lint_pass internal lint 2019-04-17 06:51:21 -07:00
flip1995
840eac2c05
Use {get,match}_def_path from LateContext 2019-04-17 12:53:29 +02:00
flip1995
2f100e04af
Remove uplifted functions {get,match}_def_path from Clippy 2019-04-17 12:51:57 +02:00
bors
27d62cf603 Auto merge of #3966 - flip1995:internal_lints, r=oli-obk
Enable rustc internal lints

Closes #3965

I'm not 100% sure if enabling the `-Zunstable-options` flag in the `.cargo/config` file is the right place.
2019-04-17 04:46:19 +00:00
bors
1132caabff Auto merge of #3975 - phansch:has_placeholders, r=flip1995
Change while_let_loop applicability to HasPlaceholders

The suggestion has been changed at some point to use `..` in the suggested code.
Due to that we can't make the lint MachineApplicable anymore.

cc #3630
2019-04-17 01:14:27 +00:00
Philipp Hansch
e974d84d03
while_let_loop uses placeholders in suggestions
Due to that we can't make the lint MachineApplicable anymore.
2019-04-16 20:05:16 +02:00
Manish Goregaokar
e9cde416ba Only suggest .copied() for Option right now 2019-04-15 15:44:09 -07:00
Manish Goregaokar
ad2c65bd1b Also suggest .copied() when .clone() is called on a Copy type 2019-04-15 14:39:41 -07:00
Manish Goregaokar
d2f7ae70ae Suggest .copied() instead of .cloned() in map_clone when dealing with references 2019-04-15 14:32:39 -07:00
flip1995
445fa3b529
Deny rustc internal lints 2019-04-15 13:21:52 +02:00
flip1995
5361b842d1
Remove clippy::default_hash_types internal lint 2019-04-15 13:21:52 +02:00
Manish Goregaokar
2156f6733e Clean up unused cx parameters 2019-04-14 13:23:43 -07:00
Manish Goregaokar
3c93a95b1f HirIdify ReadVisitor 2019-04-14 13:18:34 -07:00
Manish Goregaokar
0c6956f8ce Use _from_hir_id APIs 2019-04-14 13:15:20 -07:00
Manish Goregaokar
1b2f2be085 Remove now-unnecessary calls to node_to_hir_id 2019-04-14 13:11:31 -07:00
Philipp Hansch
289a9af801
cargo fmt 2019-04-14 15:07:15 +02:00
Philipp Hansch
ad27e3ff9b
Refactor suspicious_else_formatting using if_chain 2019-04-14 11:12:51 +02:00
Philipp Hansch
96c34e85c4
Remove except in suspicious_else_formatting
This was causing two different ICEs in #3741.
The first was fixed in #3925.

The second one is fixed with this commit: We just don't `expect`
anymore. If the snippet doesn't contain an `else`, we stop emitting the
lint because it's not a suspiciously formatted else anyway.
2019-04-14 11:04:41 +02:00
bors
d516925ec8 Auto merge of #3946 - rchaser53:issue-3920, r=flip1995
fix format does not parse escaped braces error

related: https://github.com/rust-lang/rust-clippy/issues/3920
2019-04-12 17:03:01 +00:00
rchaser53
db6ca9b8d3 fix format does not parse escaped braces error 2019-04-13 01:39:10 +09:00
flip1995
3fe5eea4e4
Fix get_def_path
This fix is obsolet once rust-lang/rust#59779 and #3926 is merged.
2019-04-12 11:59:06 +02:00
bors
2278814c8e Auto merge of #3931 - phansch:3891, r=flip1995
Fix ICE in decimal_literal_representation lint

Handling the integer parsing properly instead of just unwrapping.

Note that the test is not catching the ICE because plain UI tests
[currently hide ICEs][compiletest_issue]. Once that issue is fixed, this
test would fail properly again.

Fixes #3891

[compiletest_issue]: https://github.com/laumann/compiletest-rs/issues/169
2019-04-10 20:57:15 +00:00
Philipp Hansch
ab6b949224
Refactor check_lit method 2019-04-10 21:05:56 +02:00
Tomas Koutsky
603996c9d5 Support updated type dependent def ID getter 2019-04-10 16:18:02 +02:00
Philipp Hansch
1fd2451b90
Code formatting/cleanup 2019-04-10 07:50:34 +02:00
Philipp Hansch
2b0dc39f5b
Don't emit useless_attribute lint in external macros 2019-04-10 07:30:59 +02:00
bors
37f5c1ec73 Auto merge of #3925 - phansch:3741, r=flip1995
Fix ICE in suspicious_else_formatting

Fixes #3741
2019-04-09 07:13:08 +00:00
Philipp Hansch
0307ff020c
Fix ICE in decimal_literal_representation lint
Handling the integer parsing properly instead of just unwrapping.

Note that the test is not catching the ICE because plain UI tests
[currently hide ICEs][compiletest_issue]. Once that issue is fixed, this
test would fail properly again.

[compiletest_issue]: https://github.com/laumann/compiletest-rs/issues/169
2019-04-08 22:16:34 +02:00
Klemen Košir
560fd163d6
Escape a single quote in single_char_pattern hint 2019-04-08 21:55:50 +09:00
bors
4fdd113bed Auto merge of #3921 - euclio:single-char-names-multispan, r=flip1995
use a multispan for MANY_SINGLE_CHAR_NAMES
2019-04-08 08:42:13 +00:00
bors
e91ba8af85 Auto merge of #3848 - felix91gr:null_transmute, r=flip1995
Transmuting known null ptr to ref

Working on implementing #628
2019-04-08 07:20:25 +00:00
bors
42e1cf3763 Auto merge of #3901 - rail-rain:issue_1670, r=flip1995
Fix `explicit_counter_loop` suggestion

#1670

This code seems to me to work, but I have two question.
* Because range expression desugared in hir, `Sugg::hir` doesn't add parenthesis to range expression.  Which function is better to check range do you think, `check_for_loop_explicit_counter` or `hir_from_snippet`?
* Do you think we need to distinguish between range expression and struct expression that creates `std::ops::Range*`?
2019-04-08 06:28:15 +00:00
Philipp Hansch
547c5c0667
cargo fmt 2019-04-08 07:56:54 +02:00
Philipp Hansch
60c1bb0546
Fix ICE in suspicious_else_formatting 2019-04-07 11:11:06 +02:00
Andy Russell
0d50d44ea6
use a multispan for MANY_SINGLE_CHAR_NAMES 2019-04-05 10:07:39 -04:00
Matthias Krüger
920e47ceb5 NFC: fix typos 2019-04-04 11:15:30 +02:00
Matthias Krüger
c81e43b92c rustup https://github.com/rust-lang/rust/pull/59657
commit: 4122d2221ec65232bc211a266d0796a4713e0d39
2019-04-03 10:48:54 +02:00
Félix Fischer
069957a8ad Add TransmutingNull Lint
* Late Lint pass, catches:
  * One liner: 0 -> null -> transmute
  * One liner: std:null() -> transmute
  * Const (which resolves to null) -> transmute
* UI Test case for Lint
* Updated test for issue 3849, because now the lint that code generated is in Clippy.
* Expanded `const.rs` miri-based Constant Folding code, to cover
  raw pointers
2019-04-02 11:39:43 -03:00
Philipp Hansch
b253c564d5
Rustup to https://github.com/rust-lang/rust/pull/58805 2019-04-01 20:37:05 +02:00
Félix Fischer
491f72442e
Updated source to match with recent rustc master toolchain changes 2019-04-01 20:37:05 +02:00
flip1995
bbb7963735
Fix dogfood error of question_mark lint fix 2019-04-01 20:37:05 +02:00
flip1995
6f01ecfefd
Fix question_mark lint+test 2019-04-01 20:37:05 +02:00
rail
2b82c71b55 use span_lint_and_sugg in explicit_counter_loop 2019-03-28 08:51:57 +09:00
Félix Fischer
3cff06a0eb Fix some test failures 2019-03-26 13:57:03 -03:00
Oliver Scherer
d020565ed2 Hacky rustup 2019-03-26 10:55:03 +01:00
Matthias Krüger
b5d82524b4 run cargo fmt 2019-03-23 23:39:58 +01:00
Matthias Krüger
e17dd4efa9 rustup https://github.com/rust-lang/rust/pull/59096/ 2019-03-23 23:37:38 +01:00
rail
9698e41994 Change explicit_counter_loop's message to add parentheses if necessary 2019-03-23 15:36:48 +09:00
rail
bd6c2df066 Change explicit_counter_loop's message to reflect original variable name 2019-03-23 15:30:17 +09:00
Mateusz Mikuła
6cb0605600 Cargo fmt 2019-03-18 13:39:11 +01:00
Mateusz Mikuła
664391c5f8 Drop range_contains feature 2019-03-18 12:54:10 +01:00
Mateusz Mikuła
8feb2c6b2f Fix rustfmt::skip detection 2019-03-18 12:54:10 +01:00
Mateusz Mikuła
fb7699d9e5 Rework clippy detection in attribute lint 2019-03-18 12:54:10 +01:00
Mateusz Mikuła
0ea5e38a9e name -> check_name 2019-03-18 12:54:10 +01:00
Mateusz Mikuła
4bb6c87b08 span -> span() 2019-03-18 12:54:10 +01:00
Mateusz Mikuła
b25564fc8a name -> ident_str 2019-03-18 12:54:10 +01:00
Mateusz Mikuła
e63a685412 NestedMetaItemKind -> NestedMetaItem 2019-03-18 12:54:10 +01:00
Mateusz Mikuła
cf71caa71d Drop redundant & 2019-03-18 12:54:10 +01:00
Mateusz Mikuła
cb3aa7480c Fix path_qualified
As suggested by eddyb
2019-03-18 12:54:10 +01:00
Mateusz Mikuła
9b7ff501a6 Replace most of ty:Ty with Ty 2019-03-18 12:54:10 +01:00
flip1995
4832a853c7
Feed dog 2019-03-16 15:39:02 +01:00
flip1995
180e07e99e
Adapt paths to new formatting 2019-03-16 15:22:31 +01:00
flip1995
3c4616d303
cargo fmt 2019-03-16 11:51:57 +01:00
flip1995
254fad95de
Use LocalInternedString inside of AbsolutePathPrinter 2019-03-16 11:45:29 +01:00
flip1995
dae5c9c685
AbsolutePathBuffer -> AbsolutePathPrinter 2019-03-16 11:17:36 +01:00
flip1995
2d8618e95c
Remove ty::TyKind from eta_reduction and replace it with ty::Ty 2019-03-16 11:10:33 +01:00
flip1995
8eadbfd35b
parent_def_id -> parent 2019-03-15 23:44:04 +01:00
flip1995
dcbd3aefa2
item_path_str -> def_path_str 2019-03-15 23:43:42 +01:00
flip1995
31435cd7f5
Reimplement AbsolutePathBuffer 2019-03-15 23:42:46 +01:00
bors
e7806413c6 Auto merge of #3883 - daxpedda:missing_docs_in_private_items, r=phansch
Add `doc(include = ...)` detection to `missing_docs_in_private_items`

The whole `missing documentation in crate` part doesn't have any tests. If I should add test cases tell me.
2019-03-15 06:18:28 +00:00
daxpedda
e1096e3310
Add a test for doc(include)
Tiny code improvement.
2019-03-14 19:33:06 +01:00
daxpedda
177b3b27c4
Add doc(include = ...) detection to missing_docs_in_private_items 2019-03-14 18:32:39 +01:00
bors
9df38117d9 Auto merge of #3877 - rink1969:3842, r=flip1995
casting integer literal to float is unnecessary

fix issue https://github.com/rust-lang/rust-clippy/issues/3842
2019-03-14 16:32:15 +00:00
rink1969
d9dd008e44 casting integer literal to float is unnecessary 2019-03-14 15:53:08 +08:00
bors
99fdf2607e Auto merge of #3873 - phansch:hiridification, r=flip1995
Some more HirId-ification

* 8a59f81: Rename span_lint_node* functions to span_lint_hir*
* a457258: Use `HirId` instead of `NodeId` for lookup
2019-03-13 08:45:23 +00:00
Philipp Hansch
bf86c1b989
cargo fmt 2019-03-13 06:51:57 +01:00
bors
8fc0a738e3 Auto merge of #3869 - taiki-e:use_self, r=flip1995
Fix `use_self` false positive on nested functions

Related to https://github.com/rust-lang/rust-clippy/pull/3640

The current `use_self` warns the following code.

```rust
#![warn(clippy::use_self)]
struct Foo {}
impl Foo {
    fn bar() {
        fn baz() -> Foo { //^ warning: unnecessary structure name repetition
            Foo {} //^ warning: unnecessary structure name repetition
         }
    }
}
```
2019-03-12 12:09:56 +00:00
bors
3d31c2157a Auto merge of #3794 - mikerite:fix-3739, r=phansch
Fix `boxed_local` suggestion

Don't warn about an argument that is moved into a closure.

ExprUseVisitor doesn't walk into nested bodies so use a new
visitor that collects the variables that are moved into closures.

Fixes #3739
2019-03-12 07:43:14 +00:00
Philipp Hansch
a457258132
Use HirId instead of NodeId for lookup 2019-03-12 08:21:22 +01:00
bors
75bfa29533 Auto merge of #3871 - taiki-e:needless_continue, r=phansch
Fix `needless_continue` false positive

If the `continue` has a label, check it matches the label of the loop.

Fixes https://github.com/rust-lang/rust-clippy/issues/2329
2019-03-12 07:04:44 +00:00
Philipp Hansch
8a59f81180
Rename span_lint_node* functions to span_lint_hir*
Because they now take a `hir_id` instead of a `node_id` argument.
2019-03-12 08:01:21 +01:00
bors
b586d76b43 Auto merge of #3865 - phansch:run_more_doc_tests, r=flip1995
Run more doc tests

This executes some more doc tests that were ignored before.
2019-03-12 06:22:00 +00:00
Michael Wright
6937d5581a Merge branch 'master' into fix-3739 2019-03-12 08:13:44 +02:00
Philipp Hansch
9ca34e37fa
Run more doc tests
This executes some more doc tests that were ignored before.
2019-03-12 06:53:25 +01:00
Taiki Endo
1bc7da2fec Fix needless_continue false positive 2019-03-12 03:40:30 +09:00
Taiki Endo
187ce4c5ab Fix use_self false positive on nested functions 2019-03-11 23:24:49 +09:00
Taiki Endo
4896b259eb Filter out proc_macro and proc_macro_attribute 2019-03-11 20:45:57 +09:00
flip1995
72aeaa891b
Fix/Ignore doc tests 2019-03-10 23:01:56 +01:00
flip1995
44c46d2059
Run rustfmt 2019-03-10 22:12:26 +01:00
Alexander Regueiro
d2b85323ad Addressed points raised in review. 2019-03-10 18:06:28 +00:00
Alexander Regueiro
d43966a176 Various cosmetic improvements. 2019-03-10 18:06:28 +00:00
Manish Goregaokar
038ec7f5d8 Move get_unwrap to restriction
fixes #3862
2019-03-09 13:48:06 -08:00
bors
ccfbfb8097 Auto merge of #3860 - phansch:refactor_out_opt_def_id, r=flip1995
Refactor: Remove utils::opt_def_id

This removes some indirection. Probably this method was uplifted to
rustc at some point?
2019-03-09 12:05:41 +00:00
Philipp Krones
c32135a87f
Rollup merge of #3857 - phansch:document_path_qpath, r=flip1995
Document match_path, improve match_qpath docs

Inching towards enabling `#[deny(missing_docs)]` in utils 📜
2019-03-09 12:24:44 +01:00
Philipp Krones
f69351e995
Rollup merge of #3852 - phansch:refactor_assign_ops, r=flip1995
Refactor: Cleanup one part of assign_ops lint

Removes a lot of indentation and separates lint emission from lint
logic. Only touches the `hir::ExprKind::AssignOp` part of the lint.
2019-03-09 12:24:43 +01:00
Philipp Krones
1902384d15
Rollup merge of #3851 - phansch:refactor_trait_stuff, r=flip1995
Refactor: Extract `trait_ref_of_method` function

This pattern was used in three places after #3844, so I think it's worth moving it into `utils/mod.rs` and documenting it.
2019-03-09 12:24:42 +01:00
Philipp Hansch
9d97ed6faa
Refactor: Remove utils::opt_def_id
This removes some indirection. Probably this method was uplifted to
rustc at some point?
2019-03-08 14:14:41 +01:00
Philipp Hansch
f04acdd463
Document match_path, improve match_qpath docs 2019-03-08 09:50:20 +01:00
Philipp Hansch
9494f22f06
cargo fmt 2019-03-08 09:44:22 +01:00
Philipp Hansch
131b89b54e
fmt 2019-03-08 09:43:36 +01:00
Philipp Krones
837d675afd
Update clippy_lints/src/utils/mod.rs
Co-Authored-By: phansch <dev@phansch.net>
2019-03-08 09:40:12 +01:00
Philipp Hansch
65694cc6c8
Fix doctest 2019-03-08 09:10:41 +01:00
Philipp Hansch
5c9221f880
Refactor: Cleanup one part of assign_ops lint
Removes a lot of indentation and separates lint emission from lint
logic. Only touches the `hir::ExprKind::AssignOp` part of the lint.
2019-03-08 09:01:29 +01:00
ljedrz
5d78250c75 align with rust-lang/rust/#58992 2019-03-07 21:51:05 +01:00
rchaser53
ae787d954e fix missing a semicolon 2019-03-07 23:26:47 +09:00
Philipp Hansch
e1d47cd5f1
Refactor: Extract trait_ref_of_method function 2019-03-07 08:17:43 +01:00
Félix Fischer
ddc718087f Renamed: Cyclomatic Complexity -> Cognitive Complexity
* Ran automatic naming update

* Formalized rename of `cyclomatic_complexity` to `cognitive_complexity`
** Added the rename to `lib.rs`
** Added rename test

* Added warning for deprecated key `cyclomatic_complexity_threshold` and tests for it

* Added deprecation status for Clippy's builtin attribute

* Updated tests for new builtin attribute renaming
2019-03-06 10:07:38 -03:00
Andy Russell
a9de64a151
fix or ignore failing doc tests 2019-03-05 18:45:08 -05:00
Andy Russell
fe96ffeac9
move lint documentation into macro invocations 2019-03-05 18:45:08 -05:00
Philipp Hansch
15cba2e956
Fix missing_const_for_fn for impl trait methods 2019-03-05 08:11:55 +01:00
Philipp Hansch
b87f5bc55a
Don't trigger missing_const_for_fn in external macros
As reported in #3841. Only fixes the part where it triggers on the
`derive`.
2019-03-04 22:56:33 +01:00
Philipp Hansch
68096cf181
fmt fixes 2019-03-03 13:05:39 +01:00
ljedrz
f3363b9cf2 align with rust-lang/rust/#58836 2019-03-01 19:10:14 +01:00
ljedrz
f2587703cc enable rust-lang/rust#58754 2019-03-01 19:10:14 +01:00
Santiago Pastorino
77a67c914d
Place::Local(x) is now Place::Base(PlaceBase::Local(x)) 2019-03-01 12:20:17 -03:00
flip1995
1463d6f69f
Error an unknown or deprecated Clippy attribute 2019-02-28 16:44:42 +01:00
bors
ff2798840c Auto merge of #3666 - detrumi:map-or-on-non-copy, r=flip1995
Only suggest map_or for copy types

Fixes #2686
2019-02-27 08:28:48 +00:00
Philipp Hansch
982a99d2c4
Rustup https://github.com/rust-lang/rust/pull/58321 2019-02-27 07:20:49 +01:00
bors
6e8931c5f5 Auto merge of #3821 - g-bartoszek:redundant_closure-different-borrow-levels, r=oli-obk
do not trigger redundant_closure when there is a difference in borrow…

… level between closure parameter and "self", fixes  #3802
2019-02-26 17:30:48 +00:00
Wilco Kusee
eb70a72459
Fix false negative 2019-02-26 17:29:36 +01:00
Wilco Kusee
fec6e55d1d
Attempt to fix false negative 2019-02-26 17:27:41 +01:00
Wilco Kusee
4cf720abbe
Move lint_map_unwrap_or to its own file 2019-02-26 17:27:41 +01:00
Wilco Kusee
54ab22f6db
Only suggest map_or for copy types 2019-02-26 17:27:40 +01:00
bors
0957f7d3b7 Auto merge of #3817 - rust-lang:fix-bool_comparison-on-non-bool, r=oli-obk
Fix `bool_comparison` with non-`bool` expressions

Fixes #3703.
It just moves around the type check that was already there for some comparison to all of them, because if one type isn't `bool`, none of those comparison can be simplified.
2019-02-26 15:51:40 +00:00
Grzegorz
a7f4d41a7d do not trigger redundant_closure when there is a difference in borrow level between closure parameter and "self" 2019-02-26 12:12:27 +01:00
bors
412d41ae86 Auto merge of #3814 - ljedrz:HirIdification_lockstep_upgrade, r=phansch
HirIdify some lints

Unblocks https://github.com/rust-lang/rust/pull/58561 (a part of [rust-lang/rust#57578](https://github.com/rust-lang/rust/pull/57578)). Can we branch it like with https://github.com/rust-lang/rust-clippy/pull/3790? I can rebase on a different commit if need be.

Haven't had time to run tests yet, so I'd wait for Travis 🙈.
2019-02-26 10:43:50 +00:00
ljedrz
c1b65ec363 fix line format 2019-02-26 11:21:07 +01:00
Michael Wright
c9d79c0c5e Remove #[feature(try_from)]
`try_from` is now stable.
2019-02-26 08:43:47 +02:00
mcarton
c0c0686a65 Fix bool_comparison with non-bool expressions 2019-02-25 22:31:16 +01:00
bors
50d9473856 Auto merge of #3808 - mikerite:useless-format-suggestions, r=oli-obk
Fix `useless_format` suggestions
2019-02-25 16:21:26 +00:00
bors
2141ebf695 Auto merge of #3816 - g-bartoszek:redundant_closure_for_macros, r=Manishearth
do not trigger redundant_closure for external macros

fixes #3791
2019-02-25 13:46:31 +00:00
Grzegorz
41f197460f redundant_closure does not trigger for external macros 2019-02-25 13:40:28 +01:00
bors
1ac6f4e9ae Auto merge of #3772 - flip1995:ice-3719, r=Manishearth
Fix ICE #3719+#3718 in lint match_ref_pats

Fixes #3719
This conveniently also fixes #3718

The ICE occurs when the match expression was a macro call, where the macro was defined in another file. Since we don't have the ability to reproduce this behavior with our UI tests (AFAIK), I couldn't add a test reproducing this ICE.. However, I added a test which is related to the ICE, to show the new behavior of the lint.

I tested it with the mscheme repo locally and the ICE didn't happen anymore.

r? @matthiaskrgr
2019-02-25 12:30:35 +00:00
bors
cd29740e6e Auto merge of #3805 - martinsp:ice-3747, r=Manishearth
Fix ICE #3747

I'm not sure if this was the correct approach.

I don't know if I put tests/ui/crashses/ice-3747.rs in correct place because the test always passed when I ran it with `cargo test`, even without the fix applied.

If I run that test with `env CLIPPY_TESTS=true cargo run --bin clippy-driver -- -L ./target/debug tests/ui/crashes/ice-3747.rs` then the test correctly fails without the fix applied

fixes #3747
2019-02-25 12:08:43 +00:00
ljedrz
7bc2e1d60d fix: replace wrong id 2019-02-25 11:06:46 +01:00
Philipp Hansch
bd949328f1
Make DiagnosticWrapper private
It's doesn't have to be public anywhere outside of clippy_lints
2019-02-25 07:19:56 +01:00
ljedrz
8dac8a6ba4 HirIdify some lints 2019-02-24 20:49:43 +01:00
bors
5833e4d26e Auto merge of #3810 - phansch:refactor/extract_module, r=flip1995
Extract diagnostics module and document some functions

This moves the lint building functions from `utils/mod.rs` to their own
`utils/diagnostics.rs` file. Also adds documentation for three of them.
2019-02-24 15:35:01 +00:00
bors
1ce961f083 Auto merge of #3790 - ljedrz:HirIdify_intravisit, r=phansch
partially HirIdify lints

Enables https://github.com/rust-lang/rust/pull/58232 (a part of https://github.com/rust-lang/rust/pull/57578).
2019-02-24 14:32:55 +00:00
ljedrz
601cbc6d84 fix formatting 2019-02-24 15:16:16 +01:00
Philipp Hansch
7d883cddbc
Extract diagnostics module and document some functions
This moves the lint building functions from `utils/mod.rs` to their own
`utils/diagnostics.rs` file. Also adds documentation for three of them.
2019-02-24 14:11:05 +01:00
Philipp Hansch
ff1b1a7c9f
Document some span_lint_* util functions 2019-02-24 09:49:17 +01:00
Michael Wright
0182a6640e Fix useless_format suggestions 2019-02-24 07:30:08 +02:00
Martins Polakovs
391ee7987d Fix ICE #3747
[Martins Polakovs, John Firebaugh]
2019-02-23 21:38:16 +02:00
Michael Wright
5332cdb7dc Remove unneeded visitor class
Use ExprUseVisitor correctly instead.
2019-02-22 07:06:51 +02:00
bors
a5c16e5892 Auto merge of #3789 - bzzzzzz:needless_range_loop_bugfix, r=oli-obk
Make needless_range_loop not applicable to structures without iter method

Fixes https://github.com/rust-lang/rust-clippy/issues/3788

Now we will start lint indexed structure only if it has known iter or iter_mut method implemented.
2019-02-21 09:36:13 +00:00
Michael Wright
9d6ecc7485 Fix boxed_local suggestion
Don't warn about an argument that is moved into a closure.

ExprUseVisitor doesn't walk into nested bodies so use a new
visitor that collects the variables that are moved into closures.

Fixes #3739
2019-02-21 06:59:10 +02:00
bzzzz
7767b3a081 Fixed formatting and typo 2019-02-20 10:12:24 -08:00
bors
027dde92e2 Auto merge of #3781 - uniphil:write_with_newline_false_positive, r=oli-obk
Don't check [print/write]_with_newline on raw strings

Some tests for #3778 and some maybe-not-the-greatest code that passes those tests!

I didn't run `fmt` because a) it doesn't seem to install on nightly for me, and b) on stable it wanted to apply formatting to over 90 files. Happy to make any tweaks though!

I suspect this contribution may require more than just tweaks. I'm still sort of new to rust so it may not be idiomatic, and the specific approach I took feels a little heavy-handed and brittle. I'm happy to make changes with some guidance, or equally happy if this gives a starting place for someone else to do it better :)
2019-02-20 16:37:32 +00:00
ljedrz
1fac380886 partially HirIdify lints 2019-02-20 13:16:16 +01:00
bors
d5d8d7bca5 Auto merge of #3779 - mikerite:fix-3704, r=phansch
Improve `iter_cloned_collect` suggestions

Fixes #3704
2019-02-20 09:21:18 +00:00
bzzzz
f9c6682827 Make needless_range_loop not applicable to structures without iter method 2019-02-20 00:10:25 -08:00
flip1995
75f39881d4
Document the new Sugg functions 2019-02-19 21:34:14 +01:00
flip1995
87ae6c8bc9
Fix ice-3719 2019-02-19 21:34:14 +01:00
flip1995
1a86d80c10
Implement Sugg::hir_with_macro_callsite 2019-02-19 21:34:14 +01:00
bors
075c212849 Auto merge of #3776 - notriddle:drop-bounds, r=oli-obk
Add a lint to warn on `T: Drop` bounds

**What it does:** Checks for generics with `std::ops::Drop` as bounds.

**Why is this bad?** `Drop` bounds do not really accomplish anything.
A type may have compiler-generated drop glue without implementing the
`Drop` trait itself. The `Drop` trait also only has one method,
`Drop::drop`, and that function is by fiat not callable in user code.
So there is really no use case for using `Drop` in trait bounds.

**Known problems:** None.

**Example:**
```rust
fn foo<T: Drop>() {}
```

Fixes #3773
2019-02-19 09:46:29 +00:00
Manish Goregaokar
68476e1d13 Rustup to rustc 1.34.0-nightly (32471f7ea 2019-02-19) 2019-02-19 13:04:43 +05:30
Michael Howell
bc4c3b6ff1 Add more descriptive details 2019-02-18 19:37:08 -07:00
phil
ef72b2cac0 Check {print,write}_with_newline for literal newline
Both regular strings and raw strings can contain literal newlines. This commit
extends the lint to also warn about terminating strings with these.

Behaviour handling for raw strings is also moved into `check_newlines` by
passing in the `is_raw` boolean from `check_tts` as
[suggested](https://github.com/rust-lang/rust-clippy/pull/3781#pullrequestreview-204663732)
2019-02-18 19:22:20 -05:00
Daniel Wagner-Hall
4009a44118 Fix Binding for rustc update 2019-02-18 23:16:53 +00:00
Daniel Wagner-Hall
bcefd688c9 Restore tests
Also, fix existing test
2019-02-18 22:56:43 +00:00
Daniel Wagner-Hall
422c9a0fa2 wildcard_enum_match_arm gives suggestions
And is also more robust
2019-02-18 22:56:43 +00:00
phil
3fa3bd8e94 Don't fail for raw string ending in \n
Pass tests for #3778, {print,write}_with_newline false positive

This change guards the lint from checking newlines with a sort of complicated
check to see if it's a raw string. Raw strings shouldn't be newline-checked,
since r"\n" is literally \-n, not a newline. I think it's ok not to check for
_literal_ newlines at the end of raw strings, but maybe that's debatable.

I... don't think this code is that great. I wanted to write the check after
`check_tts`, but that was too late -- raw string type info is lost (or I
couldn't find it). Putting it inside `check_tts` feels heavy-duty and the check
itself feels like a brittle reach possibly into places it shouldn't.

Maybe someone can fix this up :)
2019-02-18 11:39:40 -05:00
Eduardo Pinho
8994466bfe
Format transmute_from_int_to_float docs 2019-02-18 15:09:34 +00:00
Eduardo Pinho
74ac35bcab
Update why transmute_int_to_float is bad
Fix #3550
2019-02-18 14:14:54 +00:00
Michael Wright
9185c8d996 Format 2019-02-18 08:32:53 +02:00
Michael Howell
2df14c3701 Add a lint to warn on T: Drop bounds
**What it does:** Checks for generics with `std::ops::Drop` as bounds.

**Why is this bad?** `Drop` bounds do not really accomplish anything.
A type may have compiler-generated drop glue without implementing the
`Drop` trait itself. The `Drop` trait also only has one method,
`Drop::drop`, and that function is by fiat not callable in user code.
So there is really no use case for using `Drop` in trait bounds.

**Known problems:** None.

**Example:**
```rust
fn foo<T: Drop>() {}
```
2019-02-17 22:53:08 -07:00
Michael Wright
6e7a813ed2 Improve iter_cloned_collect suggestions
Fixes #3704
2019-02-18 07:30:50 +02:00
Timo
99eccaa120
Add a semicolon as suggested 2019-02-17 22:14:38 -05:00
Timo
508b41ecef
Fix typo in documentation for float_cmp_const lint 2019-02-17 21:06:29 -05:00
flip1995
f204b7ec76
Fix ICE #3717
Restore the old `TypeckTables` in visit_body after walking the body
2019-02-17 01:50:13 +01:00
flip1995
10811d5d89
Fix breakage from rust-lang/rust#58296 2019-02-14 14:01:43 +01:00
Michael Wright
533dd360d7 Fix breakage due to rust-lang/rust#58167 2019-02-14 08:55:50 +02:00
flip1995
5a3cd31c9e
Rustup
cc rust-lang/rust#58137
2019-02-13 22:08:17 +01:00
bors
db13e6fa34 Auto merge of #3756 - g-bartoszek:redundant-closure-for-methods, r=oli-obk
Redundant closure for methods

fixes  #3469
2019-02-12 13:31:44 +00:00
bors
ed3287605d Auto merge of #3757 - mikerite:fix-2542, r=oli-obk
Fix `needless_range_loop` bad suggestion

Detect if the index variable is used inside a closure.

Fixes #2542
2019-02-12 10:27:18 +00:00
bors
2066368583 Auto merge of #3758 - phansch:document_macro, r=flip1995
Document `declare_clippy_lint` macro

Split up from my work on updating CONTRIBUTING.md, which is slowly
making progress.

cc #2666
2019-02-11 23:52:52 +00:00
Philipp Hansch
a14247b500
Update comment regarding crate level cfg_attr 2019-02-11 22:32:54 +01:00
Philipp Hansch
7d3983216f
Document some more core functions 2019-02-11 08:34:37 +01:00
Philipp Hansch
a27022e0dc
Document declare_clippy_lint macro
Split up from my work on updating CONTRIBUTING.md, which is slowly
making progress.

cc #2666
2019-02-11 08:34:37 +01:00
Michael Wright
217965e855 Fix needless_range_loop bad suggestion
Detect if the index variable is used inside a closure.

Fixes #2542
2019-02-11 07:03:12 +02:00
bors
2755d12fa6 Auto merge of #3744 - phansch:fix3144, r=oli-obk
Fix ICE in needless_pass_by_value lint

If I understand it correctly, we were first creating a type with a
`RegionKind::ReErased` region and then deleted it again in
`util::implements_trait` with:

    cx.tcx.erase_regions(&ty);

causing the type query to fail.

It looks like using `ReEmpty` works around that deletion.

Fixes #3144
2019-02-10 13:39:46 +00:00
bors
af43950143 Auto merge of #3740 - flip1995:const_assert_macro, r=oli-obk
Macro check for assertion_on_constants lint

The `assertion_on_constants` lint currently has following output for this code [Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6f2c9df6fc50baf847212d3b5136ee97):
```rust
macro_rules! assert_const {
    ($len:expr) => {
        assert!($len > 0);
    }
}

fn main() {
    assert_const!(3);
    assert_const!(-1);
}
```
```
warning: assert!(const: true) will be optimized out by the compiler
 --> src/main.rs:3:9
  |
3 |         assert!($len > 0);
  |         ^^^^^^^^^^^^^^^^^^
...
8 |     assert_const!(3);
  |     ---------------- in this macro invocation
  |
  = note: #[warn(clippy::assertions_on_constants)] on by default
  = help: remove it
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants

warning: assert!(const: false) should probably be replaced
 --> src/main.rs:3:9
  |
3 |         assert!($len > 0);
  |         ^^^^^^^^^^^^^^^^^^
...
9 |     assert_const!(-1);
  |     ----------------- in this macro invocation
  |
  = help: use panic!() or unreachable!()
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants
```

This is contradictory. This lint should not trigger if the `assert!` is in a macro itself.
2019-02-10 12:47:16 +00:00
Grzegorz
16881390e1 removing redundant closures in the whole project 2019-02-10 13:35:44 +01:00
Grzegorz
b38c587b98 redundant closure implemented for closures containing method calls 2019-02-10 12:58:51 +01:00
bors
5725726345 Auto merge of #3751 - h-michael:opt-def-id, r=phansch
Use Hir::Def opt_def_id

related with: https://github.com/rust-lang/rust-clippy/pull/3750#issuecomment-462010225

Using `def.opt_def_id` in `opt_def_id` before replacing all all at once.
2019-02-09 12:01:45 +00:00
Hirokazu Hata
71dfbe2072 Use Hir::Def opt_def_id 2019-02-09 13:28:21 +09:00
bors
77435f9938 Auto merge of #3748 - phansch:uitest, r=oli-obk
Add a uitest subcommand to simplify UI test invocation

This makes running single tests a lot easier.

It's now

`TESTNAME=xxx cargo uitest`

instead of

`TESTNAME=xxx cargo test --test compile-test`
2019-02-09 04:09:25 +00:00
Hirokazu Hata
66f8fa320b Add new Def type ConstParam 2019-02-09 11:42:13 +09:00
Philipp Hansch
f934f98111
Add a uitest subcommand to simplify UI test invocation
This allows to run

`TESTNAME=xxx cargo uitest`

instead of

`TESTNAME=xxx cargo test --test-compile-test`
2019-02-08 08:09:37 +01:00
bors
e176324fc5 Auto merge of #3665 - jsgf:master, r=oli-obk
Start making clippy easier to invoke in non-cargo contexts

Clippy (clippy-driver) currently has a couple of strong but unnecessary couplings with cargo. This series:
1. makes detection of check builds more robust, and
2. make clippy-driver use the --sysroot specified on the command line as its internal sysroot.
2019-02-06 15:43:07 +00:00
Philipp Hansch
f3cd81980d
Fix ICE in needless_pass_by_value lint
If I understand it correctly, we were first creating a type with a
`RegionKind::ReErased` region and then deleted it again in
`util::implements_trait` with:

    cx.tcx.erase_regions(&ty);

causing the type query to fail.

It looks like using `ReEmpty` works around that deletion.
2019-02-06 09:18:35 +01:00
flip1995
446e2ecfb7
Don't warn about const assertions when assert is in a macro itself 2019-02-05 19:37:50 +01:00
bors
4259377ea6 Auto merge of #3725 - mikerite:fix-2728, r=phansch
Fix `cast_sign_loss` false positive

This checks if the value is a non-negative constant before linting about
losing the sign.

Because the `constant` function doesn't handle const functions, we check if
the value is from a call to a `max_value` function directly. A utility method
called `get_def_path` was added to make checking for the function paths
easier.

Fixes #2728
2019-02-04 05:52:44 +00:00
Michael Wright
f3ee53d225 Document get_def_path 2019-02-04 07:30:24 +02:00
rhysd
83d620b824 run util/dev update_lints and cargo fmt --all 2019-02-03 21:56:24 +09:00
rhysd
4b736ff29b Merge branch 'master' into issue3721 2019-02-03 21:27:23 +09:00
rhysd
60f723fba4 prefer if to match 2019-02-03 18:50:00 +09:00
rhysd
3100fecb99 use snippet for making a suggestion if possible 2019-02-03 18:28:42 +09:00
Michael Wright
c02367c4e9 Fix breakage due to rust-lang/rust#58079
The rustc change added HirId to a few nodes. As I understand it, the plan is
to remove the NodeId from these nodes eventually. Where the NodeId was
not being matched, I used `..` to try and avoid further breakage. Where it
was, I used `_` to make the fix easier when NodeId is removed.
2019-02-03 09:12:07 +02:00
Jeremy Fitzhardinge
86c513e605 Let CLIPPY_CONF_DIR be used to start search for config, and fall back to
CARGO_MANIFEST_DIR if it isn't set. If CARGO_MANIFEST_DIR isn't set, fall back
"." rather than panicing.

Issue #3663
2019-02-02 11:43:21 -08:00
bors
27b5dd8886 Auto merge of #2857 - avborhanian:master, r=phansch
Adding lint test for excessive LOC.

This is a WIP for #2377. Just wanted to pull in because I had a few questions:

1. Is it okay that I'm approaching this via counting by looking at each line in the snippet instead of looking at the AST tree? If there's another way to do it, I want to make sure I'm doing the correct way, but I wasn't sure since the output AST JSON doesn't seem to contain whitespace.

2. My function is definitely going to trigger the lint, so also wanted to see if there was something obvious I could do to reduce it.

3. Are the two tests fine, or is there something obvious I'm missing?

4. Obviously bigger question - am I approaching the line count correctly. Current strategy is count a line if it contains some code, so skip if it's just comments or empty.
2019-02-02 08:32:27 +00:00
rhysd
54d49af3ff add more test cases for dbg_macro rule 2019-02-02 04:54:51 +09:00
Philipp Hansch
ac9472d16e
Update clippy_lints/src/types.rs
Co-Authored-By: avborhanian <avborhanian@gmail.com>
2019-02-01 14:53:15 -05:00
Philipp Hansch
a022d47a6b
Update clippy_lints/src/types.rs
Co-Authored-By: avborhanian <avborhanian@gmail.com>
2019-02-01 14:52:56 -05:00
rhysd
268ff85326 use span_help_and_lint() instead of span_lint_and_sugg() 2019-02-02 04:52:21 +09:00
Unknown
93a856e9d5 Changing single character string to a character match. 2019-02-01 13:21:19 -05:00
Unknown
6931b0f5a1 rustfmt 2019-02-01 13:21:19 -05:00
Araam Borhanian
5e10809ac3 Adding lint for too many lines. 2019-02-01 13:21:19 -05:00
Unknown
44c835feea Skipping check if in external macro. 2019-02-01 13:21:19 -05:00
Unknown
c1f4e18453 Adding back tests, but also reducing threshold by 1 2019-02-01 13:21:19 -05:00
Unknown
e583f35b3a rustfmt 2019-02-01 13:21:19 -05:00
Unknown
7fbd55c329 Reworking function logic, and adding doc example.
This should fix line count logic issues that the previous code had, with assumptions it would make.
2019-02-01 13:21:19 -05:00
Araam Borhanian
1169066a0b Adding lint for too many lines. 2019-02-01 13:21:19 -05:00
Philipp Hansch
38347bad38
Make vec_box MachineApplicable 2019-02-01 18:18:45 +01:00
Philipp Hansch
4aff8711f0
Fix ICE in vec_box lint and add run-rustfix
`hir::Ty` doesn't seem to know anything about type bounds and
`cx.tcx.type_of(def_id)` caused an ICE when it was passed a generic type
with a bound:

```
src/librustc_typeck/collect.rs:1311: unexpected non-type Node::GenericParam: Type { default: None, synthetic: None }
```

Converting it to a proper `Ty` fixes the ICE and catches a few more
places where the lint applies.
2019-02-01 18:18:45 +01:00
bors
5176a5c4b7 Auto merge of #3726 - phansch:some_renaming, r=oli-obk
Some renamings: s/ast_ty/hir_ty and s/StructField/hir::StructField

I think in both cases the new names make the code more understandable.
For `StructField` specifically because there's one in
[`syntax::ast`][ast] and one in [`rustc::hir`][hir].

[ast]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast/struct.StructField.html
[hir]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/struct.StructField.html
2019-02-01 08:36:11 +00:00
Michael Wright
b6c3a6a09f Move max_value handling to consts module 2019-02-01 06:32:16 +02:00
rhysd
b52a9bd966 cargo +nightly fmt at clippy_lints/ 2019-02-01 12:03:13 +09:00
rhysd
06e4e9cf27 remove TODO comment which was already done 2019-02-01 11:40:02 +09:00
rhysd
9d130a546f add dbg_macro rule to CHANGELOG.md and update count in README 2019-02-01 11:32:22 +09:00
rhysd
7ec5528e0c fix category and use suggestion 2019-02-01 09:31:26 +09:00
Philipp Hansch
ee7bad455b
Some renamings: s/ast_ty/hir_ty and s/StructField/hir::StructField
I think in both cases the new names make the code more understandable.
For `StructField` specifically because there's one in
[`syntax::ast`][ast] and one in [`rustc::hir`][hir].

[ast]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast/struct.StructField.html
[hir]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/struct.StructField.html
2019-01-31 07:25:47 +01:00
Michael Wright
3cf8c0b3b5 Fix cast_sign_loss false positive
This checks if the value is a non-negative constant before linting about
losing the sign.

Because the `constant` function doesn't handle const functions, we check if
the value is from a call to a `max_value` function directly. A utility method
called `get_def_path` was added to make checking for the function paths
easier.

Fixes #2728
2019-01-31 06:32:29 +02:00
rhysd
f894adce8c implement dbg_macro rule (fixes #3721) 2019-01-31 02:39:38 +09:00
Alex Hamilton
587492b5d2 wildcard_match_arm: add nesting issue to known. 2019-01-29 15:33:04 -06:00
Alex Hamilton
efaed8e0c0 wildcard_match_arm: lint only enum matches. 2019-01-29 15:33:04 -06:00
Alex Hamilton
6bc4416b2b wilcard_match_arm: run rustfmt. 2019-01-29 15:33:04 -06:00
Alex Hamilton
c75dfeb29b wildcard_match_arm: add lint properly. 2019-01-29 15:33:04 -06:00
Alex Hamilton
23eae0909d wildcard_match_arm: rename function.
We also don't need `ex` as an argument.
2019-01-29 15:33:04 -06:00
Alex Hamilton
20ba476ea8 wildcard_match_arm: expand lint scope.
We're not only working with Results.
2019-01-29 15:33:04 -06:00
Alex Hamilton
1b3c3d073a Change match_wild lint name to WILDCARD_MATCH_ARM.
Also fix message capitalization.
2019-01-29 15:33:04 -06:00
Alex Hamilton
0da18677f7 Add match_wild lint (#3649).
This lint prevents using a wildcard in a match.
2019-01-29 15:33:04 -06:00
bors
6b1a2a9c3e Auto merge of #3648 - phansch:const_fn_lint, r=oli-obk
Add initial version of const_fn lint

This adds an initial version of a lint that can tell if a function could be `const`.

TODO:

- [x] Finish up the docs
- [x] Fix the ICE

cc #2440
2019-01-29 19:58:13 +00:00
Philipp Hansch
d0d7c5e922
cargo fmt 2019-01-29 19:56:19 +01:00
Philipp Hansch
aed001b8d4
Update various docs
* `const_transmute` currently also seems to depend on the `const_fn`
  feature.
* Only `Sized` is currently allowed as a bound, not Copy.
2019-01-29 08:19:05 +01:00
Philipp Hansch
0c6bdda562
Use built-in entry_fn detection over self-built 2019-01-29 08:19:05 +01:00
Philipp Hansch
c0a02691d8
cargo fmt 2019-01-29 08:19:05 +01:00
Philipp Hansch
f9d65b6356
Reorganize conditionals: Run faster checks first 2019-01-29 08:19:05 +01:00
Philipp Hansch
68cc4df551
Maybe fix ICE? 2019-01-29 08:19:05 +01:00
Philipp Hansch
c3980bf0bc
Add initial version of const_fn lint 2019-01-29 08:19:05 +01:00
Michael Wright
df04238d3a Fix unit_arg false positive
Ignore arguments with the question mark operator.

Closes #2945
2019-01-29 07:22:08 +02:00
bors
410d5ba6c3 Auto merge of #3700 - phansch:would_you_like_some_help_with_this_const_fn, r=oli-obk
Prevent incorrect cast_lossless suggestion in const_fn

`::from` is not a const fn, so applying the suggestion of
`cast_lossless` would fail to compile. The fix is to skip the lint if
the cast is found inside a const fn.

Fixes #3656
2019-01-28 14:30:18 +00:00
Oliver Scherer
60332941c9 Rustfmt 2019-01-28 11:32:41 +01:00
Oliver Scherer
c67a05166f Check hypothetically failing conversion 2019-01-28 10:32:34 +01:00
Oliver Scherer
7b90cb529a Update more changed iterator paths 2019-01-28 10:16:34 +01:00
Oliver Scherer
dc8c7b1677 Atomics constants are now handled by the deprecation lint 2019-01-28 10:10:27 +01:00
Oliver Scherer
36245feeb0 Update changed iterator paths 2019-01-28 10:09:45 +01:00
Oliver Scherer
b08964b3bd Update const slice processing 2019-01-28 10:09:34 +01:00
bors
62f40e28b9 Auto merge of #3706 - robamler:patch-1, r=phansch
Fix documentation for `slow_vector_initialization`

This PR fixes the documentation for the lint `slow_vector_initialization`. The documentation recommended writing `vec![len; 0]` but the correct solution is `vec![0; len]`.
2019-01-27 13:34:47 +00:00
Matthias Krüger
79b1d9adf0 run cargo fmt 2019-01-27 13:34:23 +01:00
Matthias Krüger
3a96d6b603 rustup https://github.com/rust-lang/rust/pull/57907/
for file in `fd \.rs$` ; do sed  -i  s/span_suggestion_with_applicability/span_suggestion/g $file ; done

for file in `fd \.rs$` ; do sed  -i  s/span_suggestion_short_with_applicability/span_suggestion_short/g $file ; done

for file in `fd \.rs$` ; do sed  -i  s/span_suggestions_with_applicability/span_suggestions/g $file ; done
2019-01-27 13:33:56 +01:00
Robert Bamler
14e27f567a
Fix documentation for slow_vector_initialization
Change the recommended solution from `vec![len; 0]` to `vec![0; len]`.

Also fix grammar.
2019-01-26 20:26:38 -08:00
Matthias Krüger
e9e0a7e3bd rustup https://github.com/rust-lang/rust/pull/57726 2019-01-27 01:42:34 +01:00
bors
33a0fe7b2c Auto merge of #3690 - mikerite:fix-3630-expect-fun-call, r=phansch
Fix `expect_fun_call` lint suggestions

This commit corrects some bad suggestions produced by the
`expect_fun_call` lint and enables `rust-fix` checking on the tests.

Addresses #3630
2019-01-26 10:57:39 +00:00
Philipp Hansch
8c416c3197
Prevent incorrect cast_lossless suggestion in const_fn
`::from` is not a const fn, so applying the suggestion of
`cast_lossless` would fail to compile. The fix is to skip the lint if
the cast is found inside a const fn.
2019-01-26 10:57:15 +01:00
Michael Wright
18cacbabb4 Incorporate review suggestions 2019-01-26 11:55:54 +02:00
Sorin Davidoi
1fe0cf6f07 chore(cargo/dependencies/cargo-metadata): Upgrade to 0.7.1
Closes https://github.com/rust-lang/rust-clippy/issues/3692.
2019-01-25 21:53:44 +01:00
Matthias Krüger
873fe11ca5 dependencies: update itertools from 0.7 to 0.8 2019-01-25 20:25:14 +01:00
Philipp Hansch
0bac0149e7
Rustup
Due to https://github.com/rust-lang/rust/pull/51285
2019-01-24 20:32:18 +01:00
Michael Wright
5284b95a06 Fix expect_fun_call lint suggestions
This commit corrects some bad suggestions produced by the
`expect_fun_call` lint and enables `rust-fix` checking on the tests.

Addresses #3630
2019-01-24 06:58:53 +02:00
A.A.Abroskin
c771f339d7 allow assertions_on_constants for collapsible_if and missing_test_files 2019-01-23 17:58:33 +03:00
A.A.Abroskin
f11d993c0f Merge branch 'master' into add-lints-aseert-checks
* master: (58 commits)
  Rustfmt all the things
  Don't make decisions on values that don't represent the decision
  Improving comments.
  Rustup
  Added rustfix to the test.
  Improve span shortening.
  Added "make_return" and "blockify" convenience methods in Sugg and used them in "needless_bool".
  Actually check for constants.
  Fixed potential mistakes with nesting. Added tests.
  formatting fix
  Update clippy_lints/src/needless_bool.rs
  formatting fix
  Fixing typo in CONTRIBUTING.md
  Fix breakage due to rust-lang/rust#57651
  needless bool lint suggestion is wrapped in brackets if it is an "else" clause of an "if-else" statement
  Fix automatic suggestion on `use_self`.
  Remove negative integer literal checks.
  Fix `implicit_return` false positives.
  Run rustfmt
  Fixed breakage due to rust-lang/rust#57489
  ...
2019-01-23 11:36:12 +03:00
bors
a069320fd7 Auto merge of #3684 - g-bartoszek:sugg-snippet-modifications, r=phansch
"make_return" and "blockify" convenience methods, fixes #3683

…ed them in "needless_bool".
2019-01-22 20:18:11 +00:00
bors
a40d8e4479 Auto merge of #3679 - daxpedda:use_self, r=phansch
Fix automatic suggestion on `use_self`.

In an example like this:
```rust
impl Example {
    fn fun_1() { }
    fn fun_2() {
        Example::fun_1();
    }
}
```
Clippy tries to replace `Example::fun_1` with `Self`, loosing `::fun_1` in the process, it should rather try to replace `Example` with `Self`.

**Question**
- There may be other paths that need the same treatment, but I'm not sure I understand them fully:
  - e648adf086/clippy_lints/src/use_self.rs (L94-L96)
  - e648adf086/clippy_lints/src/use_self.rs (L225-L229)
2019-01-22 19:18:39 +00:00
Oliver Scherer
d6c806378e Rustfmt all the things 2019-01-22 16:27:42 +01:00
Oliver Scherer
38cdf63acf Don't make decisions on values that don't represent the decision 2019-01-22 15:28:51 +01:00
daxpedda
42d5a07f0c
Improving comments. 2019-01-22 15:23:45 +01:00
Oliver Scherer
3168023cc8 Rustup 2019-01-22 15:17:05 +01:00
Philipp Krones
e70f9456fc
Improve span shortening.
Co-Authored-By: daxpedda <1645124+daxpedda@users.noreply.github.com>
2019-01-22 14:43:59 +01:00
Grzegorz Bartoszek
0f5c43a722 Added "make_return" and "blockify" convenience methods in Sugg and used them in "needless_bool". 2019-01-22 14:07:53 +01:00
bors
9d5b148648 Auto merge of #3677 - daxpedda:integer_arithmetic, r=oli-obk
Remove negative integer literal checks.

Fixes #3678.
2019-01-21 15:07:22 +00:00
daxpedda
87d24e1fc9
Actually check for constants. 2019-01-21 13:59:49 +01:00
bors
e0bcec717a Auto merge of #3676 - daxpedda:implicit_return, r=oli-obk
Fix `implicit_return` false positives.

Fixes the following false positives:
- linting on `if let` without `else` in a `loop` even with a present `return`
- linting on `unreachable!()`
2019-01-21 12:25:45 +00:00
daxpedda
2e0977f3b4
Fixed potential mistakes with nesting. Added tests. 2019-01-21 13:06:32 +01:00
bors
54978a571c Auto merge of #3680 - g-bartoszek:needless-bool-else-if-brackets, r=oli-obk
needless bool lint suggestion is wrapped in brackets if it is an "els…

…e" clause of an "if-else" statement
2019-01-21 11:47:06 +00:00
Grzegorz Bartoszek
34785a12f4 formatting fix 2019-01-21 12:04:25 +01:00
Oliver Scherer
4532073a29
Update clippy_lints/src/needless_bool.rs
Co-Authored-By: g-bartoszek <grzegorz.bartoszek@thaumatec.com>
2019-01-21 11:41:33 +01:00
Grzegorz Bartoszek
0a0792e535 formatting fix 2019-01-21 11:14:34 +01:00
Michael Wright
a747dbb04f Fix breakage due to rust-lang/rust#57651 2019-01-20 22:56:07 +02:00
Grzegorz Bartoszek
adce3ef966 needless bool lint suggestion is wrapped in brackets if it is an "else" clause of an "if-else" statement 2019-01-20 16:15:00 +01:00
daxpedda
13b5ea4223
Fix automatic suggestion on use_self. 2019-01-20 14:50:26 +01:00
daxpedda
0555ca1c2d
Remove negative integer literal checks. 2019-01-20 14:18:31 +01:00
daxpedda
2183cfcc13
Fix implicit_return false positives. 2019-01-20 13:45:22 +01:00
Michael Wright
8747691bea Run rustfmt 2019-01-20 12:49:45 +02:00
Michael Wright
f51f0178dd Fixed breakage due to rust-lang/rust#57489 2019-01-20 12:21:30 +02:00
Michael Wright
77b71a1af2 Fix breakage due to rust-lang/rust#57755 2019-01-20 10:14:23 +02:00
bors
e648adf086 Auto merge of #3674 - sinkuu:fmt_rustup, r=oli-obk
Catch up with `format_args` change

Catches up with a change in rust-lang/rust#57537. (Since the optimization is optional, this clippy PR can be merged before the rustc PR.)

Happened to fix a bug in `expect_fun_call`, that is the lint ignores more than
one arguments to `format`.

```
warning: use of `expect` followed by a function call
 --> src/main.rs:2:17
  |
2 |     Some("foo").expect(format!("{} {}", 1, 2).as_ref());
  |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| panic!("{} {}", 1))`
  |
```
2019-01-19 12:40:46 +00:00
Shotaro Yamada
2ee713dc7b Catch up with format_args change
Catches up with a change in rust-lang/rust#57537

Happened to fix a bug in `expect_fun_call`, that is the lint ignores more than
one arguments to `format`.
2019-01-19 21:18:31 +09:00
bors
751d82e825 Auto merge of #3672 - mikerite:fix-3670, r=oli-obk
Fix bad `while_let_on_iterator` suggestion.

Don't suggest a `for` loop if the iterator is used inside the `while` loop.

Closes #3670
2019-01-19 11:12:03 +00:00
Michael Wright
a773276da3 Fix bad while_let_on_iterator suggestion.
Don't suggest a `for` loop if the iterator is used inside the `while` loop.

Closes #3670
2019-01-19 11:36:27 +02:00
Matthias Krüger
de9c09e2bd rustup https://github.com/rust-lang/rust/pull/57747 2019-01-19 09:27:45 +01:00
Andy Russell
8fba46aa27
add applicability to lint name suggestion 2019-01-16 15:29:37 -05:00
Michael Wright
f96dc2e9e2 Remove map_clone fixed known problem 2019-01-15 08:15:12 +02:00
Michael Wright
67a9f20c91 Fix map_clone bad suggestion
`cloned` requires that the elements of the iterator must be references. This
change determines if that is the case by examining the type of the closure
argument and suggesting `.cloned` only if it is a reference. When the closure
argument is not a reference, it suggests removing the `map` call instead.

A minor problem with this change is that the new check sometimes overlaps
with the `clone_on_copy` lint.

Fixes #498
2019-01-15 08:09:47 +02:00
bors
19553aee2c Auto merge of #3657 - roblabla:bugfix-missing-docs-global-asm, r=phansch
Missing docs: don't require documenting Global Asm items.

global_asm! items cannot be documented, the lint still gets triggered after adding documentation to the macro invocation. Furthermore, even if we could add documentation to the AST node, rustdoc doesn't render it anyways.

Playground example: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=5182df182f0ffbbab4c3107e43368ac3
2019-01-14 14:50:27 +00:00
bors
11ba624e38 Auto merge of #3653 - gendx:master, r=phansch
Fix typos in clippy_lints/src/len_zero.rs

Some comments in the len_zero lint had typos.
2019-01-14 09:16:20 +00:00
bors
ec1a6cb442 Auto merge of #3658 - detrumi:add-several-run-rustfix-annotations, r=phansch
Add several run rustfix annotations

Adds `run-rustfix` to 18 of the tests from the tracking issue #3630.
Each test has its own commit, to make reviewing easier (hopefully this is easier to review than 18 separate PRs).

## Changes
- `cfg_attr_rustfmt`: Custom inner attributes are unstable. Let's disable the lint for inner attributes until [#54726](https://github.com/rust-lang/rust/issues/54726) stabilizes
- `collapsible_if`: unrelated cyclomatic_complexity warning that can be ignored
- `duration_subsec`: Simply needed `#![allow(dead_code)]`
- `excessive_precision`: Fixed by `#!allow(dead_code,unused_variables)`
- `explicit_write`: Fixed by `#![allow(unused_imports)]`
- `inconsistent_digit_grouping`: Avoid triggering `clippy::excessive_precision` lint
- `infallible_destructuring_match`: Fixed by `#![allow(dead_code, unreachable_code, unused_variables)]`
- `into_iter_on_ref`: Triggered unrelated `clippy::useless_vec` lint
- `large_digit_groups`: Avoid triggering `clippy::excessive_precision` lint
- `map_clone`: Fixed by `#![allow(clippy::iter_cloned_collect)]`
- `mem_replace`: Suggestion causes import to be unused, fixed by `#![allow(unused_imports)]`
- `precedence`: Allow some unrelated lints, and change out-of-range `0b1111_1111i8` literal
- `redundant_field_names`: Allow dead code, and remove stabilized feature toggles
- `replace_consts`: Fixed by `#![allow(unused_variables)]`
- `starts_ends_with`: Fixed by `#![allow(unused_must_use)]`
- `types`: Fixed by `#![allow(dead_code, unused_variables)]`
- `unit_arg`: Fixed by `#[allow(unused_must_use)]`
- `unnecessary_fold`: Fixed by adding type annotations and adding `#![allow(dead_code)]`
2019-01-14 08:16:51 +00:00
roblabla
79203653d1 Missing docs: don't require documenting Global Asm items.
global_asm! items cannot be documented, the lint still gets triggered
after adding documentation to the macro invocation. Furthermore, even
if we could add documentation to the AST node, rustdoc doesn't render
it anyways.

Playground example: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=5182df182f0ffbbab4c3107e43368ac3
2019-01-13 16:22:48 +00:00
Wilco Kusee
ea7eb49b47 Disable deprecated_cfg_attr lint for inner attributes 2019-01-13 11:53:43 +01:00
Matthias Krüger
079a593dab rustup: the features if_while_or_patterns has been stabilized 2019-01-12 16:11:17 +01:00
Guillaume Endignoux
798a419b1c Fix comments in clippy_lints/src/len_zero.rs 2019-01-10 22:48:44 +01:00
A.A.Abroskin
a9f8d3c8fd add assert(true/false, some message) tests 2019-01-09 21:30:47 +03:00
Abroskin Alexander
7075015f31
Merge branch 'master' into add-lints-aseert-checks 2019-01-09 13:49:40 +03:00
A.A.Abroskin
906b51637c change assert_checks to assertions_on_constants 2019-01-09 13:38:38 +03:00
Philipp Hansch
38d4ac7cea
Remove all copyright license headers
Discussion previously happened in https://github.com/rust-lang/rust/pull/43498
2019-01-08 21:46:39 +01:00
bors
5b8496603c Auto merge of #3640 - detrumi:nested_use_self, r=flip1995
Restrict `use_self` on nested items

Fixes #3637
Fixes #3463

These changes make it so that nested items aren't visited any more by the `use_self` lint.

I think visiting nested items should be possible (so that it uses a different `item_path` for the nested item), but I'm not sure whether it's viable and what the best approach would be.
- Can `item_path` be changed to a new `Self` path before visiting the item, and then changing it back afterwards?
- Alternatively, could a new visitor be created, re-using `check_trait_method_impl_decl`?
2019-01-07 18:54:28 +00:00
bors
140c1650e8 Auto merge of #3600 - xfix:cast-ref-to-mut, r=flip1995
cast_ref_to_mut lint

I see this pattern way too often, and it's completely wrong. In fact, due to how common this incorrect pattern is, [the Rustonomicon specifically points this out](https://doc.rust-lang.org/nomicon/transmutes.html).

> - Transmuting an & to &mut is UB
>   - Transmuting an & to &mut is always UB
>   - No you can't do it
>   - No you're not special

This is my first lint.
2019-01-07 18:30:53 +00:00
Konrad Borowski
27ea638a15 Move cast_ref_to_mut list to correctness group 2019-01-07 14:39:56 +01:00
Konrad Borowski
21d30450b5 Don't import ty::Ref in cast_ref_to_mut lint 2019-01-07 14:37:28 +01:00
Konrad Borowski
6faf1330aa Move a hint to an error message in cast_ref_to_mut lint
This matches mem::transmute::<&T, &mut T> lint in rustc.
2019-01-07 14:37:28 +01:00
Konrad Borowski
1cab4d15a2 Add a note to cast_ref_to_mut lint 2019-01-07 14:37:28 +01:00
Konrad Borowski
fd57874106 Use ty::Ref instead of ty::TyKind::Ref 2019-01-07 14:37:28 +01:00
Konrad Borowski
34daf09aa4 cast_ref_to_mut lint 2019-01-07 14:37:28 +01:00
Marcel Hellwig
a3931229c4
Add missing ` in default lint 2019-01-07 14:32:32 +01:00
Wilco Kusee
351688db78
Improve tests and exclude nested impls 2019-01-07 14:11:53 +01:00
A.A.Abroskin
96058616e2 run ./util/dev update_lints 2019-01-07 13:33:06 +03:00
A.A.Abroskin
3d9535a106 Add unreachable!() as option 2019-01-07 13:30:17 +03:00
A.A.Abroskin
98c5f37ad2 Add assert(true) and assert(false) lints 2019-01-07 13:30:17 +03:00
Michael Wright
d2ea6355a8 Update unwrap_get code review suggestions 2019-01-07 06:22:39 +02:00
Wilco Kusee
7230768998 Update known problems 2019-01-06 15:41:02 +01:00
Wilco Kusee
ff191a808e Restrict use_self on nested items 2019-01-06 15:34:36 +01:00
Michael Wright
4add1e23f9 Improve get_unwrap suggestion
Handle case where a reference is immediately dereferenced.

Fixes 3625
2019-01-06 11:46:03 +02:00
Matthias Krüger
3389a68834 Revert "Auto merge of #3603 - xfix:random-state-lint, r=phansch"
This reverts commit 0a6593cd1b, reversing
changes made to 5277a1fb6c.

This hopefully fixes #3628
2019-01-05 10:19:04 +01:00
bors
d264e406be Auto merge of #3627 - detrumi:use_self_local_macro, r=phansch
Trigger `use_self` lint in local macros

Closes #2098

The test currently only covers local macros. #2098 suggested this:
> You could add the macro in question into the `mini_macro` subcrate

But that doesn't work for a `macro_rules`:
```
error: cannot export macro_rules! macros from a `proc-macro` crate type currently
```

So I suggest leaving out the test for external macros, as using `in_external_macro` seems straigtforward enough. Alternatives would be to use to add an additional crate (overkill if you ask me), or test with a `proc-macro`.
2019-01-05 08:51:13 +00:00
Matthias Krüger
a4b99c6d68 rustup https://github.com/rust-lang/rust/pull/56837 2019-01-05 08:21:56 +01:00
Matthias Krüger
33ec4e5220 rustup (don't know the exact PR unfortunately) 2019-01-05 01:12:33 +01:00
bors
194a91c45d Auto merge of #3601 - xfix:move-constant-write-lint, r=flip1995
Move constant write checks to temporary_assignment lint

They make more sense here

cc #3595
2019-01-04 14:59:11 +00:00
Wilco Kusee
407ff74dcc
Trigger use_self lint in local macros 2019-01-04 13:01:31 +01:00
bors
756b32e1e2 Auto merge of #3623 - phansch:rustup, r=flip1995
rustup: https://github.com/rust-lang/rust/pull/55517

None
2019-01-03 22:29:09 +00:00
Philipp Hansch
d1fffe07c5
rustup: https://github.com/rust-lang/rust/pull/55517 2019-01-03 21:54:57 +01:00
bors
c7c75db827 Auto merge of #3621 - Zoxc:parallel, r=phansch
Make clippy work with parallel rustc
2019-01-03 19:27:32 +00:00
John Kåre Alsaker
3af68f831a Make clippy work with parallel rustc 2019-01-03 19:18:06 +01:00
bors
5b8b01e8dc Auto merge of #3519 - phansch:brave_newer_ui_tests, r=flip1995
Integrate rustfix into Clippy test suite

Once the [PR to compiletest-rs](https://github.com/laumann/compiletest-rs/pull/151) is reviewed and merged this fixes #2376.

I will create a separate tracking issue for adding `run-rustfix` to all tests.
2019-01-03 15:08:47 +00:00
bors
0a6593cd1b Auto merge of #3603 - xfix:random-state-lint, r=phansch
random_state lint
2019-01-03 02:00:46 +00:00
bors
84aa027888 Auto merge of #3607 - detrumi:limit_infinite_iter_to_known_types, r=phansch
Only trigger `infinite_iter` lint for infinitely allocating `collect()` calls

Fixes  #3538

~Oh, I guess this should actually check other methods like `count` as well, not only `collect()`.~
Never mind, `collect` is the only of these functions that allocates a data structure.
2019-01-03 00:12:02 +00:00
Wilco Kusee
f38fb56baf Limit infinite_iter collect() check to known types 2018-12-31 13:38:31 +01:00
bors
85ba5f0f17 Auto merge of #3608 - phansch:improve_util_docs, r=oli-obk
Some improvements to util documentation

None
2018-12-31 12:03:28 +00:00
Philipp Hansch
cc76384807
Some improvements to util documentation 2018-12-31 12:12:50 +01:00
bors
f2fd8e71e9 Auto merge of #3606 - detrumi:blacklisted_name_hashset, r=phansch
Use hashset in `blacklisted_name` lint
2018-12-31 10:22:06 +00:00
Wilco Kusee
d1dfd3e96f Use hashset for name blacklist 2018-12-31 10:44:27 +01:00
bors
6f3912850a Auto merge of #3590 - jorpic:i3559-if_same_then_else, r=phansch
Fix if_same_then_else false positive

This fixes false positive in #3559.
The problem was that `SpanlessEq` does not check patterns in declarations. So this two blocks considered equal.
```rust
if true {
    let (x, y) = foo();
} else {
   let (y, x) = foo();
}
```
Not sure if the proposed change is safe as `SpanlessEq` is used extensively in other lints, but I tried hard to come up with counterexample and failed.
2018-12-31 09:25:18 +00:00
bors
529f698c23 Auto merge of #3599 - xfix:use-hash-set-for-valid-idents, r=oli-obk
Use an FxHashSet for valid idents in documentation lint
2018-12-30 17:46:01 +00:00
Konrad Borowski
978e3ac2cf Use node_id_to_type_opt instead of node_it_to_type in random_state 2018-12-30 13:40:27 +01:00
bors
735607c1f9 Auto merge of #3588 - detrumi:tuple_struct_use_self, r=phansch
`use_self` for tuple structs

Fixes #3498
2018-12-30 11:12:55 +00:00
Max Taldykin
911a752561 Check pattern equality while checking declaration equality 2018-12-30 14:01:56 +03:00
Konrad Borowski
1130bbc26f Merge branch 'master' of https://github.com/rust-lang/rust-clippy into random-state-lint 2018-12-30 11:43:20 +01:00
bors
aee138a7cf Auto merge of #3597 - xfix:match-ergonomics, r=phansch
Match ergonomics (lints from A to B)
2018-12-30 10:40:36 +00:00
Wilco Kusee
1d10de66de Remove false negatives from known problems 2018-12-30 08:23:39 +01:00
Wilco Kusee
ab42ba4f54 Implement use_self for tuple structs 2018-12-30 08:23:38 +01:00
Wilco Kusee
0f3dcdc3aa Document known problems 2018-12-30 08:20:49 +01:00
Konrad Borowski
a6c4eaa93c random_state lint 2018-12-30 02:45:34 +01:00
Matthias Krüger
e590025f61 rustup https://github.com/rust-lang/rust/pull/56225/
item.name -> item.ident.name
2018-12-30 01:09:24 +01:00
Konrad Borowski
815e434a1f Move constant write checks to temporary_assignment lint
They make more sense here
2018-12-30 00:25:09 +01:00
bors
6cba3da727 Auto merge of #3558 - russelltg:new_without_default_merge, r=flip1995
Merge new_without_default_derive into new_without_default

Closes #3525, deprecating new_without_default_derive and moving both lints into new_without_default.
2018-12-29 17:31:35 +00:00
Konrad Borowski
ab70e0e742 Use an FxHashSet for valid idents in documentation lint 2018-12-29 18:08:53 +01:00
Konrad Borowski
aeabb890d6 Use match ergonomics for booleans lint 2018-12-29 17:38:15 +01:00
Konrad Borowski
13c857b745 Use match ergonomics for block_in_if_condition lint 2018-12-29 17:32:09 +01:00
Konrad Borowski
fe151ebb9c Use match ergonomics for bit_mask lint 2018-12-29 17:31:32 +01:00
Konrad Borowski
931e2b0026 Use match ergonomics for attrs lint 2018-12-29 17:29:50 +01:00
Konrad Borowski
3bf71a8e62 Use match ergonomics for assign_ops lint 2018-12-29 17:27:26 +01:00
Konrad Borowski
79cd95cf35 Use match ergonomics for artithmetic lint 2018-12-29 17:25:45 +01:00
Konrad Borowski
0ddb628488 Use match ergonomics for approx_const lint 2018-12-29 17:25:07 +01:00
bors
4d60841205 Auto merge of #3596 - xfix:remove-crate-from-paths, r=flip1995
Remove crate:: prefixes from crate paths

This is somewhat misleading, as those are actually external crates,
and don't need a crate:: prefix.
2018-12-29 16:15:57 +00:00
Konrad Borowski
3f62fc3a7e Remove crate:: prefixes from crate paths
This is somewhat misleading, as those are actually external crates,
and don't need a crate:: prefix.
2018-12-29 16:05:49 +01:00
Konrad Borowski
9fe8a3e52e Support array indexing expressions in unused write to a constant 2018-12-29 15:34:15 +01:00
Konrad Borowski
847898f18f Mark writes to constants as side-effect-less 2018-12-29 15:18:51 +01:00
Konrad Borowski
44bf8e0c3d Remove unsafe from consts clippy lints 2018-12-29 00:50:03 +01:00
Philipp Hansch
298aedf2f8
Fix suggestion for unnecessary_ref lint 2018-12-28 20:54:29 +01:00
Peter Fürstenau
6ee0e22204 Merge remote-tracking branch 'upstream/master' 2018-12-28 20:19:51 +01:00
Russell Greene
d127aed737 Merge new_without_default_derive into new_without_default 2018-12-28 10:57:58 -07:00
flip1995
909bfd3cd8
Match on ast/hir::ExprKind::Err 2018-12-28 13:31:19 +01:00
bors
721f688eff Auto merge of #3577 - daxpedda:master, r=flip1995
Fix false positives for `implicit_return` and `empty_loop` on macro expansion.

This PR only fixes `implicit_return` and `empty_loop`.
But I suspect this bug may affect a lot of other lints.
2018-12-27 15:21:22 +00:00
Matthias Krüger
99454bc9a1 rustup https://github.com/rust-lang/rust/pull/57069 2018-12-27 11:19:20 +01:00
daxpedda
2d96ef1315
Rustfmt. 2018-12-26 18:13:33 +01:00
Matthias Krüger
7f5e17f3f1 fix a couple of ftrivial typos (NFC). 2018-12-25 18:22:34 +01:00
Philipp Krones
197914439a
Fix macro detection in empty_loop.
Co-Authored-By: daxpedda <1645124+daxpedda@users.noreply.github.com>
2018-12-25 12:57:16 +01:00
daxpedda
a77bcadaa5
Changed macro_backtrace() to in_macro(). 2018-12-25 12:48:54 +01:00
daxpedda
b5587a894f
Fix lint detection on macro expansion. 2018-12-24 22:06:08 +01:00
Oliver Scherer
6db409fc0c
FIXME > TODO 2018-12-23 13:29:37 +01:00
Matthias Krüger
ce3e69da1c rustup https://github.com/rust-lang/rust/pull/56992 2018-12-23 10:42:06 +01:00
bors
52820e588f Auto merge of #3573 - Vlad-Shcherbina:map_clone_caveat, r=flip1995
Document map_clone known problems #498

(cherry picked from commit ada0d2c548)

This was lost in relicensing (057243f16b).
However, I [acknowledged](https://github.com/rust-lang/rust-clippy/issues/3099#issuecomment-416482309) relicensing so this cherry pick should be fine I guess.
2018-12-22 15:02:50 +00:00