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
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
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
93a856e9d5
Changing single character string to a character match.
2019-02-01 13:21:19 -05:00
Unknown
6931b0f5a1
rustfmt
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
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
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
Araam Borhanian
1169066a0b
Adding lint for too many lines.
2019-02-01 13:21:19 -05: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
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
rhysd
7ec5528e0c
fix category and use suggestion
2019-02-01 09:31:26 +09:00
Philipp Hansch
ee7bad455b
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-01-31 07:25:47 +01:00
rhysd
f894adce8c
implement dbg_macro rule ( fixes #3721 )
2019-01-31 02:39:38 +09:00
Alex Hamilton
587492b5d2
wildcard_match_arm: add nesting issue to known.
2019-01-29 15:33:04 -06:00
Alex Hamilton
efaed8e0c0
wildcard_match_arm: lint only enum matches.
2019-01-29 15:33:04 -06:00
Alex Hamilton
6bc4416b2b
wilcard_match_arm: run rustfmt.
2019-01-29 15:33:04 -06:00
Alex Hamilton
c75dfeb29b
wildcard_match_arm: add lint properly.
2019-01-29 15:33:04 -06:00
Alex Hamilton
23eae0909d
wildcard_match_arm: rename function.
...
We also don't need `ex` as an argument.
2019-01-29 15:33:04 -06:00
Alex Hamilton
20ba476ea8
wildcard_match_arm: expand lint scope.
...
We're not only working with Results.
2019-01-29 15:33:04 -06:00
Alex Hamilton
1b3c3d073a
Change match_wild lint name to WILDCARD_MATCH_ARM.
...
Also fix message capitalization.
2019-01-29 15:33:04 -06:00
Alex Hamilton
0da18677f7
Add match_wild lint ( #3649 ).
...
This lint prevents using a wildcard in a match.
2019-01-29 15:33:04 -06:00
bors
6b1a2a9c3e
Auto merge of #3648 - phansch:const_fn_lint, r=oli-obk
...
Add initial version of const_fn lint
This adds an initial version of a lint that can tell if a function could be `const`.
TODO:
- [x] Finish up the docs
- [x] Fix the ICE
cc #2440
2019-01-29 19:58:13 +00:00
Philipp Hansch
d0d7c5e922
cargo fmt
2019-01-29 19:56:19 +01:00
Philipp Hansch
aed001b8d4
Update various docs
...
* `const_transmute` currently also seems to depend on the `const_fn`
feature.
* Only `Sized` is currently allowed as a bound, not Copy.
2019-01-29 08:19:05 +01:00
Philipp Hansch
0c6bdda562
Use built-in entry_fn detection over self-built
2019-01-29 08:19:05 +01:00
Philipp Hansch
c0a02691d8
cargo fmt
2019-01-29 08:19:05 +01:00
Philipp Hansch
f9d65b6356
Reorganize conditionals: Run faster checks first
2019-01-29 08:19:05 +01:00
Philipp Hansch
68cc4df551
Maybe fix ICE?
2019-01-29 08:19:05 +01:00
Philipp Hansch
c3980bf0bc
Add initial version of const_fn lint
2019-01-29 08:19:05 +01:00
Michael Wright
df04238d3a
Fix unit_arg
false positive
...
Ignore arguments with the question mark operator.
Closes #2945
2019-01-29 07:22:08 +02:00
bors
410d5ba6c3
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.
Fixes #3656
2019-01-28 14:30:18 +00:00
Oliver Scherer
60332941c9
Rustfmt
2019-01-28 11:32:41 +01:00
Oliver Scherer
c67a05166f
Check hypothetically failing conversion
2019-01-28 10:32:34 +01:00
Oliver Scherer
7b90cb529a
Update more changed iterator paths
2019-01-28 10:16:34 +01:00
Oliver Scherer
dc8c7b1677
Atomics constants are now handled by the deprecation lint
2019-01-28 10:10:27 +01:00
Oliver Scherer
36245feeb0
Update changed iterator paths
2019-01-28 10:09:45 +01:00