Commit Graph

5483 Commits

Author SHA1 Message Date
bors
4259377ea6 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.

Fixes #2728
2019-02-04 05:52:44 +00:00
Michael Wright
f3ee53d225 Document get_def_path 2019-02-04 07:30:24 +02:00
Manish Goregaokar
7bea43614c
Merge pull request #3735 from jsgf/setup-toolchain
Add setup-toolchain.sh script to configure the master version of rustc,
2019-02-03 21:14:07 -08:00
Jeremy Fitzhardinge
47563a13eb Add setup-toolchain.sh script to configure the master version of rustc,
and update CONTRIBUTING.md accordingly.
2019-02-03 14:41:46 -08:00
bors
69a7f03185 Auto merge of #3737 - phansch:2018, r=phansch
Transition leftover test libs to Rust 2018

To tick off some checkboxes in https://github.com/rust-lang/rust/issues/58099 =)
2019-02-03 15:24:54 +00:00
Philipp Hansch
64ff65990f
Transition leftover test libs to Rust 2018 2019-02-03 14:47:03 +01:00
bors
273b7f7f46 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.
2019-02-03 13:03:41 +00:00
rhysd
83d620b824 run util/dev update_lints and cargo fmt --all 2019-02-03 21:56:24 +09:00
rhysd
4b736ff29b Merge branch 'master' into issue3721 2019-02-03 21:27:23 +09:00
rhysd
60f723fba4 prefer if to match 2019-02-03 18:50:00 +09:00
rhysd
3100fecb99 use snippet for making a suggestion if possible 2019-02-03 18:28:42 +09:00
bors
3bda548f81 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.
2019-02-03 08:42:14 +00:00
Michael Wright
c02367c4e9 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.
2019-02-03 09:12:07 +02:00
bors
27b5dd8886 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.
2019-02-02 08:32:27 +00:00
bors
9f88641450 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`.
2019-02-02 00:12:32 +00:00
bors
2972d54602 Auto merge of #3732 - phansch:fix_ice_3720, r=oli-obk
Fix ICE in vec_box lint and add run-rustfix

Includes https://github.com/rust-lang/rust-clippy/pull/3726

`hir::Ty` doesn't seem to know anything about type bounds and
`cx.tcx.type_of(def_id)` caused an ICE when it was passed a generic type
with a bound:

```
src/librustc_typeck/collect.rs:1311: unexpected non-type Node::GenericParam: Type { default: None, synthetic: None }
```

Converting it to a proper `Ty` fixes the ICE and catches a few more places
where the lint applies.

Fixes #3720
2019-02-01 23:49:46 +00:00
rhysd
54d49af3ff add more test cases for dbg_macro rule 2019-02-02 04:54:51 +09:00
Philipp Hansch
ac9472d16e
Update clippy_lints/src/types.rs
Co-Authored-By: avborhanian <avborhanian@gmail.com>
2019-02-01 14:53:15 -05:00
Philipp Hansch
a022d47a6b
Update clippy_lints/src/types.rs
Co-Authored-By: avborhanian <avborhanian@gmail.com>
2019-02-01 14:52:56 -05:00
rhysd
268ff85326 use span_help_and_lint() instead of span_lint_and_sugg() 2019-02-02 04:52:21 +09:00
Unknown
6e35b33bc3 Updating code to ignore rustfmt issue. 2019-02-01 13:21:19 -05:00
Unknown
a35083f2e6 Updated readme. 2019-02-01 13:21:19 -05:00
Unknown
93a856e9d5 Changing single character string to a character match. 2019-02-01 13:21:19 -05:00
Unknown
21e2b13125 Fix test broken by removing comment. 2019-02-01 13:21:19 -05:00
Unknown
ae3bcb770e Updating to just warn for one test. 2019-02-01 13:21:19 -05:00
Unknown
057037a6b9 Adding back tests, but also reducing threshold by 1 2019-02-01 13:21:19 -05:00
Unknown
6931b0f5a1 rustfmt 2019-02-01 13:21:19 -05:00
Unknown
65f62d0497 Moving tests to ui-toml to make use of clippy.toml 2019-02-01 13:21:19 -05:00
Unknown
be514a4336 Updating number of lines for the failing test to be > 100.
Due to updating the configuration to be 101 instead of 51
2019-02-01 13:21:19 -05:00
Araam Borhanian
5e10809ac3 Adding lint for too many lines. 2019-02-01 13:21:19 -05:00
Unknown
44c835feea Skipping check if in external macro. 2019-02-01 13:21:19 -05:00
Unknown
02456208b4 Fix test broken by removing comment. 2019-02-01 13:21:19 -05:00
Unknown
50c82e0270 Updating to just warn for one test. 2019-02-01 13:21:19 -05:00
Unknown
c1f4e18453 Adding back tests, but also reducing threshold by 1 2019-02-01 13:21:19 -05:00
Unknown
e583f35b3a rustfmt 2019-02-01 13:21:19 -05:00
Unknown
3a97b5fa20 Moving tests to ui-toml to make use of clippy.toml 2019-02-01 13:21:19 -05:00
Unknown
7fbd55c329 Reworking function logic, and adding doc example.
This should fix line count logic issues that the previous code had, with assumptions it would make.
2019-02-01 13:21:19 -05:00
Unknown
93bf74a158 Running util/dev to update README/CHANGELOG 2019-02-01 13:21:19 -05:00
Unknown
6b86c3b1e7 Updating number of lines for the failing test to be > 100.
Due to updating the configuration to be 101 instead of 51
2019-02-01 13:21:19 -05:00
Araam Borhanian
1169066a0b Adding lint for too many lines. 2019-02-01 13:21:19 -05:00
Philipp Hansch
69d96c7cdf
Remove conditionals from base builds
We _always_ want to execute these, also on the master branch.
2019-02-01 18:27:09 +01:00
Philipp Hansch
38347bad38
Make vec_box MachineApplicable 2019-02-01 18:18:45 +01:00
Philipp Hansch
4aff8711f0
Fix ICE in vec_box lint and add run-rustfix
`hir::Ty` doesn't seem to know anything about type bounds and
`cx.tcx.type_of(def_id)` caused an ICE when it was passed a generic type
with a bound:

```
src/librustc_typeck/collect.rs:1311: unexpected non-type Node::GenericParam: Type { default: None, synthetic: None }
```

Converting it to a proper `Ty` fixes the ICE and catches a few more
places where the lint applies.
2019-02-01 18:18:45 +01:00
bors
5176a5c4b7 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].

[ast]: https://doc.rust-lang.org/nightly/nightly-rustc/syntax/ast/struct.StructField.html
[hir]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/hir/struct.StructField.html
2019-02-01 08:36:11 +00:00
Philipp Hansch
4e39e65ad8
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`.
2019-02-01 07:34:36 +01:00
Michael Wright
b6c3a6a09f Move max_value handling to consts module 2019-02-01 06:32:16 +02:00
Michael Wright
488cdebd26 Merge branch 'master' into fix-2728 2019-02-01 06:27:36 +02:00
rhysd
b52a9bd966 cargo +nightly fmt at clippy_lints/ 2019-02-01 12:03:13 +09:00
rhysd
06e4e9cf27 remove TODO comment which was already done 2019-02-01 11:40:02 +09:00
rhysd
9d130a546f add dbg_macro rule to CHANGELOG.md and update count in README 2019-02-01 11:32:22 +09:00