Michael Wright [Thu, 31 Jan 2019 04:20:49 +0000 (06:20 +0200)]
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.
bors [Tue, 29 Jan 2019 22:48:03 +0000 (22:48 +0000)]
Auto merge of #3652 - Aehmlo:where_the_wild_things_are, r=phansch
Add wildcard_match_arm lint
This lint prevents using a wildcard in a match arm. Implemented as a restriction currently, because this is pretty much an edge case. See #3649 for more information.
Didn't add any tests because I wasn't sure how, but if someone wants to point me in the right direction, I'd be happy to!
bors [Mon, 28 Jan 2019 14:30:18 +0000 (14:30 +0000)]
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.
bors [Sun, 27 Jan 2019 13:34:47 +0000 (13:34 +0000)]
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]`.
Philipp Hansch [Sat, 26 Jan 2019 08:49:55 +0000 (09:49 +0100)]
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.
bors [Sat, 26 Jan 2019 09:56:07 +0000 (09:56 +0000)]
Auto merge of #3701 - mikerite:fix-3118, r=phansch
Fix dogfood tests on Appveyor
This introduces a work-around for a bug in rustup.rs when excuting
cargo from a custom toolchain. Instead of trusting rustup to
invoke cargo from one of the release channels we just invoke
nightly cargo directly.
Michael Wright [Sat, 26 Jan 2019 09:10:13 +0000 (11:10 +0200)]
Fix dogfood tests on Appveyor
This introduces a work-around for a bug in rustup.rs when excuting
cargo from a custom toolchain. Instead of trusting rustup to
invoke cargo from one of the release channels we just invoke
nightly cargo directly.
bors [Fri, 25 Jan 2019 17:47:54 +0000 (17:47 +0000)]
Auto merge of #3691 - phansch:update_changelog, r=oli-obk
Update changelog with all changes since 0.0.212
This updates the changelog with all notable and user-facing changes since
0.0.212 has been released. I decided to group the changes by the Rust version
they are included in, as that's what makes the most sense to users.
Whenever a new rust version is released, we will have to go through the list
of commits and then update the changelog with the relevant changes.
A.A.Abroskin [Wed, 23 Jan 2019 08:36:12 +0000 (11:36 +0300)]
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
...
bors [Tue, 22 Jan 2019 19:18:39 +0000 (19:18 +0000)]
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:
- https://github.com/rust-lang/rust-clippy/blob/e648adf0866a1cea7db6ce2d33ea86e442f25377/clippy_lints/src/use_self.rs#L94-L96
- https://github.com/rust-lang/rust-clippy/blob/e648adf0866a1cea7db6ce2d33ea86e442f25377/clippy_lints/src/use_self.rs#L225-L229
bors [Sat, 19 Jan 2019 12:40:46 +0000 (12:40 +0000)]
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))`
|
```