bors [Mon, 4 Feb 2019 05:52:44 +0000 (05:52 +0000)]
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.
bors [Sun, 3 Feb 2019 13:03:41 +0000 (13:03 +0000)]
Auto merge of #3723 - rhysd:issue3721, r=oli-obk
Implement dbg_macro rule
Fixes #3721
This patch adds new `dbg_macro` rule to check `dbg!` macro use.
Since this is my first patch to clippy, I'm not confident about following points:
- ~~Currently only checks `dbg!` span. Is it possible to check if the `dbg!` macro is provided by standard library or user-defined? If it's possible, I can make the check more strict.~~ Resolved as https://github.com/rust-lang/rust-clippy/pull/3723#discussion_r252417934
- ~~Is category `style` correct for this rule?~~'restriction' is used instead
- ~~Should I use `span_lint_and_sugg` instead of `span_lint`? Currently entire message is put as `msg`. But later part `ensure to avoid having uses of it in version control` may be put as suggestion.~~ Done
- I'm not native English speaker. The message and doc may not be natural as English.
bors [Sun, 3 Feb 2019 08:42:14 +0000 (08:42 +0000)]
Auto merge of #3736 - mikerite:fix-build-20190203, r=phansch
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.
Michael Wright [Sun, 3 Feb 2019 07:12:07 +0000 (09:12 +0200)]
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.
bors [Sat, 2 Feb 2019 08:32:27 +0000 (08:32 +0000)]
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.
bors [Sat, 2 Feb 2019 00:12:32 +0000 (00:12 +0000)]
Auto merge of #3731 - phansch:travis, r=phansch
Travis: Don't run integration tests on every PR commit
This does not save Clippy any time but it makes sure that the concurrent
build limit is not reached as quickly for the `rust-lang` Travis
account.
I can't create a permalink to the discussion somehow, so here's an
excerpt from the Infra channel:
```
[11:57 PM] pietroalbini: there is a clippy build (20 jobs) and a packed_simd one (42 builders) and a rustc one which isn't scheduling atm
[11:58 PM] pietroalbini: I don't think there is a way to prioritize rustc builds in the queue on travis, right?
[12:22 AM] alexcrichton: pietro: I don't think so no
[12:22 AM] alexcrichton: If it's a problem we should cull builds on other projects
[12:22 AM] alexcrichton: The rust repo is the #1 priority
```
Since the integration tests are rarely failing these days, I think it's
fine to not run them on every commit.
If needed, it's also still possible to do a complete test run with `@bors try`.
bors [Fri, 1 Feb 2019 08:36:11 +0000 (08:36 +0000)]
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].
Philipp Hansch [Fri, 1 Feb 2019 06:34:36 +0000 (07:34 +0100)]
Travis: Don't run integration tests on every PR commit
This does not save Clippy any time but it makes sure that the concurrent
build limit is not reached as quickly for the `rust-lang` Travis
account.
I can't create a permalink to the discussion somehow, so here's an
excerpt from the Infra channel:
```
[11:57 PM] pietroalbini: there is a clippy build (20 jobs) and a packed_simd one (42 builders) and a rustc one which isn't scheduling atm
[11:58 PM] pietroalbini: I don't think there is a way to prioritize rustc builds in the queue on travis, right?
[12:22 AM] alexcrichton: pietro: I don't think so no
[12:22 AM] alexcrichton: If it's a problem we should cull builds on other projects
[12:22 AM] alexcrichton: The rust repo is the #1 priority
```
Since the integration tests are rarely failing these days, I think it's
fine to not run them on every commit.
If needed, it's also still possible to do a `try` build with `@bors try`.
Philipp Hansch [Thu, 31 Jan 2019 06:11:22 +0000 (07:11 +0100)]
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].
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]`.