]>
git.lizzy.rs Git - rust.git/log
Philipp Hansch [Thu, 23 Apr 2020 06:12:03 +0000 (08:12 +0200)]
cargo dev fmt
Philipp Hansch [Thu, 23 Apr 2020 06:09:42 +0000 (08:09 +0200)]
More diagnostic items
In particular for:
* `VecDeque`
* `String`
* `Mutex`
* `HashMap`
* `HashSet`
cc https://github.com/rust-lang/rust/pull/71414 https://github.com/rust-lang/rust-clippy/issues/5393
bors [Sun, 26 Apr 2020 11:26:15 +0000 (11:26 +0000)]
Auto merge of #5533 - phansch:rustup001, r=matthiaskrgr
rustup to https://github.com/rust-lang/rust/pull/70043
changelog: none
Philipp Hansch [Sun, 26 Apr 2020 08:12:14 +0000 (10:12 +0200)]
rustup to https://github.com/rust-lang/rust/pull/70043
bors [Sat, 25 Apr 2020 21:41:56 +0000 (21:41 +0000)]
Auto merge of #5511 - alex-700:fix-redundant-pattern-matching, r=flip1995
Fix redundant_pattern_matching lint
fixes #5504
changelog: Fix suggestion in `redundant_pattern_matching` for macros.
bors [Sat, 25 Apr 2020 21:29:03 +0000 (21:29 +0000)]
Auto merge of #5525 - flip1995:issue_1654, r=phansch
Don't trigger while_let_on_iterator when the iterator is recreated every iteration
r? @phansch
Fixes #1654
changelog: Fix false positive in [`while_let_on_iterator`]
bors [Sat, 25 Apr 2020 21:16:06 +0000 (21:16 +0000)]
Auto merge of #5530 - ebroto:issue_5524, r=flip1995
map_clone: avoid suggesting `copied()` for &mut
changelog: map_clone: avoid suggesting `copied()` for &mut
Fixes #5524
Eduardo Broto [Sat, 25 Apr 2020 20:49:06 +0000 (22:49 +0200)]
map_clone: avoid suggesting `copied()` for &mut
Aleksei Latyshev [Thu, 23 Apr 2020 08:40:16 +0000 (11:40 +0300)]
fix redundant_pattern_matching lint
- now it gives correct suggestion in case of macros
- better tests
- remove a couple of non-relevant tests
bors [Sat, 25 Apr 2020 19:38:04 +0000 (19:38 +0000)]
Auto merge of #5527 - flip1995:rollup-pr2htfd, r=flip1995
Rollup of 5 pull requests
Successful merges:
- #5408 (Downgrade match_bool to pedantic)
- #5505 (Avoid running cargo+internal lints when not enabled)
- #5516 (Add a note to the beta sections of release.md)
- #5517 (Deploy time travel)
- #5523 (Add lifetime test case for `new_ret_no_self`)
Failed merges:
r? @ghost
changelog: rollup
Philipp Krones [Sat, 25 Apr 2020 19:06:31 +0000 (21:06 +0200)]
Rollup merge of #5523 - phansch:add-new-ret-no-self-testcase, r=flip1995
Add lifetime test case for `new_ret_no_self`
cc https://github.com/rust-lang/rust-clippy/issues/734#issuecomment-
619344352
changelog: none
Philipp Krones [Sat, 25 Apr 2020 19:06:30 +0000 (21:06 +0200)]
Rollup merge of #5517 - flip1995:deploy_time_travel, r=Manishearth
Deploy time travel
Since not only commits to the master branch, but also tags and the beta branch are deployed, we have to be cautious which version of the deploy script is used. GHA always runs the workflow that is commited on the `ref`, that gets tested. For tagged commits. this is 6 weeks outdated workflows/scripts. To prevent this, this workflow first checks out the deploy.sh script, the website templates and all python scripts generating files for the website.
changelog: none
Philipp Krones [Sat, 25 Apr 2020 19:06:28 +0000 (21:06 +0200)]
Rollup merge of #5516 - flip1995:doc_release, r=phansch
Add a note to the beta sections of release.md
changelog: none
Philipp Krones [Sat, 25 Apr 2020 19:06:27 +0000 (21:06 +0200)]
Rollup merge of #5505 - flip1995:avoid_running_lints, r=matthiaskrgr
Avoid running cargo+internal lints when not enabled
r? @matthiaskrgr
changelog: none
Philipp Krones [Sat, 25 Apr 2020 19:06:26 +0000 (21:06 +0200)]
Rollup merge of #5408 - dtolnay:matchbool, r=flip1995
Downgrade match_bool to pedantic
I don't quite buy the justification in https://rust-lang.github.io/rust-clippy/. The justification is:
> It makes the code less readable.
In the Rust codebases I've worked in, I have found people were comfortable using `match bool` (selectively) to make code more readable. For example, initializing struct fields is a place where the indentation of `match` can work better than the indentation of `if`:
```rust
let _ = Struct {
v: {
...
},
w: match doing_w {
true => ...,
false => ...,
},
x: Nested {
c: ...,
b: ...,
a: ...,
},
y: if doing_y {
...
} else { // :(
...
},
z: ...,
};
```
Or sometimes people prefer something a bit less pithy than `if` when the meaning of the bool doesn't read off clearly from the condition:
```rust
if set.insert(...) {
... // ???
} else {
...
}
match set.insert(...) {
// set.insert returns false if already present
false => ...,
true => ...,
}
```
Or `match` can be a better fit when the bool is playing the role more of a value than a branch condition:
```rust
impl ErrorCodes {
pub fn from(b: bool) -> Self {
match b {
true => ErrorCodes::Yes,
false => ErrorCodes::No,
}
}
}
```
And then there's plain old it's-1-line-shorter, which means we get 25% more content on a screen when stacking a sequence of conditions:
```rust
let old_noun = match old_binding.is_import() {
true => "import",
false => "definition",
};
let new_participle = match new_binding.is_import() {
true => "imported",
false => "defined",
};
```
Bottom line is I think this lint fits the bill better as a pedantic lint; I don't think linting on this by default is justified.
changelog: Remove match_bool from default set of enabled lints
flip1995 [Sat, 25 Apr 2020 18:51:23 +0000 (20:51 +0200)]
Add tests for #1654
flip1995 [Sat, 25 Apr 2020 18:51:02 +0000 (20:51 +0200)]
Don't trigger while_let_on_iterator when the iterator is recreated every iteration
bors [Sat, 25 Apr 2020 18:18:32 +0000 (18:18 +0000)]
Auto merge of #5520 - matthiaskrgr:rustup_44, r=flip1995,phansch
rustup https://github.com/rust-lang/rust/pull/71215/
There's currently an crash in `ui/new_without_default.rs` that I need to figure out how to avoid.
changelog: none
flip1995 [Sat, 25 Apr 2020 18:07:55 +0000 (20:07 +0200)]
Update issue_2356.stderr reference file
flip1995 [Sat, 25 Apr 2020 18:01:22 +0000 (20:01 +0200)]
Update while_let_on_iterator tests
flip1995 [Sat, 25 Apr 2020 18:00:00 +0000 (20:00 +0200)]
Fix while_let_on_iterator suggestion and make it MachineApplicable
Philipp Hansch [Sat, 25 Apr 2020 08:43:41 +0000 (10:43 +0200)]
Add lifetime test case for `new_ret_no_self`
Matthias Krüger [Fri, 24 Apr 2020 09:57:34 +0000 (11:57 +0200)]
rustup https://github.com/rust-lang/rust/pull/71215/
David Tolnay [Fri, 3 Apr 2020 00:36:49 +0000 (17:36 -0700)]
Downgrade match_bool to pedantic
flip1995 [Thu, 23 Apr 2020 21:24:58 +0000 (23:24 +0200)]
Run fetch before testing if master contains beta
flip1995 [Thu, 23 Apr 2020 18:34:30 +0000 (20:34 +0200)]
The beta branch update should not require a force push
flip1995 [Thu, 23 Apr 2020 18:14:06 +0000 (20:14 +0200)]
Add a note to the beta sections of release.md
bors [Thu, 23 Apr 2020 20:56:15 +0000 (20:56 +0000)]
Auto merge of #5513 - matthiaskrgr:reg, r=phansch
fix clippy_dev exit status and make regex match again
changelog: none
Fixes #5510
r? @phansch
flip1995 [Thu, 23 Apr 2020 18:45:39 +0000 (20:45 +0200)]
Remove apt-get upgrade again
flip1995 [Thu, 23 Apr 2020 18:44:18 +0000 (20:44 +0200)]
Always use the deploy script and templates of the master branch
bors [Thu, 23 Apr 2020 18:35:22 +0000 (18:35 +0000)]
Auto merge of #5498 - phansch:update_changelog, r=flip1995
Update CHANGELOG.md for Rust 1.43 and 1.44
[Rendered](https://github.com/phansch/rust-clippy/blob/update_changelog/CHANGELOG.md)
changelog: none
Matthias Krüger [Thu, 23 Apr 2020 14:08:40 +0000 (16:08 +0200)]
README: fix lit count line
It looks like after changing to "there are more than 120 lints", an older PR was merged
and resolving merge conflicts this was changed back to "there are 123 lints" causing the update-script to silently fail.
Changed back the README.md back to the new format fixes the problem.
Matthias Krüger [Thu, 23 Apr 2020 13:51:03 +0000 (15:51 +0200)]
clippy_dev: make it fatal when the regex for updating lint count does not match
Fixes #5510
bors [Thu, 23 Apr 2020 05:08:29 +0000 (05:08 +0000)]
Auto merge of #5508 - lzutao:rustup-71044, r=phansch
Rustup "Remove `BodyAndCache`"
cc https://github.com/rust-lang/rust/pull/71044
changelog: none
lzutao [Thu, 23 Apr 2020 02:02:26 +0000 (09:02 +0700)]
`predecessors_for` will be removed soon
Co-Authored-By: ecstatic-morse <ecstaticmorse@gmail.com>
Lzu Tao [Thu, 23 Apr 2020 01:39:35 +0000 (08:39 +0700)]
Rustup "Remove `BodyAndCache`"
flip1995 [Wed, 22 Apr 2020 18:51:58 +0000 (20:51 +0200)]
Only run (late) internal lints, when they are warn/deny/forbid
flip1995 [Tue, 21 Apr 2020 20:53:18 +0000 (22:53 +0200)]
Only run cargo lints, when they are warn/deny/forbid
bors [Wed, 22 Apr 2020 15:50:32 +0000 (15:50 +0000)]
Auto merge of #5439 - rokob:lock-await, r=Manishearth
Lint for holding locks across await points
Fixes #4226
This introduces the lint await_holding_lock. For async functions, we iterate
over all types in generator_interior_types and look for types named MutexGuard,
RwLockReadGuard, or RwLockWriteGuard. If we find one then we emit a lint.
changelog: introduce the await_holding_lock lint
Andy Weiss [Wed, 22 Apr 2020 04:28:23 +0000 (21:28 -0700)]
span_lint_and_note now takes an Option<Span> for the note_span instead of just a span
Andy Weiss [Fri, 17 Apr 2020 06:21:49 +0000 (23:21 -0700)]
Make lint also capture blocks and closures, adjust language to mention other mutex types
Andy Weiss [Fri, 10 Apr 2020 05:12:34 +0000 (22:12 -0700)]
don't test the code in the lint docs
Andy Weiss [Fri, 10 Apr 2020 04:50:23 +0000 (21:50 -0700)]
Switch to matching against full paths instead of just the last element of the path
Andy Weiss [Wed, 8 Apr 2020 04:20:37 +0000 (21:20 -0700)]
Lint for holding locks across await points
Fixes #4226
This introduces the lint await_holding_lock. For async functions, we iterate
over all types in generator_interior_types and look for types named MutexGuard,
RwLockReadGuard, or RwLockWriteGuard. If we find one then we emit a lint.
Philipp Hansch [Tue, 21 Apr 2020 05:06:44 +0000 (07:06 +0200)]
Also mention `--fix` for nightly users
bors [Mon, 20 Apr 2020 23:54:15 +0000 (23:54 +0000)]
Auto merge of #5499 - matthiaskrgr:crash_5497, r=flip1995
fix crash on issue-69020-assoc-const-arith-overflow.rs
Fixes #5497
changelog: fix crash on rustc test issue-69020-assoc-const-arith-overflow.rs
Matthias Krüger [Mon, 20 Apr 2020 21:00:01 +0000 (23:00 +0200)]
fix crash on issue-69020-assoc-const-arith-overflow.rs
Fixes #5497
bors [Mon, 20 Apr 2020 21:00:25 +0000 (21:00 +0000)]
Auto merge of #5496 - phansch:markdown-link, r=flip1995
util/fetch_prs_between.sh: Add Markdown formatted link
This can then be easily copy/pasted into the changelog :blue_heart:
changelog: none
Philipp Hansch [Mon, 20 Apr 2020 20:53:00 +0000 (22:53 +0200)]
Address review comments
bors [Mon, 20 Apr 2020 20:40:45 +0000 (20:40 +0000)]
Auto merge of #5495 - phansch:update_changelog_docs, r=flip1995
Update the changelog update documentation
I just started working on updating the changelog. Hopefully the docs are a bit clearer now?
r? @flip1995
changelog: none
Philipp Hansch [Mon, 20 Apr 2020 20:29:27 +0000 (22:29 +0200)]
remark fixes
Philipp Hansch [Mon, 20 Apr 2020 20:22:05 +0000 (22:22 +0200)]
Update CHANGELOG.md for Rust 1.43 and 1.44
bors [Mon, 20 Apr 2020 20:21:33 +0000 (20:21 +0000)]
Auto merge of #5332 - DevinR528:if-let-else-mutex, r=flip1995
If let else mutex
changelog: Adds lint to catch incorrect use of `Mutex::lock` in `if let` expressions with lock calls in any of the blocks.
closes: #5219
Devin R [Mon, 20 Apr 2020 19:47:08 +0000 (15:47 -0400)]
update stderr file
Philipp Hansch [Mon, 20 Apr 2020 19:08:55 +0000 (21:08 +0200)]
util/fetch_prs_between.sh: Add Markdown formatted Link
This can then be easily copy/pasted into the changelog :blue_heart:
Devin R [Mon, 20 Apr 2020 19:08:44 +0000 (15:08 -0400)]
factor ifs into function, add differing mutex test
Philipp Hansch [Mon, 20 Apr 2020 18:39:49 +0000 (20:39 +0200)]
Update the changelog update documentation
bors [Mon, 20 Apr 2020 18:29:00 +0000 (18:29 +0000)]
Auto merge of #5493 - ebroto:unsafe_derive_deserialize, r=flip1995
Implement unsafe_derive_deserialize lint
Added `unsafe_derive_deserialize` lint to check for cases when automatically deriving `serde::Deserialize` can be problematic, i.e. with types that have methods using `unsafe`.
Closes #5471
changelog: Add lint [`unsafe_derive_deserialize`]
Eduardo Broto [Mon, 20 Apr 2020 18:05:15 +0000 (20:05 +0200)]
Apply suggestions from PR review
* Move the lint to pedantic
* Import used types instead of prefixing with `hir::`
Devin R [Mon, 20 Apr 2020 10:49:59 +0000 (06:49 -0400)]
update span_lint_and_help call to six args
Devin R [Wed, 15 Apr 2020 21:08:26 +0000 (17:08 -0400)]
test for mutex eq, add another test case
Devin R [Wed, 15 Apr 2020 20:22:28 +0000 (16:22 -0400)]
use if chain
Devin R [Mon, 30 Mar 2020 18:53:27 +0000 (14:53 -0400)]
cargo dev fmt
Devin R [Mon, 30 Mar 2020 18:39:27 +0000 (14:39 -0400)]
fix map import to rustc_middle
Devin R [Tue, 24 Mar 2020 02:20:51 +0000 (22:20 -0400)]
dev update_lints
Devin R [Wed, 18 Mar 2020 23:53:22 +0000 (19:53 -0400)]
fix internal clippy warnings
Devin R [Wed, 18 Mar 2020 22:33:59 +0000 (18:33 -0400)]
change visitor name to OppVisitor
Devin R [Wed, 18 Mar 2020 22:13:06 +0000 (18:13 -0400)]
use Visitor api to find Mutex::lock calls
Devin R [Wed, 18 Mar 2020 19:28:57 +0000 (15:28 -0400)]
add note about update-all-refs script, revert redundant pat to master
Devin R [Wed, 18 Mar 2020 19:20:01 +0000 (15:20 -0400)]
move closures to seperate fns, remove known problems
Devin R [Wed, 18 Mar 2020 01:51:43 +0000 (21:51 -0400)]
use span_lint_and_help, cargo dev fmt
Devin R [Thu, 5 Mar 2020 23:02:22 +0000 (18:02 -0500)]
creating suggestion
Devin R [Thu, 5 Mar 2020 13:36:19 +0000 (08:36 -0500)]
progress work on suggestion for auto fix
Eduardo Broto [Sun, 19 Apr 2020 21:11:30 +0000 (23:11 +0200)]
Implement unsafe_derive_deserialize lint
bors [Sun, 19 Apr 2020 19:19:54 +0000 (19:19 +0000)]
Auto merge of #5141 - xiongmao86:issue5095, r=flip1995
Fixes issue 5095
fixes #5095.
- [x] Followed [lint naming conventions][lint_naming]
- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Executed `cargo dev update_lints`
- [x] Added lint documentation
- [x] Run `cargo dev fmt`
[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints
changelog: (internal) warn about collapsible `span_lint_and_then` calls.
flip1995 [Sun, 19 Apr 2020 19:00:25 +0000 (21:00 +0200)]
Update empty_enum.stderr
bors [Sun, 19 Apr 2020 18:59:23 +0000 (18:59 +0000)]
Auto merge of #5491 - smklein:borrowed_box, r=flip1995
Fix issue #2907.
Update the "borrow box" lint to avoid recommending the following
conversion:
```
// Old
pub fn f(&mut Box<T>) {...}
// New
pub fn f(&mut T) {...}
```
Given a mutable reference to a box, functions may want to change
"which" object the Box is pointing at.
This change avoids recommending removing the "Box" parameter
for mutable references.
changelog: Don't trigger [`borrow_box`] lint on `&mut Box` references
Philipp Krones [Sun, 19 Apr 2020 18:40:25 +0000 (20:40 +0200)]
Formatting and naming
Philipp Krones [Sun, 19 Apr 2020 18:38:07 +0000 (20:38 +0200)]
Formatting and naming
bors [Sun, 19 Apr 2020 18:09:34 +0000 (18:09 +0000)]
Auto merge of #5489 - phansch:node-id-hir-id, r=flip1995
Cleanup: `node_id` -> `hir_id`
This removes some more `node_id` terminology from Clippy and replaces one occurrence of `as_local_node_id` with `as_local_hir_id`, which should be doing the same for that particular case.
changelog: none
bors [Sun, 19 Apr 2020 17:50:33 +0000 (17:50 +0000)]
Auto merge of #5488 - phansch:future-not-send-ret-ty, r=flip1995
Cleanup: future_not_send: use `utils::return_ty` function
changelog: none
bors [Sun, 19 Apr 2020 17:25:40 +0000 (17:25 +0000)]
Auto merge of #5490 - sinkuu:toplevel_ref_arg_for, r=phansch
Don't trigger toplevel_ref_arg for `for` loops
The lint suggests turning `for ref x in 0..10 {` into `for ref x in let x = &0..10; {`.
---
changelog: none
Philipp Hansch [Sun, 19 Apr 2020 12:19:11 +0000 (14:19 +0200)]
Cleanup: `node_id` -> `hir_id`
Sean Klein [Sun, 19 Apr 2020 14:49:12 +0000 (10:49 -0400)]
Fix issue #2907.
Update the "borrow box" lint to avoid recommending the following
conversion:
```
// Old
pub fn f(&mut Box<T>) {...}
// New
pub fn f(&mut T) {...}
```
Given a mutable reference to a box, functions may want to change
"which" object the Box is pointing at.
This change avoids recommending removing the "Box" parameter
for mutable references.
Shotaro Yamada [Sun, 19 Apr 2020 13:56:47 +0000 (22:56 +0900)]
Don't trigger toplevel_ref_arg for `for` loops
Philipp Hansch [Sun, 19 Apr 2020 12:00:03 +0000 (14:00 +0200)]
Cleanup: future_not_send: use `return_ty` method
bors [Sat, 18 Apr 2020 20:03:54 +0000 (20:03 +0000)]
Auto merge of #5486 - flip1995:badge_over, r=flip1995
Remove badge FIXME from Cargo.toml
cc https://github.com/rust-lang/crates.io/issues/2436
changelog: none
flip1995 [Sat, 18 Apr 2020 20:02:14 +0000 (22:02 +0200)]
Remove badge FIXME from Cargo.toml
xiongmao86 [Sat, 18 Apr 2020 10:29:36 +0000 (18:29 +0800)]
Change note_span argument for span_lint_and_note.
xiongmao86 [Sat, 18 Apr 2020 10:28:29 +0000 (18:28 +0800)]
Add an Option<Span> argument to span_lint_and_help.
xiongmao86 [Fri, 17 Apr 2020 14:01:25 +0000 (22:01 +0800)]
Fixes internal lint warning in code base.
xiongmao86 [Fri, 17 Apr 2020 12:43:37 +0000 (20:43 +0800)]
Implement collapsible_span_lint_calls lint.
bors [Sat, 18 Apr 2020 09:05:41 +0000 (09:05 +0000)]
Auto merge of #5427 - pmk21:implicit-sat-sub, r=flip1995
Add lint named implicit_saturating_sub
Fixes: #5399
I've made a basic skeleton of the lint, would love more feedback on how to make it better.
changelog: Add lint [`implicit_saturating_sub`]
pmk21 [Fri, 17 Apr 2020 19:46:32 +0000 (01:16 +0530)]
Polished lint and tests
pmk21 [Mon, 6 Apr 2020 18:10:41 +0000 (23:40 +0530)]
Added final lint and tests
pmk21 [Mon, 6 Apr 2020 18:07:57 +0000 (23:37 +0530)]
Added basic lint and tests
bors [Fri, 17 Apr 2020 19:29:17 +0000 (19:29 +0000)]
Auto merge of #5483 - alex-700:fix-redundant-pattern-matching, r=flip1995
fix redundant_pattern_matching lint
- now it handles `while let` case (related to #5462)
- better suggestions in `if let` case
changelog: Fix suggestion in `redundant_pattern_matching` and also apply this lint to the `while let` case
Aleksei Latyshev [Fri, 17 Apr 2020 10:53:13 +0000 (13:53 +0300)]
fix redundant_pattern_matching lint
- now it handles `while let` case
- better suggestions in `if let` case
bors [Fri, 17 Apr 2020 16:04:14 +0000 (16:04 +0000)]
Auto merge of #5423 - rkuhn:add_futures_not_send, r=flip1995
add lint futures_not_send
changelog: add lint futures_not_send
fixes #5379
~Remark: one thing that can (should?) still be improved is to directly include the error message from the `Send` check so that the programmer stays in the flow. Currently, getting the actual error message requires a restructuring of the code to make the `Send` constraint explicit.~
It now shows all unmet constraints for allowing the Future to be Send.
bors [Fri, 17 Apr 2020 14:15:28 +0000 (14:15 +0000)]
Auto merge of #5445 - logan-dev-oss:master, r=flip1995
Fixes issue #4892.
First contribution here 😊 ! Do not hesitate to correct me.
This PR is related to issue #4892 .
# Summary
```rust
-literal.method_call(args)
```
The main idea is to not trigger `clippy::precedence` when the method call is an odd function.
# Example
```rust
// should trigger lint
let _ = -1.0_f64.abs() //precedence of method call abs() and neg ('-') is ambiguous
// should not trigger lint
let _ = -1.0_f64.sin() // sin is an odd function => -sin(x) = sin(-x)
```
# Theory
Rust allows following literals:
- char
- string
- integers
- floats
- byte
- bool
Only integers/floats implements the relevant `std::ops::Neg`.
Following odd functions are implemented on i[8-128] and/or f[32-64]:
- `asin`
- `asinh`
- `atan`
- `atanh`
- `cbrt`
- `fract`
- `round`
- `signum`
- `sin`
- `sinh`
- `tan`
- `tanh `
- `to_degrees`
- `to_radians`
# Implementation
As suggested by `flip1995` in [comment](https://github.com/rust-lang/rust-clippy/issues/4892#issuecomment-
568249683 ), this PR add a whitelist of odd functions and compare method call to the the whitelist before triggering lint.
changelog: Don't trigger [`clippy::precedence`] on odd functions.