Commit graph

193 commits

Author SHA1 Message Date
flip1995
f2f2a005b4 Merge commit '6ed6f1e6a1a8f414ba7e6d9b8222e7e5a1686e42' into clippyup 2021-03-12 15:30:50 +01:00
flip1995
f64149dd04 Merge commit '928e72dd10749875cbd412f74bfbfd7765dbcd8a' into clippyup 2021-02-25 11:25:22 +01:00
flip1995
8b9f4a0d34 Merge commit '70c0f90453701e7d6d9b99aaa1fc6a765937b736' into clippyup 2021-02-11 15:04:38 +01:00
Manish Goregaokar
c8cb90abbd Merge commit '3e4179766bcecd712824da04356621b8df012ea4' into sync-from-clippy 2021-02-02 20:43:30 -08:00
flip1995
ac912be984 Merge commit '95c0459217d1661edfa794c8bb122452b92fb485' into clippyup 2021-01-30 18:06:34 +01:00
flip1995
488153ff2f Merge commit '953f024793dab92745fee9cd2c4dee6a60451771' into clippyup 2021-01-15 10:56:44 +01:00
flip1995
ba4bf4f9c5 Merge commit '1fcc74cc9e03bc91eaa80ecf92976b0b14b3aeb6' into clippyup 2021-01-02 16:29:43 +01:00
flip1995
f03edfd7a1 Merge commit '4911ab124c481430672a3833b37075e6435ec34d' into clippyup 2020-12-20 17:19:49 +01:00
flip1995
8eca423ea1 Merge commit 'c1664c50b27a51f7a78c93ba65558e7c33eabee6' into clippyup 2020-12-06 15:01:03 +01:00
flip1995
03f04314dd clippy: Remove now obsolete lintlist module
Also stop updating the lintlist module in clippy_dev update_lints
2020-11-24 10:37:31 +01:00
flip1995
34244190d4 Merge commit 'b20d4c155d2fe3a8391f86dcf9a8c49e17188703' into clippyup 2020-11-05 14:29:48 +01:00
Eduardo Broto
cdb555f4fc Merge commit 'bf1c6f9871f430e284b17aa44059e0d0395e28a6' into clippyup 2020-10-23 22:16:59 +02:00
flip1995
fbf2430f02 Merge commit '2f6439ae6a6803d030cceb3ee14c9150e91b328b' into clippyup 2020-10-09 12:45:29 +02:00
flip1995
d1f9cad102 Merge commit 'e636b88aa180e8cab9e28802aac90adbc984234d' into clippyup 2020-09-24 14:49:22 +02:00
flip1995
282c59820b Merge commit '3d0b0e66afdfaa519d8855b338b35b4605775945' into clippyup 2020-08-28 18:43:25 +02:00
flip1995
027780ca2c Merge commit '09bd400243ed6f7059fedc0c1623aae3792521d6' into clippyup 2020-08-11 17:50:45 +02:00
Lzu Tao
8db24840f7 Merge commit 'ff0993c5e9162ddaea78e83d0f0161e68bd4ea73' into clippy 2020-06-09 14:36:01 +00:00
flip1995
a0e9f9bd0d Merge commit '7ea7cd165ad6705603852771bf82cc2fd6560db5' into clippyup2 2020-05-28 15:45:24 +02:00
Matthias Krüger
d021d3ef88 clippy_dev: make it fatal when the regex for updating lint count does not match
Fixes #5510
2020-04-23 16:11:11 +02:00
flip1995
d89bb50f72
Make lint modules private 2020-04-03 21:19:33 +02:00
flip1995
a186d9fafd
Don't filter lints in code generation functions 2020-04-03 21:19:32 +02:00
flip1995
98c30fea8c
Build lint lists once and the reuse them to update files 2020-04-03 21:19:32 +02:00
flip1995
da679825e0
Get rid of Lint::is_internal method 2020-04-03 21:19:32 +02:00
flip1995
ffb2e41234
Clean up update_lints 2020-04-03 21:18:36 +02:00
flip1995
3155eedb68
Don't use an exact lint counter anymore 2020-03-31 17:24:09 +02:00
flip1995
5de019074b
Move update_lints logic to its own module 2020-03-31 17:24:09 +02:00
flip1995
deb1979b8e
Make limit_stderr_length a subcommand 2020-03-31 17:24:09 +02:00
flip1995
8b9d70d349
Define modules in lib.rs instead of main.rs 2020-03-31 17:24:09 +02:00
Lzu Tao
53880a5bd6 Bump itertools 2020-03-29 12:50:11 +07:00
bors
e004b9431d Auto merge of #5329 - matthiaskrgr:int_arith_on_ref_5328, r=flip1995
integer_arithmetic: detect integer arithmetic on references.

changelog: integer_arithmetic fix false negatives with references on integers

Fixes #5328
2020-03-18 14:56:05 +00:00
flip1995
f041dcdb4e
Fix limit-stderr-files test 2020-03-18 15:27:25 +01:00
Matthias Krüger
7545925ffe new_lint.rs: encourage authors to write more detailed code samples in lint descriptions (linted as well as fixed code)
changelog: none
2020-03-18 01:43:39 +01:00
Yuki Okushi
4253aa7137 Rustup to rust-lang/rust#69592 2020-03-01 12:23:33 +09:00
flip1995
8472ecda0f
Fix fallout 2020-02-21 11:14:18 +01:00
flip1995
50a2f971fc
Adapt gen_lint_group_list test to also generate internal lints 2020-02-14 14:42:24 +01:00
flip1995
07026983f5
Rename lint_count -> usable_lint_count 2020-02-14 14:37:56 +01:00
flip1995
4a9bfe4184
Let update_lints also generate the internal lints 2020-02-14 14:37:56 +01:00
flip1995
3da2c9183a
Save Lint::module as full path of module 2020-02-14 14:37:56 +01:00
flip1995
560559bafe
Make Lint::by_lint_group take impl Iterator as argument 2020-02-14 14:37:55 +01:00
Krishna Sai Veera Reddy
6b4cae18dd Remove unnecessary imports from new_lint tool 2020-02-10 19:24:01 -08:00
Lzu Tao
cf58537bd6 dev: Move DOCS_LINK out of lazy_static and reuse it 2020-02-07 08:33:05 +07:00
Lzu Tao
344603afce dev: Make UpdateMode a copy type 2020-02-07 08:33:05 +07:00
Lzu Tao
729f943c53 dev: Prefer fs::read* and improvement to replace text region 2020-02-07 08:33:05 +07:00
Lzu Tao
8794e41728 dev: Use bytecount for faster line count 2020-02-06 21:39:15 +07:00
Yuki Okushi
7a36a8d98a Decrease line length limit for stderrs 2020-02-03 15:11:02 +09:00
bors
ca2abaf366 Auto merge of #5109 - phansch:ciao_util_dev, r=flip1995
Deprecate util/dev in favor of cargo alias

This means one less shell script and a bit more cross-platform support
for contributors.

If you've been using `./util/dev` before, this now becomes `cargo dev`.

The key part of this change is found in `.cargo/config` where an alias for calling the `clippy_dev` binary is defined.

changelog: none
2020-01-31 07:18:06 +00:00
Phil Hansch
8f457fa4c9
Mark clippy_project_root as must_use
Co-Authored-By: Philipp Krones <hello@philkrones.com>
2020-01-31 07:32:53 +01:00
Philipp Hansch
3f2532b904
Replace one more copy-pasted clippy_project_root fn 2020-01-31 07:30:44 +01:00
Philipp Hansch
3036a2c30e
Move project_root function to clippy_dev/src/lib.rs
This allows us to use the method in both `fmt.rs` and `lib.rs` in
multiple places. The downside is that we panic inside the method now,
instead of using the error handling in `fmt.rs`. We may want to
centralize the error handling for clippy_dev at some point, though.
2020-01-30 21:34:25 +01:00
Philipp Hansch
4d1a11d354
Deprecate util/dev in favor of cargo alias
If you've been using `./util/dev` before, this now becomes `cargo dev`.

The key part of this change is found in `.cargo/config`.

This means one less shell script and a bit more cross-platform support
for contributors.
2020-01-30 21:34:31 +01:00
Yuki Okushi
411317bd2c Decrease line length limit for stderr files 2020-01-30 12:08:38 +09:00
Yuki Okushi
c9d5cb9645 Decrease line length limit for stderr files 2020-01-21 06:43:01 +09:00
Krishna Sai Veera Reddy
9ebac161e4 Add lifetimes to LateLintPass 2020-01-16 10:05:29 -08:00
Krishna Sai Veera Reddy
2d352f42cc Fix rustc lint import paths generated by new_lint 2020-01-16 09:44:45 -08:00
Brad Sherman
ea82cbe790 Generate new lints easily
- Add option in clippy_dev to automatically generate boilerplate
  code for adding new lints
2020-01-15 21:20:50 -06:00
Lzu Tao
f5b896451a do minor cleanups
* ToString and AsRef are in prelude, no need to import them
2019-12-24 03:06:52 +07:00
Lzu Tao
185e608ae2 a few small cleanups 2019-12-23 05:28:23 +07:00
flip1995
d51a80c57e
Enable deny-warnings feature everywhere in CI 2019-11-25 17:23:48 +01:00
flip1995
b2616641d9
Fix dogfood findings 2019-10-24 14:39:19 +02:00
flip1995
ef02e3a755
Run ./util/dev fmt 2019-10-24 11:55:22 +02:00
Mark Rousskov
8c205018d2
Update clippy_dev 2019-10-24 11:47:00 +02:00
Andre Bogus
cc622608db new lints around #[must_use] fns
`must_use_unit` lints unit-returning functions with a `#[must_use]`
attribute, suggesting to remove it.

`double_must_use` lints functions with a plain `#[must_use]`
attribute, but which return a type which is already `#[must_use]`,
so the attribute has no benefit.

`must_use_candidate` is a pedantic lint that lints functions and
methods that return some non-unit type that is not already
`#[must_use]` and suggests to add the annotation.
2019-10-14 12:09:04 +02:00
bors
5cb983338e Auto merge of #4641 - sinkuu:revert_workaround, r=phansch
Revert "Workaround cargo bug on Windows"

[Cargo is fixed on rust master](https://github.com/rust-lang/rust/pull/65186). This reverts PR #4624.

Fixes #4638

changelog: none
2019-10-08 08:36:26 +00:00
bors
b690cdb1e7 Auto merge of #4611 - rust-lang:doc-visibility, r=flip1995
account for doc visibility

This fixes #4608.

Also I noticed that the lint failed to look at trait and impl items. There's a small bit of fallout in the code, too, but not enough to warrant its own commit.

changelog: check docs of trait items and impl items, also make `missing_safety_doc` account for visibility
2019-10-08 07:11:26 +00:00
Shotaro Yamada
d2daf8ecf6 Revert "Workaround cargo bug on Windows"
This reverts commit 248251b3b2.
This reverts commit 20b7351439.
2019-10-08 14:21:05 +09:00
Phil Hansch
8d2912ec00
Rollup merge of #4509 - sinkuu:redundant_clone_fix, r=llogiq
Fix false-positive of redundant_clone and move to clippy::perf

This PR introduces dataflow analysis to `redundant_clone` lint to filter out borrowed variables, which had been incorrectly detected.

Depends on https://github.com/rust-lang/rust/pull/64207.

changelog: Moved `redundant_clone` lint to `perf` group

# What this lint catches

## `clone`/`to_owned`

```rust
let s = String::new();
let t = s.clone();
```

```rust
// MIR
_1 = String::new();
_2 = &_1;
_3 = clone(_2); // (*)
```

We can turn this `clone` call into a move if

1. `_2` is the sole borrow of `_1` at the statement `(*)`
2. `_1` is not used hereafter

## `Deref` + type-specific `to_owned` method

```rust
let s = std::path::PathBuf::new();
let t = s.to_path_buf();
```

```rust
// MIR
_1 = PathBuf::new();
_2 = &1;
_3 = call deref(_2);
_4 = _3;                         // Copies borrow
StorageDead(_2);
_5 = Path::to_path_buf(_4); // (*)
```

We can turn this `to_path_buf` call into a move if

1. `_3` `_4` are the sole borrow of `_1` at `(*)`
2. `_1` is not used hereafter

# What this PR introduces

1. `MaybeStorageLive` that determines whether a local lives at a particular location
2. `PossibleBorrowerVisitor` that constructs [`TransitiveRelation`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/transitive_relation/struct.TransitiveRelation.html) of possible borrows, e.g. visiting `_2 = &1; _3 = &_2:` will result in `_3 -> _2 -> _1` relation. Then `_3` and `_2` will be counted as possible borrowers of `_1` in the sole-borrow analysis above.
2019-10-04 08:08:58 +02:00
Shotaro Yamada
248251b3b2 Use home::cargo_home 2019-10-04 11:11:40 +09:00
Shotaro Yamada
20b7351439 Workaround cargo bug on Windows 2019-10-04 10:38:52 +09:00
Shotaro Yamada
555f5a49a2 Test fixes 2019-10-03 08:10:29 +09:00
Andre Bogus
e3f143ff0a account for doc visibility 2019-10-02 21:15:28 +02:00
Lzu Tao
7065239da5 Add option_and_then_some lint 2019-08-19 03:54:40 +00:00
Philipp Hansch
5114050839
Update lint deprecation for tool lints
Our lint deprecation previously didn't work for tool lints, because
`register_removed` was registering lints to be removed _without_ the
`clippy` prefix.
2019-08-12 19:20:36 +02:00
Michael Wright
fd9c5a3c71 Merge branch 'master' into dev-fmt-20190728 2019-08-01 07:02:48 +02:00
Jakub Wieczorek
2a13e83f2b Update all the code to pass the updated use_self lint.
One struct required a temporary `#[allow(dead_code)]` annotation due to
a bug in the Rust compiler: https://github.com/rust-lang/rust/issues/63151.
2019-07-31 08:50:43 +00:00
Michael Wright
cc779c8050 dev-fmt: better error handling
Check if rustfmt is installed at the start and exit if it isn't.
2019-07-28 06:41:13 +02:00
Philipp Hansch
35b7a98f4f
Decrease maximum length for stderr files
Now at 275.
2019-07-17 21:13:33 +02:00
Michael Wright
2c90083f62 Avoid rustfmt bug on Windows 2019-07-11 05:21:44 +00:00
Michael Wright
11707f3443
Fix crash on dev --limit-stderr-length 2019-07-07 15:11:37 +02:00
Michael Wright
4c771c3478
Add dev fmt subcommand 2019-07-07 15:11:33 +02:00
flip1995
0e480ca4bc
Use replace_region_in_file for creating the lint list 2019-06-14 13:07:33 +02:00
Jane Lusby
a2bf96f1c6 make it pass dogfood 2019-06-12 12:29:37 -07:00
Jane Lusby
113ae891d9 run rustfmt 2019-06-12 12:29:37 -07:00
Jane Lusby
73259d68db fix padding and put clippy someplaces 2019-06-12 12:29:37 -07:00
Jane Lusby
cfd7e0d5fd show default lint levels 2019-06-12 12:29:37 -07:00
Jane Lusby
296794dec5 prelim arg parse 2019-06-12 12:29:37 -07:00
Jane Lusby
5abcff2be5 move Lint static def into its own module 2019-06-12 12:29:37 -07:00
Jane Lusby
f6367c41dc switch to sorted usable lints 2019-06-12 12:29:37 -07:00
Jane Lusby
44b849521e Update clippy_dev/src/main.rs
Co-Authored-By: Philipp Krones <hello@philkrones.com>
2019-06-12 12:29:37 -07:00
Jane Lusby
cf88c8487a initial commit for help improvements on clippy-driver 2019-06-12 12:29:37 -07:00
Lzu Tao
352f183429 Bump clap in clippy_dev 2019-06-03 09:36:23 +07:00
Philipp Hansch
619a2906f8
Collect at callsite, use eprintln instead of println 2019-05-17 07:41:25 +02:00
Philipp Hansch
d9a8a8a778
Add a stderr file length check to clippy_dev
This adds a check to `clippy_dev` that enforces a maximum line count for
`stderr` files. CI will fail if the line count is exceeded. It's
currently set to `320` lines.

Ideally this would be implemented in `compiletest-rs` but there are
plans to move Rust's `compiletest` into the `compiletest-rs` repository
and I don't want to do the work in `compiletest` twice. However, I also
don't want to wait until the move is done, so I added the check to
`clippy_dev` until it makes sense to add it to compiletest-rs.

cc #2038
2019-05-16 21:18:32 +02:00
flip1995
118f7d54c4
Remove rust-toolchain file from clippy_dev 2019-04-16 17:17:07 +02:00
flip1995
5361b842d1
Remove clippy::default_hash_types internal lint 2019-04-15 13:21:52 +02:00
Michael Wright
ecc5c0a57d Add rust-toolchain for clippy_dev 2019-03-15 08:17:44 +02:00
Alexander Regueiro
d43966a176 Various cosmetic improvements. 2019-03-10 18:06:28 +00:00
Michael Wright
acd6d4d094 Improve Clippy dev help
+ Print help if no subcommand is supplied
+ Make a short version of `update_lints` help for the subcommand listing
2019-03-08 07:45:31 +02:00
Andy Russell
fe96ffeac9
move lint documentation into macro invocations 2019-03-05 18:45:08 -05:00
Grzegorz
16881390e1 removing redundant closures in the whole project 2019-02-10 13:35:44 +01:00
Matthias Krüger
873fe11ca5 dependencies: update itertools from 0.7 to 0.8 2019-01-25 20:25:14 +01:00