Commit Graph

2159 Commits

Author SHA1 Message Date
daxpedda
a4ec7be06f
Forgot to remove some debugging code ... 2018-12-06 13:23:42 +01:00
daxpedda
d048e15835
Improved code noted by clippy. 2018-12-06 13:21:04 +01:00
daxpedda
973d676cd1
Fix bug in implicit_return.
Bug was already covered by test, but test was not checked for.
2018-12-06 12:22:54 +01:00
Felix Kohlgrüber
a8a0b236b5 fix #3482 and add ui test for it 2018-12-06 11:07:10 +01:00
Philipp Hansch
f93591294d
Merge pull request #3494 from daxpedda/master
Added `IMPLICIT_RETURN` lint.
2018-12-06 07:12:01 +01:00
daxpedda
b0f3ed2b80 Added additional reasoning to Why is this bad?.
Added comment to explain usage of MIR.
2018-12-05 15:01:19 +01:00
daxpedda
aed2b986e6 Renamed to implicit_return.
Covered all other kinds besides `ExprKind::Lit`.
Added check for replacing `break` with `return`.
2018-12-05 14:39:09 +01:00
flip1995
36ee92780d
Fix ty::TyKind usage 2018-12-05 12:47:19 +01:00
flip1995
20a07f6d80
Fix TyKind::<kind> usage in codebase 2018-12-05 12:47:10 +01:00
daxpedda
19db2f1a32 Appeasing the Test Gods.
Seems I'm not smart enough to run the tests locally before committing.
2018-12-05 11:26:40 +01:00
daxpedda
978f8c65ee Renamed forced_return to missing_returns.
Better clarification in the docs.
Ran `update_lints`.
2018-12-05 10:54:21 +01:00
daxpedda
d5d6692288 Added FORCED_RETURN lint. 2018-12-05 01:59:09 +01:00
Philipp Krones
3f24cdf10f
Merge pull request #3490 from phansch/extract_single_match_else_ui_test
Extract single_match_else UI test
2018-12-04 14:57:19 +01:00
Philipp Hansch
68bb900eba
Merge pull request #3473 from lucasloisp/additional-bool-comparisons
Adds inequality cases to bool comparison (#3438)
2018-12-04 07:26:29 +01:00
Philipp Hansch
8b2eb06df3
Merge pull request #3488 from phansch/fix_cargo_lint_bug
Fix wildcard_dependencies false positive
2018-12-04 07:24:11 +01:00
Philipp Hansch
3f72d4d630
Extract single_match_else UI test
There's only one test currently.
I also updated the lint doc with a 'good' example and changed the lint
help text a bit.

cc #2038
2018-12-04 07:20:13 +01:00
Philipp Hansch
46ee676139
cargo fmt 2018-12-04 06:47:41 +01:00
Lucas Lois
3930148059 Adds inequality cases to bool comparison lint
The lint now checks cases like `y != true`
2018-12-03 16:32:11 -03:00
Oliver S̶c̶h̶n̶e̶i̶d̶e̶r Scherer
c00210d7ba
Merge pull request #3478 from dtolnay/setlen
Remove unsafe_vector_initialization lint
2018-12-03 12:42:31 +01:00
David Tolnay
e632a1946e
Remove unsafe_vector_initialization lint 2018-12-03 02:48:37 -08:00
Oliver S̶c̶h̶n̶e̶i̶d̶e̶r Scherer
13438b6866
Merge pull request #3479 from dtolnay/literal
Downgrade large_digit_groups to pedantic
2018-12-03 11:06:56 +01:00
Philipp Hansch
ef64c762d2
Fix wildcard_dependencies false positive
This now only checks for wildcard_dependencies if the source is a
non-git source.

I tried adding a compiletest suite for the cargo lints, but I was unable
to override the `Cargo.toml` of the original executable.

I tested this manually by modifying the main `Cargo.toml`.

Fixes #3458
2018-12-03 08:12:35 +01:00
Philipp Hansch
ebd508e0ac
Fix rustfmt format 2018-12-03 07:13:00 +01:00
David Tolnay
c00dcd03d7
Downgrade large_digit_groups to pedantic
I believe if the user already decided to put underscores in their
literal, Clippy should be willing to believe that they put a number of
underscores that they felt was readable.
2018-12-01 17:08:42 -08:00
David Tolnay
8b1f69a485
Downgrade unsafe_vector_initialization to restriction
This lint looks for:

    let mut vec = Vec::with_capacity(len);
    vec.set_len(len);

The suggested replacement is `vec![0; len]`.

This is far too opinionated to be a deny-by-default lint because the performance
characteristics of the suggested replacement are totally different.

I am not convinced that this lint has value beyond what deny(unsafe_code) gives
you. Unsafe code is unsafe but please don't deny-by-default lint it if that's
the only reason.
2018-12-01 16:21:02 -08:00
Matthias Krüger
c38bac89e9 remove macro_at_most_once_rep feature attribute since it's stable
Warning was:
warning: the feature `macro_at_most_once_rep` has been stable since 1.32.0 and no longer requires an attribute to enable
  --> clippy_lints/src/lib.rs:19:12
   |
19 | #![feature(macro_at_most_once_rep)]
   |            ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: #[warn(stable_features)] on by default
2018-11-30 09:14:18 +01:00
flip1995
63fa5d24e1
Fix some formatting issues 2018-11-27 21:49:09 +01:00
flip1995
1751d2496d
Run rustfmt on clippy_lints 2018-11-27 21:14:15 +01:00
flip1995
87e72a5861
Fix NAIVE_BYTECOUNT applicability 2018-11-27 17:31:17 +01:00
flip1995
6eb8e6d7c5
Fix dogfood error 2018-11-27 16:59:52 +01:00
flip1995
adc638ef33
Change Applicability of MISTYPED_LITERAL_SUFFIX 2018-11-27 16:59:39 +01:00
flip1995
4e74eef6e9
Add applicability level to (nearly) every span_lint_and_sugg function 2018-11-27 15:29:23 +01:00
flip1995
3740da203b
Fix bugs and improve documentation
Some bugs and some documentation is unrelated to the Applicability change, but
these bugs were serious and the documentation was kind of required to
understand what's going on.
2018-11-27 15:29:23 +01:00
flip1995
9096269610
Add Applicability::Unspecified to span_lint_and_sugg functions 2018-11-27 15:29:23 +01:00
flip1995
fad267c3b3
Introduce snippet_with_applicability and hir_with_applicability functions 2018-11-27 15:29:14 +01:00
Oliver S̶c̶h̶n̶e̶i̶d̶e̶r Scherer
1e2291c90c
Merge pull request #3365 from gnieto/lint/slow-initialization
Add slow vector initializations lint
2018-11-26 13:37:46 +01:00
Matthias Krüger
ae32c877a5 constants: add u128 i128 builtin types and fix outdated url 2018-11-26 01:12:12 +01:00
Guillem Nieto
dc35841be4 Update lints 2018-11-25 14:36:04 -08:00
Guillem Nieto
5fa04bc3cd Lint only the first statment/expression after alloc
Instead of searching for all the successive expressions after a vector
allocation, check only the first expression.

This is done to minimize the amount of false positives of the lint.
2018-11-25 14:34:23 -08:00
Guillem Nieto
39b02fdcd2 Fix some warnings related to Self 2018-11-25 14:34:23 -08:00
Guillem Nieto
5b77ee95dc Rename some symbols
Renamed some symbols in order to make them a little bit more accurate.
2018-11-25 14:34:23 -08:00
Guillem Nieto
2753f1cbd4 Split lint into slow and unsafe vector initalization 2018-11-25 14:34:23 -08:00
Guillem Nieto
9b4bc3b6ef Add unsafe set_len initialization 2018-11-25 14:34:23 -08:00
Guillem Nieto
e0ccc9d9af Add slow zero-filled vector initialization lint
Add lint to detect slow zero-filled vector initialization. It detects
when a vector is zero-filled with extended with `repeat(0).take(len)`
or `resize(len, 0)`.
This zero-fillings are usually slower than simply using `vec![0; len]`.
2018-11-25 14:34:23 -08:00
Oliver S̶c̶h̶n̶e̶i̶d̶e̶r Scherer
69d09fbfc6
Merge pull request #3439 from dtolnay/npbv
Downgrade needless_pass_by_value to allow by default
2018-11-24 10:16:38 +01:00
Philipp Hansch
754b4c0723
Merge pull request #3452 from matthiaskrgr/rustup
rustup https://github.com/rust-lang/rust/pull/54071/
2018-11-23 10:38:20 +01:00
Matthias Krüger
311c8e29b1 rustup https://github.com/rust-lang/rust/pull/54071/ 2018-11-23 10:05:51 +01:00
Matthias Krüger
1ee0c1a029 dependencies: update pulldown-cmark from 0.1 to 0.2 2018-11-22 18:04:34 +01:00
Oliver S̶c̶h̶n̶e̶i̶d̶e̶r Scherer
ff7da3264e
Merge pull request #3447 from phansch/small_rename
s/file_map/source_map
2018-11-22 15:08:13 +01:00
Oliver S̶c̶h̶n̶e̶i̶d̶e̶r Scherer
87ec0580f9
Merge branch 'master' into version_ids 2018-11-22 10:22:25 +01:00
Philipp Hansch
c4b08a5b0c
s/file_map/source_map 2018-11-22 07:53:59 +01:00
Matthias Krüger
f5929e0797 rust-lang-nursery/rust-clippy => rust-lang/rust-clippy 2018-11-22 04:40:09 +01:00
Wayne Warren
1fed72bad4 Address 'clippy::single-match' dogfood lint 2018-11-21 07:52:02 -06:00
Philipp Krones
d4a6ee4a0c Fix nit
Co-Authored-By: waynr <wayne.warren.s@gmail.com>
2018-11-21 07:52:02 -06:00
Wayne Warren
cb5e327c58 Address travis CI lint failure 2018-11-21 07:52:02 -06:00
Wayne Warren
92f7f9061c issue#3318 run trivially_copy_pass_by_ref for traits 2018-11-21 07:52:02 -06:00
Oliver Scherer
617d861041 Enable rustup clippy to refer to the correct documentation 2018-11-21 13:33:42 +01:00
Matthias Krüger
4aae76464c rustup https://github.com/rust-lang/rust/pull/52591 2018-11-21 13:29:23 +01:00
David Tolnay
e4be2b4e64
Downgrade needless_pass_by_value to allow by default
I noticed that I suppress this lint in many of my projects.

https://github.com/search?q=needless_pass_by_value+user%3Adtolnay&type=Code
https://github.com/search?q=needless_pass_by_value+user%3Aserde-rs&type=Code

Upon further inspection, this lint has a *long* history of false
positives (and several remaining).

Generally I feel that this lint is the definition of pedantic and should
not be linted by default.

    #[derive(Debug)]
    enum How {
        ThisWay,
        ThatWay,
    }

    // Are we really better off forcing the call sites to write f(&_)...?
    fn f(how: How) {
        println!("You want to do it {:?}", how);
    }

    fn main() {
        f(How::ThatWay);
    }
2018-11-21 03:11:22 -08:00
bors[bot]
64ff255ac6 Merge #3432
3432: match_ref_pats: don't emit suggestions inside of a macro r=Manishearth a=flip1995

Fixes #2636 

Co-authored-by: flip1995 <hello@philkrones.com>
2018-11-19 21:07:49 +00:00
Matthias Krüger
3a11cd4289 remove unused allow() attributes, NFC 2018-11-17 13:47:46 +01:00
flip1995
1000fc5120
Don't emit suggestion when inside of a macro 2018-11-15 17:03:17 +01:00
Matthias Krüger
2d0d41ff29 rustup https://github.com/rust-lang/rust/pull/55852/ 2018-11-15 16:50:28 +01:00
bors[bot]
a2c9d10da5 Merge #3419
3419: Linter to check that all common metadata is included r=flip1995 a=ysimonson

Addresses https://github.com/rust-lang-nursery/rust-clippy/issues/1793

This is not ready to be merged yet. First the associated changes to `cargo_metadata` need to be merged: https://github.com/oli-obk/cargo_metadata/pull/55

Co-authored-by: Yusuf Simonson <simonson@gmail.com>
2018-11-15 14:18:12 +00:00
Anton
93324f1acf
Fix "too" -> "foo" typo in format.rs 2018-11-14 14:08:52 +01:00
Michael Wright
3ba4c3a9b1 Fix use_self violation 2018-11-14 08:43:35 +02:00
Michael Wright
e2e892b59b Fix wrong suggestion for redundant_closure_call
Fixes #1684
2018-11-14 08:01:39 +02:00
Yusuf Simonson
866caabb7a Check for common metadata 2018-11-13 08:43:30 -05:00
Michael Wright
5ade9ff44e Fix use_self false positive on use statements 2018-11-13 06:15:33 +02:00
Michael Wright
460c2b317b Fix use_self false positive
This fixes the first error reported in issue #3410.
2018-11-10 10:57:11 +02:00
Michael Wright
c20e17f8ee Remove + from has_unary_equivalent
Rust doesn't has a unary + operator!
2018-11-06 07:05:13 +02:00
Michael Wright
2353f24095 Merge branch 'master' into fix-missing-comma-fp 2018-11-06 07:00:54 +02:00
Philipp Hansch
90f31e21ab
RIIR update lints: Add check mode (update_lints.py rewrite complete)
This finishes up the rewrite of `update_lints.py` in Rust. More
specifically, this

* adds the `--check` flag and handling to clippy_dev
* tracks file changes over the different calls to `replace_region_in_file`
* only writes changes to files if the `--check` flag is *not* used
* runs `./util/dev update_lints --check` on CI instead of the old script
* replaces usage of the `update_lints.py` script with an error

`./util/dev update_lints` behaves 99% the same as the python script.
The only difference that I'm aware of is an ordering change to
`clippy_lints/src/lib.rs` because underscores seem to be sorted
differently in Rust and in Python.

🏁
2018-11-05 07:18:47 +01:00
bors[bot]
7e417d4cbd Merge #3353
3353: float support added for mistyped_literal_suffixes lint r=mikerite a=Maxgy

I implemented the mistyped_literal_suffixes lint for float literals.

```
#![allow(unused_variables)]

fn main() {
    let x = 1E2_32;
    let x = 75.22_64;
}
```
Given the above, the additional check suggests the variables to be written as `let x = 1E2_f32` and `let x = 75.22_f64`.

Fixes #3167 

Co-authored-by: Maxwell Anderson <maxwell.brayden.anderson@gmail.com>
2018-11-05 03:58:15 +00:00
Matthias Krüger
396701613e rustup https://github.com/rust-lang/rust/pull/55665 (pass contexts by reference) 2018-11-04 22:47:20 +01:00
Maxwell Anderson
3e0de1745d changed into_iter to iter and fixed a lint check 2018-11-04 10:39:54 -07:00
Michael Wright
a3ab512576 Fix collapsible_if error 2018-11-04 10:48:24 +02:00
Michael Wright
0c1ffc1d1f Fix possible_missing_comma false positives
`possible_missing_comma` should only trigger when the binary operator has
unary equivalent. Otherwise, it's not possible to insert a comma without
breaking compilation. The operators identified were `+`, `&`, `*` and `-`.

This fixes the specific examples given in issues #3244 and #3396
but doesn't address the conflict this lint has with the style of starting
a line with a binary operator.
2018-11-04 10:02:49 +02:00
Matthias Krüger
b59b60c8ae rustup https://github.com/rust-lang/rust/pull/55330/ 2018-11-03 18:50:23 +01:00
bors[bot]
486300b89d Merge #3400
3400: Fix a false-positive of needless_borrow r=phansch a=sinkuu



Co-authored-by: Shotaro Yamada <sinkuu@sinkuu.xyz>
2018-11-03 08:34:13 +00:00
flip1995
cadb367a5c
Also lint cfg_attr(.., rustfmt::skip) 2018-11-02 19:50:24 +01:00
flip1995
a770d8edd0
Differ between inner and outer attributes 2018-11-02 19:49:58 +01:00
flip1995
e1cf160e2a
Add cfg_attr(rustfmt) lint 2018-11-02 19:49:57 +01:00
kennytm
5563bd6cc3
Addressed comments. 2018-11-02 22:53:57 +08:00
kennytm
2b2acf1002
Fix dogfood error. 2018-11-02 22:53:57 +08:00
kennytm
2d1c9313b0
Added lints into_iter_on_ref and into_iter_on_array. Fix #1565. 2018-11-02 22:53:56 +08:00
flip1995
32396f6e18
Allow single_match_else 2018-11-02 14:00:46 +01:00
flip1995
014cf3d6e0
Fix typos 2018-11-02 13:49:10 +01:00
flip1995
cf89c40e34
Fix dogfood error 2018-11-02 13:49:10 +01:00
flip1995
ea4a80f215
Fix typo and indentation 2018-11-02 13:49:10 +01:00
flip1995
f6d57862c7
Add new lint: unknwon_clippy_lintsg 2018-11-02 13:49:09 +01:00
Matthias Krüger
df7cff31dc clippy: fix pedantic warnings and run clippy::pedantic lints on the codebase.
Turn on pedantic lints in dogfood and base tests.

needless_bool: fix clippy::items-after-statements
redundant_pattern_matching: fix clippy::similar-names
mods.rs: fix clippy::explicit-iter-loop
returns.rs: allow clippy::cast-possible-wrap

Fixes #3172
2018-11-02 12:16:43 +01:00
bors[bot]
7c86a9c05c Merge #3387
3387: Replace big if/else expression with match r=flip1995 a=mikerite



Co-authored-by: Michael Wright <mikerite@lavabit.com>
2018-11-02 07:58:00 +00:00
Shotaro Yamada
d4370f8b07 Fix a false-positive of needless_borrow 2018-11-02 15:58:54 +09:00
bors[bot]
0ad5b9b9e0 Merge #3388
3388: RIIR update lints: Generate deprecated lints r=phansch a=phansch

The update script now also generates the 'register_removed' section in
`clippy_lints/src/lib.rs`.

Also, instead of using `let mut store ...`, I added a new identifier
line so that the replacement will continue to work in case `let mut
store ...` ever changes.

cc #2882

Co-authored-by: Philipp Hansch <dev@phansch.net>
2018-11-02 06:29:40 +00:00
Maxwell Anderson
b6b97e5c1f format code 2018-11-01 15:43:40 -06:00
Maxwell Anderson
6c1f89e8dc Merge remote-tracking branch 'upstream/master' 2018-11-01 15:26:38 -06:00
Philipp Hansch
beb44ef6ca
Fix clippy build failure on latest master 2018-11-01 20:35:23 +01:00
Maxwell Anderson
02340cc891
fix comment spacing 2018-11-01 12:35:01 -06:00
Michael Wright
0a41dfd946 Use slice patterns instead of padding 2018-11-01 07:06:47 +02:00
Maxwell Anderson
98ce3348d9 change single char str to char 2018-10-31 18:09:56 -06:00
Maxwell Anderson
3c22b2314c Merge remote-tracking branch 'upstream/master' 2018-10-31 16:48:47 -06:00
Maxwell Anderson
f4b919cad7 add lint to lintarray macro 2018-10-31 16:48:24 -06:00
Maxwell Anderson
6b895b8267 Revert "small fix"
This reverts commit b1abc81a60.
2018-10-31 16:39:12 -06:00
bors[bot]
73458aebe3 Merge #3368
3368: added downsides to "known problems" for get_unwrap lint r=flip1995 a=humean

As a beginner I found this lint to be confusing because I was not sure how the `Option` type disappeared as conceptually I know that my `.get()` and Index could fail. Initially I thought maybe the compiler or clippy was smart enough to understand that it was impossible for my `.get()` to fail in this particular case, but it was explained to me that using the Index syntax is just shorthand for directly unwrapping the value:

https://doc.rust-lang.org/src/std/collections/hash/map.rs.html#1547

For beginners or users trying to iterate quickly it seems common to litter your code with `unwrap` or `except` as placeholders for where some explicit error handling might need to take place. I think it should be warned that using Index is merely more concise, but doesn't at all reduce the risk of panics and might in fact cause you to miss handling them in a future refactor.

Co-authored-by: Michael Rutter <michael.john.rutter@gmail.com>
Co-authored-by: Michael Rutter <humean@users.noreply.github.com>
2018-10-31 10:21:51 +00:00
bors[bot]
c8308c92b6 Merge #3378
3378: Fix lint_without_lint_pass r=phansch a=mikerite



Co-authored-by: Michael Wright <mikerite@lavabit.com>
Co-authored-by: flip1995 <hello@philkrones.com>
2018-10-31 07:18:42 +00:00
Philipp Hansch
64bd658516
RIIR update lints: Generate deprecated lints
The update script now also generates the 'register_removed' section in
`clippy_lints/src/lib.rs`.

Also, instead of using `let mut store ...`, I added a new identifier
line so that the replacement will continue to work in case `let mut
store ...` ever changes.
2018-10-31 08:03:50 +01:00
bors[bot]
b144c7f35d Merge #3370
3370: bool_comparison triggers 3 times on same code r=phansch a=mrbuzz

Fix #3335 

Co-authored-by: Giorgio Gambino <gambnio.giorgio@gmail.com>
2018-10-31 06:48:49 +00:00
Michael Wright
4e054ad320 Replace big if/else expression with match 2018-10-31 06:29:38 +02:00
Matthias Krüger
650eb09981 docs: use_self: hightlight the "should be" code sample as rust code as well. 2018-10-31 01:42:17 +01:00
Manish Goregaokar
a06296f836 Rustup to rustc 1.31.0-nightly (fb2446ad5 2018-10-30) 2018-10-30 04:06:37 +00:00
Giorgio Gambino
c0c1f1f7fa Fix #3335 rev2: bool_comparison triggers 3 times on same code 2018-10-29 22:23:45 +01:00
flip1995
1e43c3bb9f
Register MISTYPED_LITERAL_SUFFIXES lint 2018-10-29 20:54:21 +01:00
flip1995
a7fc6799df
Rewrite registered lint collection 2018-10-29 20:44:45 +01:00
Michael Wright
267d5d3433
Fix lint_without_lint_pass 2018-10-29 20:28:06 +01:00
bors[bot]
14d2700b6f Merge #3217 #3366
3217: Fix string_lit_as_bytes lint for macros r=phansch a=yaahallo

Prior to this change, string_lit_as_bytes would trigger for constructs
like `include_str!("filename").as_bytes()` and would recommend fixing it
by rewriting as `binclude_str!("filename")`.

This change updates the lint to act as an EarlyLintPass lint. It then
differentiates between string literals and macros that have bytes
yielding alternatives.

Closes #3205

3366: Don't expand macros in some suggestions r=oli-obk a=phansch

Fixes #1148 
Fixes #1628
Fixes #2455
Fixes #3023
Fixes #3333
Fixes #3360

Co-authored-by: Jane Lusby <jlusby42@gmail.com>
Co-authored-by: Philipp Hansch <dev@phansch.net>
2018-10-28 17:13:34 +00:00
Giorgio Gambino
7cfde9cfa9 Fix #3335: bool_comparison triggers 3 times on same code 2018-10-28 15:37:39 +01:00
Matthias Krüger
6eb1f23555 rustup: fix build with rustc 1.31.0-nightly (cae6efc37 2018-10-27) 2018-10-28 13:56:50 +01:00
Michael Rutter
232a483331
more consistent use of terminology; trait > syntax 2018-10-28 12:31:02 +00:00
Michael Rutter
061a48321c added downsides to "known problems" for get_unwrap lint 2018-10-28 08:12:47 +00:00
Maxwell Anderson
183e19a1c3 Merge remote-tracking branch 'upstream/master' 2018-10-27 12:50:12 -06:00
Philipp Hansch
840e50e97f
Don't expand macro in or_fun_call suggestion 2018-10-27 15:47:56 +02:00
Philipp Hansch
af1548f58f
Don't expand macro in single_match suggestion 2018-10-27 15:47:56 +02:00
Philipp Hansch
aa7bcb9074
Don't expand macro in identity_conversion suggestion 2018-10-27 15:47:56 +02:00
Jane Lusby
19ac2e94c6 fix: correctly reconstruct raw strings 2018-10-26 09:12:01 -07:00
Jane Lusby
f9020bb2dd fix: extra semicolon, only create callsite once 2018-10-26 09:12:01 -07:00
Jane Lusby
c209fc9349 Fix string_lit_as_bytes lint for macros
Prior to this change, string_lit_as_bytes would trigger for constructs
like `include_str!("filename").as_bytes()` and would recommend fixing it
by rewriting as `binclude_str!("filename")`.

This change updates the lint to act as an EarlyLintPass lint. It then
differentiates between string literals and macros that have bytes
yielding alternatives.

Closes #3205
2018-10-26 09:12:01 -07:00
bors[bot]
457e7f12e9 Merge #3355
3355: Lint to remove redundant `clone()`s r=oli-obk a=sinkuu

This PR adds lint `redundant_clone`. It suggests to remove redundant `clone()` that clones a owned value that will be dropped without any usage after that.

Real-world example: https://github.com/rust-lang/rust/compare/7b0735a..sinkuu:redundant_clone2

Co-authored-by: Shotaro Yamada <sinkuu@sinkuu.xyz>
2018-10-26 10:36:43 +00:00
bors[bot]
ead29847ff Merge #3357
3357: Check existential types in `use_self` r=oli-obk a=HMPerson1

Fixes #3231

Co-authored-by: HMPerson1 <hmperson1@gmail.com>
2018-10-26 08:48:12 +00:00
Shotaro Yamada
9034b87a53 Move in_macro check 2018-10-26 03:07:29 +09:00
Shotaro Yamada
a828692780 Use BasicBlockData::terminator 2018-10-26 01:27:28 +09:00
Shotaro Yamada
6d6ff88585 Refactor 2018-10-26 01:16:14 +09:00
Shotaro Yamada
9a150b4aa1 Use lint_root 2018-10-26 01:16:14 +09:00
Shotaro Yamada
24d3f5b48f Implement visit_basic_block_data 2018-10-26 01:16:14 +09:00
Shotaro Yamada
3ca0895920 Add redundant_clone lint 2018-10-26 01:15:55 +09:00
Matthias Krüger
b8a9099011 Revert "new_ret_no_self: add sample from #3313 to Known Problems section."
This reverts commit fd2f6dd382.

Issue #3313 has been fixed.
2018-10-25 13:39:02 +02:00
bors[bot]
a87e1b02ab Merge #3331
3331: Disable arithmetic lints in constant items r=oli-obk a=pengowen123

Currently this will not catch cases in associated constants. I'm not sure whether checking spans is the best way to solve this issue, but I don't think it will cause any problems.
Fixes #1858

Co-authored-by: Owen Sanchez <pengowen816@gmail.com>
2018-10-25 09:38:00 +00:00
Philipp Krones
5dbca1f6b1
Add Applicability 2018-10-24 23:39:54 -04:00
HMPerson1
aabf8083bd
Add lint for calling mem::discriminant on a non-enum type 2018-10-24 23:39:54 -04:00
HMPerson1
3db14f182c
Check existential types in use_self 2018-10-24 23:32:33 -04:00
Owen Sanchez
0b9e9c9e3d Disable arithmetic lints in constant items 2018-10-24 20:27:26 -07:00
bors[bot]
4c6201dceb Merge #3312
3312: OUT_OF_BOUNDS_INDEXING false negative r=phansch a=JoshMcguigan

fixes #3102

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2018-10-24 21:17:43 +00:00
bors[bot]
44fb29a356 Merge #3356
3356: Fix warnings introduced by #3349 r=flip1995 a=flip1995

I missed these warnings during review, should have checked the Travis log first.

Co-authored-by: flip1995 <hello@philkrones.com>
2018-10-24 15:25:12 +00:00
bors[bot]
bce190558f Merge #3338
3338: new_ret_no_self false positives r=flip1995 a=JoshMcguigan

~~WORK IN PROGRESS~~

I plan to fix all of the false positives in #3313 in this PR, but I wanted to open it now to start gathering feedback.

In this first commit, I've updated the lint to allow tuple return types as long as `Self` shows up at least once, in any position of the tuple. I believe this is the broadest possible interpretation of what should be allowed for tuple return types, but I would certainly be okay making the lint more strict. 

fixes #3313 

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
2018-10-24 14:42:40 +00:00
flip1995
57a18b6520
Fix warnings introduced by #3349 2018-10-24 16:18:01 +02:00
bors[bot]
319b75c75b Merge #3349
3349: Fixes #3347: Lint for wildcard dependencies in Cargo.toml r=ordovicia a=ordovicia

Add a lint for wildcard dependencies in Cargo.toml.
How should I write a test for this lint?

Fixes #3347

Co-authored-by: Hidehito Yabuuchi <hdht.ybuc@gmail.com>
2018-10-24 12:21:19 +00:00
Hidehito Yabuuchi
99b78f0650 Replace remaining krate.span with DUMMY_SP 2018-10-24 21:15:27 +09:00
Hidehito Yabuuchi
0d577c36a9 Use DUMMY_SP in multiple_crate_versions 2018-10-24 20:22:38 +09:00
Hidehito Yabuuchi
663f2cff7e Some fixes for wildcard_dependencies 2018-10-24 20:19:13 +09:00
bors[bot]
03f8899fa5 Merge #3350
3350: Don't emit `new_without_default_derive` if an impl of Default exists regardless of generics r=oli-obk a=pengowen123

Fixes #2226

Co-authored-by: Owen Sanchez <pengowen816@gmail.com>
2018-10-24 07:59:06 +00:00