Commit Graph

2057 Commits

Author SHA1 Message Date
flip1995
44c46d2059
Run rustfmt 2019-03-10 22:12:26 +01:00
flip1995
3282955238
Update tests 2019-03-10 22:07:10 +01:00
Alexander Regueiro
a7c0800938 Reblessed test outputs. 2019-03-10 18:13:15 +00:00
Alexander Regueiro
d2b85323ad Addressed points raised in review. 2019-03-10 18:06:28 +00:00
Alexander Regueiro
d43966a176 Various cosmetic improvements. 2019-03-10 18:06:28 +00:00
Manish Goregaokar
038ec7f5d8 Move get_unwrap to restriction
fixes #3862
2019-03-09 13:48:06 -08:00
rchaser53
ae787d954e fix missing a semicolon 2019-03-07 23:26:47 +09:00
Michael Wright
7b948232ba Enable rustfix on unused_unit tests 2019-03-07 08:26:53 +02:00
Michael Wright
fbcf7eefb9 Add [rustfmt::skip] to unused_unit test 2019-03-07 08:13:59 +02:00
Michael Wright
131c8f6bf2 Add [rustfmt::skip] to doc_markdown tests 2019-03-07 08:03:15 +02:00
Félix Fischer
ddc718087f Renamed: Cyclomatic Complexity -> Cognitive Complexity
* Ran automatic naming update

* Formalized rename of `cyclomatic_complexity` to `cognitive_complexity`
** Added the rename to `lib.rs`
** Added rename test

* Added warning for deprecated key `cyclomatic_complexity_threshold` and tests for it

* Added deprecation status for Clippy's builtin attribute

* Updated tests for new builtin attribute renaming
2019-03-06 10:07:38 -03:00
Michael Wright
464ed58861 Ensure expect_fun_call bad suggestion is fixed
Closes #3839
2019-03-06 07:00:05 +02:00
Philipp Hansch
15cba2e956
Fix missing_const_for_fn for impl trait methods 2019-03-05 08:11:55 +01:00
Philipp Hansch
b87f5bc55a
Don't trigger missing_const_for_fn in external macros
As reported in #3841. Only fixes the part where it triggers on the
`derive`.
2019-03-04 22:56:33 +01:00
flip1995
c4eb780156
Add test for unknown Clippy attributes 2019-02-28 20:18:42 +01:00
Michael Wright
6e6e39b4a8 Add rustfmt::skip to double_parens tests 2019-02-28 08:02:45 +02:00
bors
ff2798840c Auto merge of #3666 - detrumi:map-or-on-non-copy, r=flip1995
Only suggest map_or for copy types

Fixes #2686
2019-02-27 08:28:48 +00:00
Michael Wright
11682b4cd2 Add rustfmt::skip to outer attr format tests 2019-02-27 07:41:07 +02:00
bors
6e8931c5f5 Auto merge of #3821 - g-bartoszek:redundant_closure-different-borrow-levels, r=oli-obk
do not trigger redundant_closure when there is a difference in borrow…

… level between closure parameter and "self", fixes  #3802
2019-02-26 17:30:48 +00:00
Wilco Kusee
eb70a72459
Fix false negative 2019-02-26 17:29:36 +01:00
Wilco Kusee
fec6e55d1d
Attempt to fix false negative 2019-02-26 17:27:41 +01:00
Wilco Kusee
54ab22f6db
Only suggest map_or for copy types 2019-02-26 17:27:40 +01:00
bors
0957f7d3b7 Auto merge of #3817 - rust-lang:fix-bool_comparison-on-non-bool, r=oli-obk
Fix `bool_comparison` with non-`bool` expressions

Fixes #3703.
It just moves around the type check that was already there for some comparison to all of them, because if one type isn't `bool`, none of those comparison can be simplified.
2019-02-26 15:51:40 +00:00
Grzegorz
a7f4d41a7d do not trigger redundant_closure when there is a difference in borrow level between closure parameter and "self" 2019-02-26 12:12:27 +01:00
Michael Wright
7fd0fbf435 Add [rustfmt::skip] to formatting lint tests 2019-02-26 07:49:46 +02:00
mcarton
c0c0686a65 Fix bool_comparison with non-bool expressions 2019-02-25 22:31:16 +01:00
bors
50d9473856 Auto merge of #3808 - mikerite:useless-format-suggestions, r=oli-obk
Fix `useless_format` suggestions
2019-02-25 16:21:26 +00:00
bors
1ac6f4e9ae Auto merge of #3772 - flip1995:ice-3719, r=Manishearth
Fix ICE #3719+#3718 in lint match_ref_pats

Fixes #3719
This conveniently also fixes #3718

The ICE occurs when the match expression was a macro call, where the macro was defined in another file. Since we don't have the ability to reproduce this behavior with our UI tests (AFAIK), I couldn't add a test reproducing this ICE.. However, I added a test which is related to the ICE, to show the new behavior of the lint.

I tested it with the mscheme repo locally and the ICE didn't happen anymore.

r? @matthiaskrgr
2019-02-25 12:30:35 +00:00
bors
cd29740e6e Auto merge of #3805 - martinsp:ice-3747, r=Manishearth
Fix ICE #3747

I'm not sure if this was the correct approach.

I don't know if I put tests/ui/crashses/ice-3747.rs in correct place because the test always passed when I ran it with `cargo test`, even without the fix applied.

If I run that test with `env CLIPPY_TESTS=true cargo run --bin clippy-driver -- -L ./target/debug tests/ui/crashes/ice-3747.rs` then the test correctly fails without the fix applied

fixes #3747
2019-02-25 12:08:43 +00:00
mcarton
8bcd546648 Add a test for #2526 2019-02-24 18:23:54 +01:00
Michael Wright
0182a6640e Fix useless_format suggestions 2019-02-24 07:30:08 +02:00
Martins Polakovs
391ee7987d Fix ICE #3747
[Martins Polakovs, John Firebaugh]
2019-02-23 21:38:16 +02:00
bors
36e92a521f Auto merge of #3795 - mikerite:test-rustfmt, r=phansch
Allow rustfmt to run on more tests
2019-02-22 06:54:25 +00:00
Michael Wright
7a43509cc4 rustfmt tests/ui/methods.rs 2019-02-22 08:05:21 +02:00
Michael Wright
b96c4329db Add #[rustfmt::skip] to methods tests
Many people run rustfmt automatically on save. Format-dependent tests
should be marked with `#[rustfmt::skip]` to prevent accidental
reformatting from this. As a bonus the rest of the code can the formatted.
2019-02-22 07:49:17 +02:00
bors
a5c16e5892 Auto merge of #3789 - bzzzzzz:needless_range_loop_bugfix, r=oli-obk
Make needless_range_loop not applicable to structures without iter method

Fixes https://github.com/rust-lang/rust-clippy/issues/3788

Now we will start lint indexed structure only if it has known iter or iter_mut method implemented.
2019-02-21 09:36:13 +00:00
bors
027dde92e2 Auto merge of #3781 - uniphil:write_with_newline_false_positive, r=oli-obk
Don't check [print/write]_with_newline on raw strings

Some tests for #3778 and some maybe-not-the-greatest code that passes those tests!

I didn't run `fmt` because a) it doesn't seem to install on nightly for me, and b) on stable it wanted to apply formatting to over 90 files. Happy to make any tweaks though!

I suspect this contribution may require more than just tweaks. I'm still sort of new to rust so it may not be idiomatic, and the specific approach I took feels a little heavy-handed and brittle. I'm happy to make changes with some guidance, or equally happy if this gives a starting place for someone else to do it better :)
2019-02-20 16:37:32 +00:00
bors
d5d8d7bca5 Auto merge of #3779 - mikerite:fix-3704, r=phansch
Improve `iter_cloned_collect` suggestions

Fixes #3704
2019-02-20 09:21:18 +00:00
bzzzz
f9c6682827 Make needless_range_loop not applicable to structures without iter method 2019-02-20 00:10:25 -08:00
Michael Wright
bef7c76025 Format again 2019-02-20 06:06:00 +02:00
flip1995
0ce564a7e1
Add test related to the ICE
This test doesn't reproduce the ICE since it only happens, when the macro is defined in another file.
Currently we can't add tests with multiple files AFAIK

Also using the auxiliary folder didn't help
2019-02-19 21:34:14 +01:00
bors
075c212849 Auto merge of #3776 - notriddle:drop-bounds, r=oli-obk
Add a lint to warn on `T: Drop` bounds

**What it does:** Checks for generics with `std::ops::Drop` as bounds.

**Why is this bad?** `Drop` bounds do not really accomplish anything.
A type may have compiler-generated drop glue without implementing the
`Drop` trait itself. The `Drop` trait also only has one method,
`Drop::drop`, and that function is by fiat not callable in user code.
So there is really no use case for using `Drop` in trait bounds.

**Known problems:** None.

**Example:**
```rust
fn foo<T: Drop>() {}
```

Fixes #3773
2019-02-19 09:46:29 +00:00
Michael Wright
a6864297a7 Format again 2019-02-19 06:39:22 +02:00
Michael Howell
2da7f084fe Fix formatting 2019-02-18 19:36:58 -07:00
phil
ef72b2cac0 Check {print,write}_with_newline for literal newline
Both regular strings and raw strings can contain literal newlines. This commit
extends the lint to also warn about terminating strings with these.

Behaviour handling for raw strings is also moved into `check_newlines` by
passing in the `is_raw` boolean from `check_tts` as
[suggested](https://github.com/rust-lang/rust-clippy/pull/3781#pullrequestreview-204663732)
2019-02-18 19:22:20 -05:00
Daniel Wagner-Hall
bcefd688c9 Restore tests
Also, fix existing test
2019-02-18 22:56:43 +00:00
Daniel Wagner-Hall
422c9a0fa2 wildcard_enum_match_arm gives suggestions
And is also more robust
2019-02-18 22:56:43 +00:00
phil
cf5d4a1b45 Add failing test for #3778 write_with_newline
Literal `\n` characters (not a newline) in a `r"raw"` string should not
fail the lint.

This affects both write_with_newline and print_with_newline, so it is added in
both places.

I also copied a missing test case from write_with_newline over to
print_with_newline and added a note that one of those tests is supposed to
fail.
2019-02-18 11:39:40 -05:00
Michael Howell
2df14c3701 Add a lint to warn on T: Drop bounds
**What it does:** Checks for generics with `std::ops::Drop` as bounds.

**Why is this bad?** `Drop` bounds do not really accomplish anything.
A type may have compiler-generated drop glue without implementing the
`Drop` trait itself. The `Drop` trait also only has one method,
`Drop::drop`, and that function is by fiat not callable in user code.
So there is really no use case for using `Drop` in trait bounds.

**Known problems:** None.

**Example:**
```rust
fn foo<T: Drop>() {}
```
2019-02-17 22:53:08 -07:00
Michael Wright
6e7a813ed2 Improve iter_cloned_collect suggestions
Fixes #3704
2019-02-18 07:30:50 +02:00