Commit graph

1009 commits

Author SHA1 Message Date
llogiq
9ee462625b Merge pull request #637 from mcarton/debug
Lint usage of `Debug`-based formatting
2016-02-12 12:18:15 +01:00
Oliver Schneider
eed9ec15fb improve the no_effect lint 2016-02-11 13:50:41 +01:00
Manish Goregaokar
1013026f18 Merge branch 'pr-645' 2016-02-10 10:20:23 +05:30
Joshua Holmer
7e06737d6f Improve testing and suggestion messages on bool_comparison 2016-02-09 15:44:07 -05:00
mcarton
2db6965c81 Lint usage of Debug-based formatting 2016-02-09 21:22:54 +01:00
mcarton
1a8b8cd28f Don’t use {:?} and use span_suggestion in TOPLEVEL_REF_ARG 2016-02-09 21:22:30 +01:00
mcarton
d27aa960b6 Remove unused Display implementation for consts 2016-02-09 21:22:30 +01:00
mcarton
34812e82d0 Use const_eval in loops 2016-02-09 21:22:30 +01:00
Joshua Holmer
2687a3f6b5 Update lints 2016-02-09 14:52:20 -05:00
Joshua Holmer
14292674b0 display suggestion separately from lint 2016-02-09 14:44:42 -05:00
Manish Goregaokar
93461afffc Merge branch 'pr-613'
Conflicts:
	src/lib.rs
	src/types.rs
2016-02-10 01:03:26 +05:30
Joshua Holmer
56b3e7b4c2 lint comparison to bool (e.g. y == true)
Addresses #630
2016-02-09 14:10:22 -05:00
llogiq
275795fab3 speed up lint using blocks and types 2016-02-09 06:18:08 +01:00
llogiq
3b0b9e0e06 Merge remote-tracking branch 'origin/master' into regex_macro 2016-02-08 23:51:30 +01:00
llogiq
6525471214 fix #595 2016-02-08 23:48:04 +01:00
Oliver Schneider
672beb4138 prevent panic in enum glob import lint if a crate's elements are glob imported
fixes #639
2016-02-08 11:28:18 +01:00
llogiq
ceb9a8bdd7 regex macro lint 2016-02-07 22:50:54 +01:00
mcarton
a9e1b1fba0 Small cleanup 2016-02-07 14:40:45 +01:00
mcarton
344698377f Fix typo 2016-02-07 13:27:09 +01:00
mcarton
cd7a913200 Add - and / to EQ_OP 2016-02-07 13:26:34 +01:00
mcarton
8e22d08129 Improve is_exp_equal 2016-02-07 13:26:34 +01:00
mcarton
d862495d19 Lint ifs with the same then and else blocks 2016-02-07 13:26:34 +01:00
mcarton
fe6f2a22ba Lint about consecutive ifs with same condition 2016-02-07 13:26:34 +01:00
Manish Goregaokar
9ba5d45509 Merge branch 'pr-581'
Conflicts:
	README.md
2016-02-07 17:40:48 +05:30
mcarton
d9a2a7ac3c Fix false negative in TRIVIAL_REGEX 2016-02-06 18:13:19 +01:00
Manish Goregaokar
f53a830c8c Merge pull request #623 from mcarton/redundant
Be more consistent in lint declarations
2016-02-06 12:14:03 +05:30
mcarton
83a82a1d86 Remove redundancy in lint documentation
The default level is always given in the declare_lint! macro, no need to
add it inconsistently in the documentation.
2016-02-06 00:41:54 +01:00
mcarton
13f245f6c9 Fix util/update_wiki.py warnings and be consistent in declare_lint! invocations 2016-02-06 00:13:29 +01:00
mcarton
a02b8124de Lint about trivial regexes 2016-02-05 23:10:48 +01:00
mcarton
70124cf591 Fix case conventions 2016-02-05 21:54:29 +01:00
mcarton
c0063e172d Improve error message 2016-02-05 19:46:11 +01:00
mcarton
0f50b0981d Check for pattern use in FOR_KV_MAP 2016-02-05 19:14:02 +01:00
mcarton
431c446746 Lint looping on maps ignoring the keys or values 2016-02-05 19:13:14 +01:00
llogiq
2adc906a75 Merge branch 'master' into regex_syntax 2016-02-05 17:34:09 +01:00
llogiq
a14514f7c8 fixed span position and README 2016-02-05 17:29:41 +01:00
Manish Goregaokar
4eb9a921d4 Lint on cloning double pointer
fixes #620
2016-02-05 16:04:15 +05:30
llogiq
3d85cc24e7 new regex syntax lint, fixes #597 2016-02-05 00:36:06 +01:00
Oliver Schneider
af07ccc16c fallout 2016-02-03 15:39:22 +01:00
Oliver Schneider
3b8375d90b warn on useing all variants of an enum 2016-02-03 15:38:23 +01:00
mcarton
fab10c07e8 Fix confusing message for STRING_TO_STRING 2016-02-03 13:52:19 +01:00
scurest
908fb143ef Extend ABSURD_UNSIGNED_COMPARISONS to handle more types 2016-02-03 05:08:00 -06:00
Manish Goregaokar
5eb884b7b0 Merge branch 'pr-593'
Conflicts:
	README.md
	src/lib.rs
2016-02-03 03:26:51 +05:30
mcarton
db205c82a4 Add a lint about using clone on Copy types 2016-02-02 22:35:01 +01:00
mcarton
47e26ab287 Fix warnings about the rustfmt_skip attribute 2016-02-02 22:34:20 +01:00
mcarton
c0d2fdc723 Partially apply rustfmt 2016-02-02 22:34:20 +01:00
mcarton
0c726e8077 Restore some of rustfmt madness 2016-02-02 22:34:20 +01:00
inrustwetrust
d93eca29fc Fix typo in drop_ref lint description. 2016-02-02 20:47:38 +01:00
inrustwetrust
bd86922c4f Add lint to warn for calls to std::mem::drop with a reference argument 2016-02-02 20:24:41 +01:00
llogiq
3a31576d76 fixed #606 2016-02-01 20:37:07 +01:00
llogiq
1dd19fbae3 Merge pull request #609 from oli-obk/prefixed_enum_variants
lint against enums where all variants share a prefix/postfix
2016-02-01 20:36:18 +01:00
Oliver Schneider
3b1df8d381 fallout 2016-02-01 13:01:16 +01:00
Oliver Schneider
328d2c7626 add lint to check for enums where all variants have the same pre-/postfix 2016-02-01 13:01:16 +01:00
Seo Sanghyeon
35ec57c116 Skip escape analysis for closure arguments 2016-02-01 20:35:01 +09:00
Oliver Schneider
07ace32ac9 fallout 2016-02-01 11:29:04 +01:00
Oliver 'ker' Schneider
d6c0435c81 lint on single match expressions with a value in the else path 2016-02-01 11:29:03 +01:00
llogiq
a2ad0c6695 fixed #528 2016-01-31 23:25:10 +01:00
scurest
e48fbba864 Add a lint to suggest uint == 0 over uint <= 0 2016-01-29 21:21:12 -06:00
llogiq
5402ef3d27 Merge branch 'devonhollowood-for-loop-over-option'
Conflicts:
	README.md
2016-01-30 01:34:35 +01:00
Devon Hollowood
405d7c691e Add for_loop_over_result lint 2016-01-29 15:24:17 -08:00
mcarton
f7bab322f6 Fix formatting on wiki 2016-01-29 22:49:48 +01:00
mcarton
95599c6a62 Synchronise comments with wiki
Wiki commits bfa439b and 9b8ced8.
2016-01-29 22:42:19 +01:00
mcarton
3a39bbaf74 Small cleanup 2016-01-29 22:31:17 +01:00
mcarton
1b9fbd8801 Fix false positive in NEEDLESS_LIFETIMES 2016-01-29 22:31:12 +01:00
mcarton
afb7e67217 Add a lint to warn about &vec![_] if &[_] would do 2016-01-29 17:41:52 +01:00
Devon Hollowood
f5cc94c96a Add for_loop_over_option lint 2016-01-28 23:39:00 -08:00
Manish Goregaokar
4c14d98c9f Merge pull request #549 from mcarton/ifs
Remove and lint about useless braces in `else { if .. }`
2016-01-29 03:39:27 +05:30
mcarton
da93643357 Add a lint to warn about use of print{,ln}! 2016-01-28 19:34:52 +01:00
llogiq
291b73b8e8 Merge master and re-run update_lints.py 2016-01-27 22:23:21 +01:00
Florian Hartwig
cee96fab39 Point out that char is 32 bit value 2016-01-27 21:10:35 +01:00
Florian Hartwig
23dfb2fbc0 Make update_lints script accept digits in lint names 2016-01-27 20:59:19 +01:00
Florian Hartwig
04f9d35f64 Add a lint for casts from char literals to u8 2016-01-27 20:23:59 +01:00
llogiq
5d5e50d67e fixed suggestion for iter case 2016-01-27 14:51:30 +01:00
llogiq
d152e5c683 fixed argument check 2016-01-26 23:51:06 +01:00
llogiq
2d97f916eb added more test, now works with vecs and iter 2016-01-25 19:46:56 +01:00
llogiq
ed96583677 extend_from_slice lint 2016-01-25 14:02:47 +01:00
mcarton
8ef0b86fab Lint explicit Clone implementations on Copy type 2016-01-24 15:33:23 +01:00
Oliver 'ker' Schneider
2a51f8d2be lint on items following statements 2016-01-24 10:16:56 +01:00
Manish Goregaokar
61bfaeb644 Merge branch 'rustup' 2016-01-22 18:36:23 +05:30
Manish Goregaokar
c86a5ccd2e Upgrade Rust to rustc 1.8.0-nightly (18b851bc5 2016-01-22)
fixes #573
2016-01-22 18:35:48 +05:30
mcarton
c6c0edb19b Add a lint about deriving Hash and implementing PartialEq 2016-01-21 19:56:31 +01:00
mcarton
7a26cfc991 Add macro checks in src/methods.rs lints 2016-01-20 18:32:17 +01:00
mcarton
91ff1db5bc Add a lint for starts_with 2016-01-20 12:57:14 +01:00
mcarton
5ac6659814 Handle Entry types in OR_FUN_CALL lint 2016-01-20 11:42:25 +01:00
Florian Hartwig
ea26ae3888 Add macro check 2016-01-19 20:08:56 +01:00
Florian Hartwig
01eda52cb5 Add lint for "string literal".as_bytes() 2016-01-19 19:17:50 +01:00
Florian Hartwig
6a4d77aa32 Fix deprecation warning on latest nightly 2016-01-19 13:53:49 +01:00
llogiq
5623e9e601 Merge pull request #559 from mcarton/redundant_closure
Fix redundant_closure false positive
2016-01-18 19:33:42 +01:00
mcarton
9d5e9cfd97 Fix redundant_closure false positive 2016-01-18 19:28:06 +01:00
mcarton
3713fd3dce Check types in the CMP_OWNED lint 2016-01-18 15:35:50 +01:00
Manish Goregaokar
5ab5a8801e Merge pull request #556 from mcarton/or_fun_call
New lint, new utility functions and nightly fix
2016-01-18 18:57:35 +05:30
mcarton
21ba315102 Update to rustc 1.7.0-nightly (d0bac3f14 2016-01-18) 2016-01-18 13:27:42 +01:00
mcarton
b5f65ec699 Improve OR_FUN_CALL to suggest unwrap_or_default 2016-01-18 13:11:07 +01:00
mcarton
fb6b3bed0f Add utility functions to check for trait impl 2016-01-18 13:10:26 +01:00
mcarton
90cbc858e9 Fix spelling mistake 2016-01-18 13:09:46 +01:00
Florian Hartwig
7e85db645e Fix another false positive in lifetime elision lint
The false positive occurred when we have an anonymous input lifetime and a
named output lifetime. This is not elidable, because if we elided the output
lifetime, it would be inferred to be the same as the input.
2016-01-17 17:53:41 +01:00
mcarton
c6604bb281 Add a lint to warn about call to .*or(foo(..)) 2016-01-16 18:47:45 +01:00
llogiq
840d87022e Merge pull request #523 from sanxiyn/escape-arg
Extend escape analysis to arguments
2016-01-16 00:03:58 +01:00
llogiq
da8a788b77 Merge pull request #551 from fhartwig/unused-lifetimes-fix
Consider lifetime in self parameter in unused_lifetime lint
2016-01-16 00:02:08 +01:00
mcarton
387e0991e3 Handle more iterator adapter cases in for loops 2016-01-14 20:58:32 +01:00
Florian Hartwig
7499f3c7a9 Consider lifetime in self paramter in unused_lifetime lint 2016-01-14 19:27:24 +01:00
mcarton
c2444c6043 Lint about else { if .. } with useless braces 2016-01-13 18:32:55 +01:00
mcarton
375b8168e4 Remove useless curly braces in else { if .. } 2016-01-13 18:32:05 +01:00
mcarton
6fa9bf64d7 Use span_suggestion in ENTRY lint 2016-01-13 17:27:49 +01:00
mcarton
f63329761f Cleanup utils, mostly doc 2016-01-13 17:27:49 +01:00
mcarton
09129c1b41 Add BTreeMap to the HASHMAP_ENTRY rule
Fixes #433
2016-01-13 17:27:36 +01:00
mcarton
44daa8bd72 Use span_suggestion in matches lints
Ref #442
2016-01-13 13:17:11 +01:00
mcarton
9f641a1009 Add known enums to SINGLE_MATCH 2016-01-13 01:19:27 +01:00
llogiq
37707b5a34 added semver lint 2016-01-09 02:05:43 +01:00
Manish Goregaokar
a21108a296 Stronger macro check 2016-01-08 21:21:12 +05:30
Manish Goregaokar
f27cfdb51a Fix warnings for unused attributes 2016-01-07 12:06:16 +05:30
Manish Goregaokar
002c8c34f8 re-add missing comments 2016-01-04 20:01:08 +05:30
Manish Goregaokar
c1a99fdd90 Fix dogfood failures by refactoring open_options 2016-01-04 12:06:37 +05:30
Manish Goregaokar
c9342d0121 fmt clippy 2016-01-04 09:56:12 +05:30
mcarton
9945bd82a8 Add better error messages for HashMapLint 2016-01-03 17:19:49 +01:00
mcarton
d0bb71e6a2 Finish the HashMapLint 2016-01-03 17:04:08 +01:00
mcarton
54b70ed8e1 Move eq_op::is_exp_equal to utils 2016-01-03 17:04:08 +01:00
mcarton
0c6e385493 Implement a HashMapLint 2016-01-03 17:04:08 +01:00
Manish Goregaokar
4484448cd1 Merge branch 'pr-538'
Conflicts:
	README.md
2016-01-03 21:26:04 +05:30
Manish Goregaokar
780dedc500 fixups 2016-01-03 21:25:09 +05:30
mcarton
7a4d6aa8b7 Use same error message for OPTION_UNWRAP_USED and RESULT_UNWRAP_USED
IIRC, Result::expect wasn't stable until quite recently, which might be
why there was 2 different error messages.
2016-01-03 14:49:54 +01:00
Guillaume Gomez
abfb1d3ca1 Add new lint on function naming check (the '_') 2016-01-03 14:48:54 +01:00
mcarton
52fbf1989d Add missing WRONG_PUB_SELF_CONVENTION in lint_array! and corresponding test 2016-01-03 14:42:24 +01:00
llogiq
a02f34aba9 Merge pull request #520 from mcarton/#471
Implement #471
2016-01-02 21:07:56 +01:00
llogiq
3e20292877 Merge pull request #535 from GuillaumeGomez/improve_field_help
Add help on field binding
2016-01-02 21:05:22 +01:00
mcarton
542685dad1 Merge branch 'master' of https://github.com/Manishearth/rust-clippy into #471 2016-01-02 19:36:45 +01:00
Manish Goregaokar
d8d3ee907b Add macro check for box vec (fixes #529) 2016-01-02 21:49:53 +05:30
Manish Goregaokar
a745efd566 Add smarter macro check for block_in_if (fixes #528) 2016-01-02 21:41:53 +05:30
Manish Goregaokar
32cf6e32f6 Improve documentation on match_ref_pats (fixes #532) 2016-01-02 16:36:17 +05:30
Manish Goregaokar
1605ef6ed4 Rustup to syntax::errors changes 2016-01-02 16:10:15 +05:30
Guillaume Gomez
bd8a265000 Add help on field binding 2016-01-02 06:31:05 +01:00
Johannes Linke
f89e400578 Minor documentation cleanups 2016-01-01 17:49:01 +01:00
Johannes Linke
b287739c0b Remove reference to a fixed issue 2016-01-01 17:48:46 +01:00
Johannes Linke
06f30a61dd Add "warn/allow by default" to lint descriptions where it was missing. 2016-01-01 17:48:19 +01:00
Devon Hollowood
093582c102 Make MethodsPass lint notes clearer 2015-12-30 01:07:40 -08:00
Devon Hollowood
2c42d46468 Bug fix 2015-12-30 00:55:38 -08:00
Devon Hollowood
a6bd2d0622 Add SEARCH_IS_SOME lint 2015-12-30 00:38:03 -08:00
Devon Hollowood
bbd439ec9e Add FILTER_NEXT lint 2015-12-28 16:56:58 -08:00
Seo Sanghyeon
07830c44af Extend escape analysis to arguments 2015-12-28 23:12:57 +09:00
Devon Hollowood
29b53d600f Replace match_method_chain() with method_chain_args() 2015-12-27 14:15:09 -08:00
Devon Hollowood
f1aac931bd Refactor check_expr() impl for MethodsPass 2015-12-27 01:22:53 -08:00
Manish Goregaokar
dbf1cdf34a Fix panic lint 2015-12-24 15:27:31 +05:30
mcarton
592ca26e90 Fix #518 2015-12-23 22:37:52 +01:00
mcarton
4958878ad2 Fix missing parameter in panic! 2015-12-23 22:36:37 +01:00
mcarton
0fa8481ba3 Put tests in tests folder 2015-12-23 17:48:41 +01:00
mcarton
2fd3093395 Only run MATCH_OVERLAPPING_ARM on integral matches 2015-12-23 11:25:44 +01:00
mcarton
90efb7b76d Fix typo 2015-12-23 11:25:32 +01:00
mcarton
1aa3956b8a Update README 2015-12-23 02:45:17 +01:00
mcarton
0c8de9ed52 Split MatchPass::check_expr for dogfood 2015-12-23 02:42:01 +01:00
mcarton
3373ea43c0 Consider literal patterns in MATCH_OVERLAPPING_ARM 2015-12-23 02:42:01 +01:00
mcarton
7216e83189 Implement #471 2015-12-23 02:42:01 +01:00
Florian Hartwig
e4fbeb4947 Don't trigger block_in_if_condition_expr lint if the block is unsafe 2015-12-23 02:12:08 +01:00
Manish Goregaokar
dd16ac2ad7 Merge pull request #509 from mcarton/array-indexing
Implement #364
2015-12-22 10:22:06 +05:30
Manish Goregaokar
ea03c0d9e3 Merge pull request #514 from mcarton/remove-dup
Remove dup
2015-12-22 10:18:12 +05:30
mcarton
0e4259a827 Remove duplicated if_let_chain! macro definition 2015-12-22 00:48:50 +01:00
Markus Unterwaditzer
acc47a3bd5 Nightly fixes
As of
e3da2a9003 (diff-12e06f1e9ca371a11bdc4615f50a4071L59)
HirVec is syntax::ptr::P instead of Vec.
2015-12-22 00:22:35 +01:00
mcarton
826827fe94 Fix some typos 2015-12-21 20:47:19 +01:00
mcarton
3abdcd4709 Implement #364 2015-12-21 19:36:58 +01:00
Devon Hollowood
b190aa7deb Implement #507
Make `used_underscore_binding` lint compatible with MacroAttributes
expansions. TODO: Add a good test for this.
2015-12-21 01:03:12 -08:00
Manish Goregaokar
4a32445aa7 Add macro check to used_underscore 2015-12-20 04:53:29 +05:30
Manish Goregaokar
a65a7770b3 Rust upgrade to rustc 1.7.0-nightly (8ad12c3e2 2015-12-19) 2015-12-19 19:08:22 +05:30
Manish Goregaokar
9dca15de3e Merge pull request #499 from devonhollowood/underscore_binding
Add used_underscore_binding lint
2015-12-19 19:02:06 +05:30
Devon Hollowood
98d21f9fc5 Make compatible with unused_variables lint 2015-12-18 16:04:33 -08:00
Devon Hollowood
02cb24de82 Remove local variable check 2015-12-18 13:45:03 -08:00
Manish Goregaokar
b900e88910 Merge pull request #494 from sanxiyn/suggestion-2
Use suggestion for needless_return
2015-12-17 22:17:32 +05:30
Devon Hollowood
e620a1d57c Make suggested changes 2015-12-16 17:28:26 -08:00
llogiq
c645a9febe adding missing doc comments 2015-12-14 22:16:56 +01:00
llogiq
827082ac41 fix boxed_local example 2015-12-14 21:17:11 +01:00
Manish Goregaokar
8105260d6e Merge pull request #501 from oli-obk/fix/seme
fix cyclomatic complexity lint (fixes #491, fixes #478)
2015-12-14 22:23:42 +05:30
Oliver Schneider
cc1d696cb9 fix fallout from CC improvements 2015-12-14 14:30:09 +01:00
Oliver Schneider
902c7d832b fix cc computation in the presence of diverging calls
CFG treats diverging calls as its completely own path out of the function.
While this makes sense, it should also mean that a panic should increase the cyclomatic
complexity. Instead it decreases it.

Minimal example:

```rust
if a {
    b
} else {
    panic!("cake");
}
d
```

creates the following graph

```dot
digraph G {
  "if a" -> "b"
  "if a" -> "panic!(\"cake\")"
  "b" -> c
}
```

which has a CC of 1 (3 - 4 + 2). A CC of 1 means there is one path through the program.
Obviously that is wrong. There are two paths. One returning normally, and one panicking.
2015-12-14 14:29:20 +01:00
llogiq
c0bccc9567 more doc comments 2015-12-14 13:32:07 +01:00
llogiq
d7292fe235 more docs 2015-12-14 08:03:01 +01:00
Manish Goregaokar
f2b977907c Merge branch 'more_wiki' 2015-12-13 21:58:18 +05:30
Devon Hollowood
6960bf2ebc Make ExprField follow single-underscore rules 2015-12-12 21:59:25 -08:00
Devon Hollowood
b24e3aeea0 Add wiki docs, in line with #492 2015-12-12 21:56:05 -08:00
Devon Hollowood
aeb5a0e60c Reduce false positives
Add macro checking, and only lint for single leading underscores
2015-12-12 21:39:10 -08:00
Devon Hollowood
6091112698 Update tests 2015-12-12 21:39:10 -08:00
Devon Hollowood
43b96d59ad Run update_lints.py 2015-12-12 21:39:10 -08:00
Devon Hollowood
9de308ee15 Add used_underscore_binding lint 2015-12-12 21:39:10 -08:00
Manish Goregaokar
4ae43b10f0 Add wiki note for escape analysis 2015-12-13 09:08:58 +05:30
Cesar Eduardo Barros
8e59be318c Mention VecDeque in linkedlist lint
I couldn't find anything named RingBuf in the standard library. Some
search revealed that it had been renamed to VecDeque before the first
stable Rust release.
2015-12-12 20:05:06 -02:00
Manish Goregaokar
6aa656a910 Merge pull request #492 from Manishearth/wiki
added wiki comments + wiki-generating python script
2015-12-11 09:20:19 -05:00
Seo Sanghyeon
974ab43453 Use suggestion for needless_return 2015-12-11 16:28:05 +09:00
llogiq
5bbc1427fd added wiki comments + wiki-generating python script 2015-12-11 01:22:27 +01:00
Manish Goregaokar
b9546599e3 Check for unused lifetimes in bounds (fixes #489) 2015-12-10 12:02:59 -05:00
Manish Goregaokar
b865e30b49 Upgrade rust to rustc 1.6.0-nightly (462ec0576 2015-12-09) 2015-12-09 15:56:49 -05:00
Seo Sanghyeon
213c15cd66 Add span_lint_and_then and use it 2015-12-09 02:46:14 +09:00
Seo Sanghyeon
35b5c3efdd Use suggestion for redundant_closure 2015-12-08 15:03:01 +09:00
llogiq
3260b501a2 Merge pull request #483 from Manishearth/bored
Add lint for unused lifetimes (fixes #459)
2015-12-07 21:47:10 +01:00
Manish Goregaokar
e8686a3ecd Merge branch 'pr-482' 2015-12-07 07:23:52 -05:00
Guillaume Gomez
72117836f1 Add check on redundant _ bindings in structs 2015-12-07 13:16:59 +01:00
Manish Goregaokar
c7b87a06d2 Add lint for unused lifetimes (fixes #459) 2015-12-07 06:55:14 -05:00
Manish Goregaokar
c4e9982dd7 Merge pull request #481 from fhartwig/lifetime-with-alias
Make unneeded_lifetimes lint work properly with type aliases
2015-12-06 09:08:40 +05:30
Florian Hartwig
ac39dc290b Remove obsolete workaround 2015-12-06 02:05:32 +01:00
Florian Hartwig
62db392730 Make lifetimes lint work with type aliases and non-locally-defined structs 2015-12-06 02:04:13 +01:00
Robert Clipsham
978c41584f Fix clippy with latest Rust nightly. 2015-12-05 12:33:58 +00:00
Manish Goregaokar
dc414e6c02 Make panic in CC silencable (partial #478) 2015-12-05 14:23:00 +05:30
Manish Goregaokar
18e81c1b59 Rudimentary escape analysis for Box<T> 2015-12-04 20:23:14 +05:30
llogiq
e90acaf596 Merge pull request #460 from oli-obk/cyclomatic_complexity
Cyclomatic complexity
2015-12-03 16:52:53 +01:00
Oliver Schneider
04524c549e improve cc of function 2015-12-03 16:41:55 +01:00
Oliver Schneider
3d1b7e1957 high-speed-dogfood 2015-12-03 16:41:55 +01:00
Oliver Schneider
617c820e6b compute cyclomatic complexity (adjusted to not punish Rust's match) 2015-12-03 16:41:55 +01:00
Seo Sanghyeon
26f539eaa3 Remove unused qualifications 2015-12-02 23:25:12 +09:00
Manish Goregaokar
ba59ed05e3 Rust upgrade to rustc 1.6.0-nightly (52d95e644 2015-11-30) 2015-11-30 23:16:28 +05:30
Hobofan
7d583dab80 fix for latest nightly
Fixes breakage introduced by rust-lang/rust#30043
2015-11-27 14:50:23 +01:00
Manish Goregaokar
409c0f0998 Merge pull request #468 from devonhollowood/option-methods
Lint `map(f).unwrap_or(a)` and `map(f).unwrap_or_else(g)`
2015-11-26 14:22:27 +05:30
Devon Hollowood
443e4556c2 Add lints suggesting map_or() and map_or_else()
In accordance with the latter lint, replace map().unwrap_or_else() in
src/mut_mut.rs with map_or_else()
2015-11-25 23:56:45 -08:00
Florian Hartwig
94dc2f567a Suppress explicit_counter_loop lint if loop variable is used after the loop 2015-11-26 00:09:01 +01:00
Florian Hartwig
cf54006449 Fixes to build with current rust nightly 2015-11-25 16:28:29 +01:00
Seo Sanghyeon
b1a0abe404 Don't panic 2015-11-25 13:57:50 +09:00
Seo Sanghyeon
746991572f Extend match_ref_pats to desugared matches 2015-11-25 02:47:17 +09:00
Seo Sanghyeon
a3e8091e87 Dogfood match_ref_pats for if let 2015-11-25 02:44:40 +09:00
Manish Goregaokar
b40e80f039 spurious newline 2015-11-23 16:34:23 +05:30
Manish Goregaokar
84ad2be1df Merge branch 'pr-462'
Conflicts:
	README.md
2015-11-22 21:58:13 +05:30
John Quigley
d4cf288b38 Add block_in_if lint, #434 2015-11-22 21:52:06 +05:30
Florian Hartwig
a36707bffd Appease clippy by not shadowing variables 2015-11-19 20:19:19 +01:00
Florian Hartwig
096c064d43 Simplify has_debug_impl 2015-11-19 20:13:36 +01:00
Florian Hartwig
cad88a9137 warn on use of ok().expect() 2015-11-19 17:15:21 +01:00
Florian Hartwig
9511e6739d Update to latest rust nightly 2015-11-19 15:51:30 +01:00
Seo Sanghyeon
1d602d0f12 rustfmt a little 2015-11-17 14:22:57 +09:00
Seo Sanghyeon
b17e38782e Remove trailing commas in match arms with blocks 2015-11-17 13:39:42 +09:00
llogiq
1555eed5fb Merge pull request #452 from fhartwig/lifetime-false-positives
Fix some false positive in needless_lifetimes lint
2015-11-14 09:25:19 +01:00
Andrew Paseltiner
91763d7725 Match min and max functions using DefId
Closes #446.
2015-11-11 11:08:33 -05:00
Andrew Paseltiner
e8a239a1a2 Add lint for useless transmutes
Closes #441.
2015-11-11 10:53:11 -05:00
Florian Hartwig
e48973eb9f Track elided lifetimes in types and trait objects 2015-11-11 00:12:45 +01:00
Andre Bogus
42ae1e6918 use rustc's eval_const, bail on (negative) infinity 2015-11-10 11:23:47 +01:00
Andre Bogus
aea2eb7da7 use visitor for contains_self 2015-11-10 10:25:21 +01:00
Andrew Paseltiner
2801c1031d Remove executable permission from remaining source files 2015-11-09 08:04:41 -05:00
Manish Goregaokar
764791b83e Merge pull request #440 from Manishearth/map_clone
match .map(Clone::clone)
2015-11-08 10:13:55 +05:30
llogiq
a0cd8fc943 match .map(Clone::clone) 2015-11-05 17:11:41 +01:00
Manish Goregaokar
c7df4bd000 Rustup to rustc 1.6.0-nightly (effcd2965 2015-11-04)
fixes #437
2015-11-05 08:20:28 +05:30
Seo Sanghyeon
3322ffa8a0 New lint for assignment to temporary 2015-11-04 21:37:18 +09:00
wartman4404
764eedd050 check for Deref conversions 2015-11-03 21:11:40 -06:00
wartman4404
414c0d20f7 New lint for using .cloned() 2015-11-03 21:01:52 -06:00
Nathan Weston
d28b8e169f New lint for zip with array length instead of enumerate()
Fixes #11.
2015-11-03 15:55:20 -05:00
Manish Goregaokar
dbb8a872a3 Fix ptr-arg false positive for trait impls
Fixes #425
2015-10-31 05:18:05 +05:30
llogiq
555328cc7b Merge pull request #422 from sanxiyn/no-effect
New lint for statement with no effect
2015-10-29 12:05:28 +01:00
Seo Sanghyeon
0fe5981870 New lint for statement with no effect 2015-10-29 15:50:35 +09:00
wartman4404
8e4c2171d2 Don't show single_match if match_bool also applies 2015-10-28 22:26:48 -05:00
Florian Hartwig
c5b6fda399 Allow needless_lifetime to pass dogfood.sh 2015-10-27 18:28:36 +01:00
Florian Hartwig
5ca7ebb6d2 Fix false positives when iterator variable is used after the loop 2015-10-26 23:57:55 +01:00
Florian Hartwig
8626ac1fd4 Fixes for code review comments
* remove weird infinite loops from compile-tests
* remove call to Option::unwrap
* in the lint message, show while-let loop rewritten as for loop
2015-10-26 23:57:55 +01:00
Florian Hartwig
659e7c1d5e Don't suggest using a for loop if the iterator is used in the loop body
Due to https://github.com/rust-lang/rust/issues/8372, we have to use while-let
in these cases.
2015-10-26 23:57:55 +01:00
Florian Hartwig
f6163fce61 Suggest for loop instead of while-let when looping over iterators 2015-10-26 23:57:50 +01:00
Georg Brandl
a91c618fed Fix reverse_range_loop not taking sign into account (fixes #409)
Adds a Display impl for Constant, because that might come in handy
elsewhere as well.
2015-10-26 08:05:01 +01:00
Kevin Yap
70e3277bf9 Compare float literals to stringified constants
- Convert constants to strings and compare directly with float literal.
- Return immediately after positive match for constant.
- Fix value of `my_log10_e` in `approx_const` tests.
2015-10-24 16:00:22 -07:00
Kevin Yap
546eb14b7e Change implementation of approx_const lint
- Replace epsilon with lower and upper bounds for each constant.
- Warn on use of "3.14", and update tests accordingly.
2015-10-22 23:07:27 -07:00
Seo Sanghyeon
d843257643 New lint for struct update that has no effect 2015-10-22 18:19:06 +09:00
Andre Bogus
da82e2d3ba added code snippet help to match_bool 2015-10-21 08:24:56 +02:00
Vikas Kumar
5e78fbbf57 Fixups from review comments
1. Moved common check `in_external_macro` to the top of function from inside each
conditionals.
2. Inlined `is_bool_expr` call
2015-10-20 11:26:54 -07:00
Vikas Kumar
675c532eab Ran util/update_lints.py to auto gen doc and lib.rs 2015-10-20 10:25:37 -07:00
Vikas Kumar
2951b70d15 Match on bool should be replaced with if..else block
1. Added another conditional in `check_expr` impl to lint if match expr
is a bool.
2. Test cases.
2015-10-20 10:18:48 -07:00
Manish Goregaokar
dea087dd17 Merge branch 'pr-394' 2015-10-18 00:54:03 +05:30
Florian Gilcher
8063916477 Cleanup as discussed in PR 2015-10-17 20:16:54 +02:00
Manish Goregaokar
853368c1d3 Make is_from_for_desugar sound (rust/28973 got fixed) 2015-10-17 04:33:05 +05:30
Florian Gilcher
39e93d572b Regnerate README.md 2015-10-15 21:33:47 +02:00
Florian Gilcher
1bd023d3e0 New lint for needless use of nightly features 2015-10-15 21:33:47 +02:00
Manish Goregaokar
b2f4550654 Fix type complexity lint 2015-10-15 19:55:14 +05:30
Andre Bogus
33062bb620 Merge branch 'master' of https://github.com/Manishearth/rust-clippy into rustup 2015-10-15 16:19:08 +02:00
Andre Bogus
657afc1157 rustup 2015-10-15 16:02:19 +02:00
Florian Hartwig
871d9fc27c Make ptr_arg lint warn by default 2015-10-14 20:35:44 +02:00
Andre Bogus
cf1e83b6dc Merged #365 2015-10-14 12:22:57 +02:00
Andre Bogus
949c3545ce Merged #366 2015-10-14 12:06:28 +02:00
Andre Bogus
b3d035d252 Merge PR #374 2015-10-14 11:44:09 +02:00
Andre Bogus
bed29a017b new lint to detect 2015-10-13 18:38:08 +05:30
Andre Bogus
b2f1940f6f improved precedence messages (fixes #389) 2015-10-13 13:59:20 +02:00
Manish Goregaokar
567d5a7293 Improve cmp_owned suggestions (fixes #386) 2015-10-13 04:16:05 +05:30
Ravi Shankar
fb5fdb61fa whup the while_let_loop for ignoring expressions! 2015-10-12 19:12:59 +05:30
Manish Goregaokar
a04745e16c Merge pull request #379 from swgillespie/zero_div_zero_nan
implement 0.0/0.0 -> NaN lint as described in #370
2015-10-12 11:33:35 +05:30
llogiq
d34a62b887 Merge pull request #381 from durka/patch-2
fix doc comment for if_let_chain!
2015-10-12 08:01:35 +02:00
Georg Brandl
be2fb9ba11 Remove "are you sure?" from lint msg.
No added value, and leads to punctuation clash.
2015-10-12 07:59:08 +02:00
Alex Burka
3632b93d7a fix doc comment for if_let_chain! 2015-10-12 01:54:44 -04:00
swgillespie
b02e80c012 implement 0.0/0.0 -> NaN lint as described in #370
casing of NaN
2015-10-11 19:26:23 -07:00
Manish Goregaokar
4e2b09831b Rust upgrade to rustc 1.5.0-nightly (9d3e79ad3 2015-10-10) 2015-10-12 02:42:59 +05:30
Florian Hartwig
b48db27152 Recommend using Mutex<()> for locking 2015-10-11 16:07:00 +02:00
Florian Hartwig
6b7fff93bc Fix documentation that disagrees with code 2015-10-08 00:35:32 +02:00
Florian Hartwig
26b2733b15 Add a lint for sized integer types in a mutex 2015-10-07 22:58:34 +02:00
Pyriphlegethon
b7c6c30c88 Change lint description 2015-10-07 17:15:44 +02:00
Pyriphlegethon
7644f8e2a1 Add "nonsensical OpenOptions" lint 2015-10-07 13:46:51 +02:00
Florian Hartwig
f8aa0431bd Suggest using an atomic value instead of a Mutex where possible 2015-10-07 01:35:14 +02:00
Manish Goregaokar
3e475e9588 Merge pull request #354 from Pyriphlegethon/master
Add "unnecessary mut passed" lint
2015-10-07 04:18:02 +05:30
Georg Brandl
85ac834343 RingBuf was renamed to VecDeque (fixes #363) 2015-10-05 22:02:14 +02:00
Josh Stone
846602a876 Update the DefLocal pattern
DefLocal now contains a DefId too, since rust-lang/rust@a0dc2d9a29.
2015-10-02 11:07:56 -07:00
Manish Goregaokar
431c391818 Fix a panic caused by while let 2015-10-02 13:37:41 +05:30
Manish Goregaokar
7eb0896271 Merge pull request #351 from Wafflespeanut/while_let
Training the `while_let` detector...
2015-10-01 01:14:45 +05:30
Manish Goregaokar
f76f4d52c2 Fix rustup fallout: lifetimes false positives 2015-09-30 20:10:54 +05:30
Manish Goregaokar
4fc17e7faf rustup to rustc 1.5.0-nightly (65d5c0833 2015-09-29) 2015-09-30 19:54:41 +05:30
Pyriphlegethon
33a0799fa9 Remove unnecessary clones and add helper function 2015-09-30 13:08:29 +02:00
Pyriphlegethon
e2a6c9e375 Add unnecessary mut passed lint for methods 2015-09-29 18:46:16 +02:00
Ravi Shankar
185da55263 extending while_let to warn for more statements 2015-09-29 20:26:34 +05:30
Pyriphlegethon
40e180d8c7 Replace tabs by spaces 2015-09-29 13:16:53 +02:00
Pyriphlegethon
b8cdefb6cf Add unnecessary mut passed lint 2015-09-29 13:11:19 +02:00
Georg Brandl
e8f875813d all: remove trailing spaces 2015-09-28 07:11:03 +02:00
Manish Goregaokar
15e3774cb4 rustup to 1.5.0-nightly (7bf4c885f 2015-09-26)
fixes #348
2015-09-28 10:34:10 +05:30
Manish Goregaokar
cd11488080 rustup 2015-09-24 2015-09-25 18:52:36 +05:30
Manish Goregaokar
294d7d8586 Merge branch 'pr-347' 2015-09-24 12:01:18 +05:30
Pietro Monteiro
b2c66d1a0e Upgrade Rust to rustc 1.5.0-nightly (b2f379cdc 2015-09-23)
Ident was removed in many HIR structures in favor of Name.
2015-09-23 17:30:39 -07:00
llogiq
4838e8a3b4 Merge pull request #344 from Manishearth/reflet
Handle let ref in toplevel_ref_arg as well
2015-09-22 09:18:45 +02:00
Manish Goregaokar
3609a2211a Handle let ref in toplevel_ref_arg as well 2015-09-22 12:46:51 +05:30
Georg Brandl
7cc291d02e generalize let_and_return for any block (closes #340) 2015-09-20 13:57:31 +02:00
Georg Brandl
7fdf52270b Fix stray backquote. 2015-09-19 08:49:01 +02:00
Manish Goregaokar
b56ff4319e fix dogfood 2015-09-19 08:33:04 +05:30
Manish Goregaokar
f4da7d09d2 Upgrade Rust to rustc 1.5.0-nightly (cff041170 2015-09-17)
LintPass was split and ExprParen was removed from the HIR

Fixes #338
2015-09-19 08:23:04 +05:30
llogiq
862c195fa1 Merge pull request #337 from Manishearth/indentfix
fix indentation
2015-09-17 07:44:39 +02:00
llogiq
acc83c0b02 Merge pull request #336 from Manishearth/issue335
ref matches: false positive with only wildcard pattern match
2015-09-17 07:43:26 +02:00
Georg Brandl
58fee220a9 fix indentation 2015-09-17 07:27:23 +02:00
Georg Brandl
e3ee87965e ref matches: false positive with only wildcard pattern match (fixes #335) 2015-09-17 07:25:08 +02:00
Manish Goregaokar
3124d2b8df Rustup to rustc 1.5.0-nightly (fc4d566b4 2015-09-16)
fixes #334
2015-09-17 05:32:29 +05:30
Nathan Weston
8a5b4f19fd Check for mutable borrow of counter variable 2015-09-15 09:41:25 -04:00
Nathan Weston
6b57924e81 Improve lint message
Remove trailing period and include snippet of loop argument.
2015-09-15 09:41:25 -04:00
Nathan Weston
1e320b38c1 Add is_integer_literal utility function
Replaces is_lit_zero and is_lit_one which were used in a couple of
places.
2015-09-15 09:41:25 -04:00
Nathan Weston
f87dd31f30 New lint: loop with explicit counter variable (fixes #159)
Avoiding false positives here turns out to be fairly complicated.
2015-09-15 09:41:25 -04:00
swgillespie
bc7d252856 use the constant folder to generalize the lint a little bit and clean up the code. Add additional tests for things that should not be linted 2015-09-14 22:20:56 -07:00
swgillespie
82c524b774 implement empty range lint as described in #330 2015-09-14 17:19:05 -07:00
llogiq
03af82afd1 removed expensive crate check from approx_const 2015-09-11 15:59:19 +02:00
llogiq
681bce925f less false positives for approx_const and float_cmp 2015-09-11 15:30:08 +02:00
llogiq
0e1bc74683 additional macro check + more tests 2015-09-10 08:51:14 +02:00
llogiq
4835372df5 made shadow_unrelated allow, added previous binding span note, fixed #319 2015-09-08 11:50:04 +02:00
Manish Goregaokar
0e658afc1b Fix mut_mut false positive, make Allow (fixes #309) 2015-09-08 02:29:13 +05:30
llogiq
e43f2d7e54 damn autocorrect 2015-09-07 11:49:35 +02:00
llogiq
c79d884450 replace if let by equality check 2015-09-07 11:46:04 +02:00
llogiq
92b04cd75d split wrong_self_convention in pub/default visibility part 2015-09-07 09:17:45 +02:00
Andre Bogus
468b410d04 de-closured the item name getter 2015-09-06 21:03:09 +02:00
Andre Bogus
87e6099ad7 fix false positive len_zero in is_empty() 2015-09-06 20:57:06 +02:00
llogiq
1569fd8c55 Merge pull request #308 from Manishearth/unit_cmp
macro check for unit_cmp
2015-09-06 19:46:21 +02:00
Andre Bogus
391a5135e8 fixed build 2015-09-06 19:44:54 +02:00
Andre Bogus
0c74304f7b macro check for unit_cmp 2015-09-06 19:41:09 +02:00
Andre Bogus
b76ad366ab fixed bad_bit_mask false positive 2015-09-06 16:09:35 +02:00
inrustwetrust
efd553c8a9 Don't show the explicit_iter_loop lint for arrays with more than 32 elements
The IntoIterator trait is currently not implemented for arrays with more than
32 elements, so for longer arrays, the iter() or iter_mut() methods must be
used.
2015-09-06 13:36:21 +02:00
Andre Bogus
55729b7caa dogfooding a newly caught problem 2015-09-06 10:59:06 +02:00
Andre Bogus
54393f0ef5 More strict macro check 2015-09-06 10:53:55 +02:00
llogiq
3848756be0 Made min_max Warn by default 2015-09-05 14:20:35 +02:00
llogiq
b90e4c7bd5 hir naming, removed lookup, match full path 2015-09-05 13:15:18 +02:00
llogiq
cd91110ec0 new lint: min_max 2015-09-05 12:46:34 +02:00
llogiq
28212e4981 fixed dogfood by using snippet instead of the (escaped) literal string 2015-09-04 14:24:49 +02:00
llogiq
e11fd49b1c Unicode lints, second attempt: Lint whole strings, help with replacement 2015-09-04 16:18:46 +05:30
Manish Goregaokar
af4d7f9b60 Merge pull request #298 from birkenfeld/as_mut
methods: allow &mut self for as_ methods
2015-09-04 16:16:58 +05:30
Georg Brandl
d659d039b6 methods: allow &mut self for as_ methods 2015-09-04 07:56:52 +02:00
Manish Goregaokar
eca185438b Update rust to 0efb9dab8c7c07fa28e9df0eccc5c07ea3c17fbb (HIR+lints, Thu Sep 3 18:59:56 2015 +0530)
fixes #294
2015-09-03 23:12:19 +05:30
llogiq
cb571bf2e2 also ignore functions 2015-09-03 10:57:11 +02:00
Manish Goregaokar
fbdba7f915 Fix ICE 2015-09-03 02:15:02 +05:30
Georg Brandl
7649d1c2a8 shadow: complete coverage of "contains_self" checker 2015-09-02 18:24:46 +02:00
Georg Brandl
6b589681c9 methods: allow multiple self kinds for "is_" methods
These can be static method predicates.  (Found one in rust-copperline,
called Term::is_unsupported_term().)
2015-09-02 17:14:27 +02:00
Georg Brandl
846c164709 don't say "did you mean to" - use the standard "consider..."
"Did you mean to ..." sounds a bit condescending to me, since
if I meant to write "if let" I probably wouldn't have written "match" :)
2015-09-02 16:46:14 +02:00
Manish Goregaokar
73c34e12b3 Only handle ranges starting with 0 for needless_range_loop (fixes #279) 2015-09-02 16:11:54 +05:30
llogiq
0c7f05dd76 check item name for eq, fixes #268 2015-09-02 10:30:11 +02:00
llogiq
0fb7d1d2d9 reporting improvements 2015-09-02 08:19:47 +02:00
llogiq
bc1eb84810 match region patterns 2015-09-02 07:56:13 +02:00
llogiq
1ab733cfa1 extended pattern matching 2015-09-02 07:55:07 +02:00
llogiq
08fb953e1a extended pattern matching 2015-09-02 01:36:37 +02:00
Georg Brandl
5264196538 methods: try to allow value self when type is Copy (fixes #273) 2015-09-01 21:08:49 +02:00
Georg Brandl
1007864198 new lint: self conventions for certain method names (fixes #267) 2015-09-01 18:52:48 +02:00
Georg Brandl
88dd38de87 lib: add clippy_pedantic group with all Allow by default lints (fixes #265) 2015-09-01 18:05:28 +02:00
Frank Denis
833493cf07 FnKind::FkClosure -> FnKind::Closure 2015-09-01 14:28:23 +02:00
Manish Goregaokar
d3da9f6c81 Merge branch 'pr-260'
Conflicts:
	src/lib.rs
2015-08-31 15:06:53 +05:30
Georg Brandl
e33bef685e lifetimes lint: walk type bounds as well as types (fixes #253, again) 2015-08-31 11:26:41 +02:00
Georg Brandl
0217fb81ee loops: fix false positives with explicit_iter_loop and references (fixes #261) 2015-08-31 08:29:40 +02:00
Georg Brandl
d499d2a9a7 loops: remove debugging print 2015-08-31 08:20:39 +02:00
Georg Brandl
03abe275b2 new lint: unnecessary patterns (x@_ -> x) 2015-08-30 19:02:30 +02:00
Tim Neumann
ef0c933550 add precedence_negative_literal lint 2015-08-30 17:34:48 +02:00
Georg Brandl
16df79a054 new lint: using collect() to just exhaust an iterator
Should use a for loop instead.
2015-08-30 13:10:59 +02:00
Georg Brandl
b72ef5a173 new lint: loop-match-break, which could be while-let (fixes #118) 2015-08-30 12:40:39 +02:00
Georg Brandl
6461fb3308 lifetimes lint: take "where" clauses into account (fixes #253)
If a where clause is present and has lifetimes mentioned, just bail out.
2015-08-30 09:58:26 +02:00
llogiq
621818e606 rustup, the ExpnInfo stuff changed 2015-08-28 14:35:20 +02:00
Manish Goregaokar
c3d4eb5bbd Merge branch 'pr-228'
Conflicts:
	README.md
	src/methods.rs
2015-08-27 15:25:56 +02:00
Manish Goregaokar
5159e034a6 appease the dogfood gods 2015-08-27 04:40:01 +05:30
Manish Goregaokar
9ebcd0bf29 More macro checks 2015-08-27 04:33:59 +05:30
Manish Goregaokar
7a1082d916 Merge pull request #239 from jedisct1/nightly
Changes for rust-nightly after #27856
2015-08-27 03:44:30 +05:30
Georg Brandl
bb552dc96f eta_reduction: fix false positive for unsafe fns (fixes #243) 2015-08-26 17:09:51 +02:00
llogiq
6984d2bc09 added helpful links to lints that have wiki entries 2015-08-26 14:33:51 +02:00
llogiq
5e341715cd Merge pull request #240 from Manishearth/shadow_scope
correct scoping for shadow lints
2015-08-25 23:56:57 +02:00
llogiq
51a211503d correct scoping for shadow lints 2015-08-25 23:48:22 +02:00
Manish Goregaokar
c9b849bdc8 Merge pull request #237 from birkenfeld/iter_fix
loops: use a whitelist for the "x.iter() -> &x" lint (fixes #236)
2015-08-26 03:16:49 +05:30
Frank Denis
92db00863f Changes for rust-nightly after #27856 2015-08-25 23:21:38 +02:00
Manish Goregaokar
6df102cdab Merge pull request #238 from birkenfeld/to_string_fix
methods: suggest correct replacement for `to_string()` (fixes #232)
2015-08-26 02:43:19 +05:30
llogiq
9012d8f197 fixed false positives on structs/enum variants 2015-08-25 20:11:03 +02:00
llogiq
56cdd58ad2 Merge branch 'master' of https://github.com/Manishearth/rust-clippy into shadow 2015-08-25 20:09:50 +02:00
llogiq
974ceefc1e shadowing detection 2015-08-25 20:06:09 +02:00
llogiq
544c14f3ef Merge pull request #230 from birkenfeld/eq_op_fix
eq_op: cut back to expressions that are guaranteed side effect free
2015-08-25 19:32:12 +02:00
Georg Brandl
6fa34cca29 methods: suggest correct replacement for to_string() (fixes #232) 2015-08-25 18:39:21 +02:00
Georg Brandl
ffed5b0b23 loops: use a whitelist for the "x.iter() -> &x" lint (fixes #236) 2015-08-25 18:28:05 +02:00
llogiq
bd22521af2 shadowing detection 2015-08-25 17:36:46 +02:00
Georg Brandl
b13d318f48 all: remove unneeded deref and/or ref operations 2015-08-25 17:35:20 +02:00
Georg Brandl
88047a0953 collapsible_if: remove extraneous note output
This was probably a debug addition.
2015-08-25 17:35:20 +02:00
Georg Brandl
92a3394065 all: remove unneeded deref and/or ref operations 2015-08-25 14:41:35 +02:00
llogiq
5225feceaa shadowing detection 2015-08-25 13:40:26 +02:00
Georg Brandl
d5c808acd0 collapsible_if: remove extraneous note output
This was probably a debug addition.
2015-08-25 13:27:21 +02:00
Georg Brandl
81ef3da03c methods: people might be using to_string() to make a copy; add a hint for that 2015-08-25 12:46:29 +02:00
Georg Brandl
64cd1fc6ba eq_op: cut back to expressions that are guaranteed side effect free
fixes #229
2015-08-25 12:34:37 +02:00
Georg Brandl
56e8db476c new lint: inherent methods that should be trait impls (fixes #218) 2015-08-25 11:10:42 +02:00
llogiq
209e6981a3 shadowing detection 2015-08-24 16:59:02 +02:00
llogiq
961f9d68a9 Merge pull request #226 from birkenfeld/fixes
Two small fixes/refactorings
2015-08-24 16:21:17 +02:00
Georg Brandl
cc8f33d915 ranges: remove unneeded as_str() 2015-08-23 16:34:23 +02:00
Georg Brandl
c8a2e848ab utils: extract utility method for matching trait method calls from loops 2015-08-23 16:32:50 +02:00
R.Chavignat
3af2e3ba85 Refactored CastPass. 2015-08-23 06:26:31 +02:00
R.Chavignat
e80f2470b7 Merge branch 'master' into cast_iusize_improvements 2015-08-23 00:08:16 +02:00
R.Chavignat
79ef13592e Completed the implementation of *size handling.
Added some more cases to the test, and implemented a new lint,
cast_possible_wrap, triggered when casting from an unsigned type to a
signed type of the same size.
2015-08-22 23:49:03 +02:00
llogiq
5a5b1ba96b Merge pull request #216 from birkenfeld/match_pass
new lint: using &Ref patterns instead of matching on *expr (fixes #187)
2015-08-22 19:06:48 +02:00
Georg Brandl
7580da306e matches: special message for this case
match &e { &Pat1 => {}, &Pat2 => {}, ... }

(inspired by dogfood fixes)
2015-08-22 14:34:39 +02:00
Georg Brandl
8f1a237493 &-matches: dogfood fixes! 2015-08-22 14:34:39 +02:00
Georg Brandl
017dac2301 new lint: using &Ref patterns instead of matching on *expr (fixes #187) 2015-08-22 14:34:39 +02:00
Georg Brandl
5403e82681 matches: new module, move single_match lint there 2015-08-22 14:34:39 +02:00
Georg Brandl
1587256dc4 types: check for macros in type complexity check 2015-08-22 14:30:53 +02:00
Manish Goregaokar
1334f2ceae Fix doubleborrow of refcell in consts.rs 2015-08-22 13:02:50 +05:30
Georg Brandl
630bb76f96 new lint: type complexity (fixes #93)
Still very naive, but it's a start.
2015-08-22 08:57:11 +02:00
Georg Brandl
e92bf84a53 ptr_arg: fix panic when pattern type is not in tcx 2015-08-22 08:57:11 +02:00
R.Chavignat
f1255d5f5d Casts : work in progress handling *size separately 2015-08-22 02:46:22 +02:00
Georg Brandl
8a10440641 utils: add match_type() helper function
which saves one level of matching when checking for type paths
2015-08-21 19:24:38 +02:00
Georg Brandl
a437936d49 all: put often used DefPaths into utils as consts
Also remove the "use xxx;" blocks to ensure import paths don't change.
They don't work anyway since stuff may still be re-exported at the old
location, while we need the "canonical" location for the type checks.

Plus, the test suite catches all these cases.
2015-08-21 19:23:05 +02:00
Georg Brandl
707e95f2e5 types: use middle::ty types instead of ast types
This gets rid of the match_ty_unwrap function.
2015-08-21 19:21:19 +02:00
Georg Brandl
b2df15d65a ptr_arg improvements (fixes #214)
* do not trigger on mutable references
* use "real" type from ty, not AST type
2015-08-21 19:21:18 +02:00
llogiq
6ffe1ed337 Merge pull request #212 from Manishearth/eq_op_const
Eq op const
2015-08-21 12:30:53 +02:00
llogiq
a22b3cdcee const folding for eq_op 2015-08-21 12:26:03 +02:00
llogiq
4dcbad1b08 const folding for eq_op 2015-08-21 12:19:07 +02:00
R.Chavignat
ad0bc66402 Added support for isize/usize in the CastPass lint pass.
Extracted the match that determines an integer types's size in a
utility function and implemented support for usize/isize.
Added a needed feature to the crate root.
Added some tests to cover those cases, and a test I previously forgot.
Silenced two errors signaled by dogfood.sh in unicode.rs.
2015-08-21 03:03:37 +02:00
R.Chavignat
dbc9b7f46e Reworked the error messages for more heplfulness.
Renamed the cast_possible_overflow lint to cast_possible_truncation,
and updated the error message, readme and crate root accordingly.
Added some more information to the message for the cast_precision_loss
lint.
Updated the test case to reflect changes.
2015-08-20 22:44:40 +02:00
R.Chavignat
ab481e5cb1 Refactored the CastPass lints. 2015-08-20 21:37:37 +02:00
R.Chavignat
ff28dd324e Fixed a little oversight. 2015-08-20 14:50:26 +02:00
R.Chavignat
14528d433a Simplified reexported ast::* type paths.
Also removed trailing whitespaces.
2015-08-20 14:46:40 +02:00
R.Chavignat
b417f01ed8 Also test that the CastExpr's right arm is numeric. 2015-08-20 14:36:26 +02:00
R.Chavignat
93d9249f76 Moved allow(unknown_lints) to crate level. 2015-08-20 14:25:08 +02:00
R.Chavignat
1846581baa Added examples to lint descriptions. 2015-08-20 14:24:26 +02:00
R.Chavignat
993239d33a Initial implementation of lossy cast lints.
Introduces 3 lints :
  cast_possible_overflow
  cast_precision_loss
  cast_sign_loss
Add a compile-test test case.
Fix errors spotted by dogfood script.
2015-08-20 01:04:06 +02:00
llogiq
150840667e Merge pull request #204 from Manishearth/bit-mask
Extend and correct the ineffective_bit_mask check
2015-08-19 13:25:43 +02:00
llogiq
973d5e5c6b Mul and Div for integers 2015-08-19 11:58:59 +02:00
llogiq
98d24b5b56 fixed #203 and #197 2015-08-19 09:39:03 +02:00
Georg Brandl
8f4499f3ae new lint: comparing unit types (fixes #201) 2015-08-19 08:11:00 +02:00
llogiq
9f67ba7f8d re-applied birkenfeld's improvements 2015-08-18 14:18:36 +02:00
llogiq
6e0c103133 more small const improvements 2015-08-18 12:26:01 +02:00
Georg Brandl
49ad73f6e4 consts: minor improvements 2015-08-18 11:07:13 +02:00
Georg Brandl
7f52239cab consts: convert to using a struct with state
Struct has the context reference (as an Option) and the
needed_resolution flag.
2015-08-17 19:58:21 +02:00
Georg Brandl
a2dcbfea65 const eval: implement ! for integers 2015-08-17 16:45:56 +02:00
llogiq
a2ee637be6 added test and fixed negativity check in Partial{Eq, Ord} impl 2015-08-17 16:24:57 +02:00
llogiq
c47402416b Added bit operations to const folding 2015-08-17 15:11:36 +02:00
llogiq
4394362836 dogfooding 2015-08-17 13:23:17 +02:00
llogiq
9f134f8e95 added PartialEq/PartialOrd to ConstantVariant, used to implement comparing binops 2015-08-17 13:18:14 +02:00
llogiq
0e67c0134f make float_cmp check for zero 2015-08-17 12:08:45 +02:00
llogiq
fb715ce45d fix 189, fixed a few warnings, ==/!= for consts, refactored consts test 2015-08-17 12:08:45 +02:00
Manish Goregaokar
4f1fcd4d5b Merge pull request #184 from Manishearth/identity_op
Identity op now uses const folding, no longer follows const bindings
2015-08-17 14:35:45 +05:30
Manish Goregaokar
65deb956f1 Merge pull request #186 from birkenfeld/fix
loops: fix two trailing periods in lint msgs
2015-08-17 11:05:02 +05:30
Georg Brandl
caeb72c47b loops: fix two trailing periods in lint msgs 2015-08-17 07:30:33 +02:00
Georg Brandl
e9a41e2374 new lint: lint when iterating over any Iterator::next() result (fixes #182) 2015-08-17 07:28:40 +02:00
llogiq
759b45a46d made is_negative(..) public (+doctest), fixed identity_op and precedence 2015-08-16 23:09:56 +02:00
llogiq
c4b07ead17 Merge pull request #179 from nweston/step-by-zero
New lint: Range::step_by(0) (fixes #95)
2015-08-16 20:12:52 +02:00
Nathan Weston
23a38c4170 New lint: Range::step_by(0) (fixes #95)
Uses type information so it can detect non-literal ranges as well
(Range or RangeFrom -- the other range types don't have step_by).
2015-08-16 12:58:54 -04:00
llogiq
4244f2479f dogfooding, part 2 2015-08-16 16:09:00 +02:00
llogiq
fe0de07b28 dogfooded 2015-08-16 16:05:51 +02:00
llogiq
03c7d7074d With working test now 2015-08-16 15:56:09 +02:00
Manish Goregaokar
164907ece2 restrict toplevel_ref_arg to only functions (fixes #170) 2015-08-16 17:24:03 +05:30
Georg Brandl
64954283c1 add some imports to guard against crate moves 2015-08-16 09:03:06 +02:00