Commit graph

1493 commits

Author SHA1 Message Date
Jeremy Stucki
2fe5e2cea9
Update test 2019-08-13 21:50:52 +02:00
Jeremy Stucki
6a263c0816
Add 'unnecessary_flat_map.fixed' 2019-08-13 08:03:04 +02:00
Jeremy Stucki
d51136d594
Use 'span_lint_and_sugg' 2019-08-12 21:42:57 +02:00
Philipp Hansch
e406ab5117
Add deprecation tests for deprecated tool lints 2019-08-12 19:42:23 +02:00
Philipp Hansch
0d0db5ed5f
Move old lint deprecation tests to deprecated_old.rs 2019-08-12 19:42:23 +02:00
Philipp Hansch
0b7e2376c8
Keep old deprecated lints deprecated as non-tool, too 2019-08-12 19:42:23 +02:00
Philipp Hansch
5114050839
Update lint deprecation for tool lints
Our lint deprecation previously didn't work for tool lints, because
`register_removed` was registering lints to be removed _without_ the
`clippy` prefix.
2019-08-12 19:20:36 +02:00
bors
e255f36afe Auto merge of #4365 - lukas-code:async_new_ret_no_self, r=flip1995
new_ret_no_self: allow Self in inner type for impl Trait return types

Check the inner types of associated types of a trait when checking for Self in the return type of a `new` method. This means that the following will no longer warn:
```rust
trait Trait {
    type Inner;
}

struct S;

impl S {
    fn new() -> impl Trait<Inner = Option<Self>> {
        struct TraitImpl;

        impl Trait for TraitImpl {
            type Inner = Option<S>;
        }

        TraitImpl
    }
}
```
```rust
#![feature(async_await)]

struct Connection;

impl Connection {
    async fn new() -> Result<Self, ()> {
        Ok(S)
    }
}
```
closes #4359

changelog: fix `new_ret_no_self` lint for async `new` functions.
2019-08-12 05:15:16 +00:00
Jeremy Stucki
b651f19eb8
Rename 'flat_map' → 'flat_map_identity' 2019-08-11 20:34:25 +02:00
Jeremy Stucki
f0ce04f814
Handle calls with 'std::convert::identity' 2019-08-11 19:51:43 +02:00
Jeremy Stucki
05d9f884e1
Merge branch 'origin/master' into flat-map 2019-08-11 19:22:40 +02:00
Ralf Jung
2dcce60fdc deprecate invalid_ref lint 2019-08-11 09:31:55 +02:00
Michael Wright
77278ccda9 Fix wrong_self_convention issue
Resolves #4293
2019-08-10 06:01:15 +02:00
Lukas Markeffsky
d55315808d fixed tests (again) and added a test that should actually cause a warning for new_ret_no_self 2019-08-09 23:15:49 +02:00
Lukas Markeffsky
54efffcec1 removed unused imports #2 2019-08-09 19:47:25 +02:00
Lukas Markeffsky
1d2c23a2a5 removed unused imports 2019-08-09 19:44:20 +02:00
Lukas Markeffsky
4fbe9f67ee upgrade test to rust 2018 2019-08-09 19:19:49 +02:00
Lukas Markeffsky
d7b9a845aa new_ret_no_self: walk associated types in impl Trait return types 2019-08-09 17:44:05 +02:00
bors
c55d38ed7a Auto merge of #4362 - lzutao:expect-on-cstring_as_ptr, r=flip1995
Fix lint_cstring_as_ptr for expect

Closes #4312
changelog: none
2019-08-09 09:22:02 +00:00
Lzu Tao
b825cddb6d Add more tests for raw string literal 2019-08-09 06:22:26 +00:00
Lzu Tao
c23a5c586f Fix lint_cstring_as_ptr for expect 2019-08-09 12:39:33 +07:00
Lzu Tao
30cbdc7491 Fix lint_single_char_pattern on raw string literal 2019-08-09 10:55:30 +07:00
bors
4465e2fbb8 Auto merge of #4355 - lzutao:macro_expn_try_err, r=flip1995
Fix macro expansion in try_err lint

Fixes #4309

changelog: none
2019-08-08 15:16:17 +00:00
Lzu Tao
0487b58f9a Fix macro expansion in try_err lint 2019-08-08 20:22:52 +07:00
bors
e76ef1db03 Auto merge of #4339 - phansch:rustfix_needless_bool, r=flip1995
Add run-rustfix for needless_bool lint

This splits up the needless_bool tests into `fixable.rs` and
`simple.rs`. `simple.rs` contains the code that triggers the lint
diagnostic without a suggestion.

changelog: none

cc #3630
2019-08-07 11:00:09 +00:00
Philipp Hansch
0a988c6630
Don't emit enum_variant_names if remainder starts with a numeric
As [per the reference](https://doc.rust-lang.org/reference/identifiers.html),
identifiers must start with a letter. So we don't suggest a better
variant naming in these cases.

Fixes #739
2019-08-06 20:45:36 +02:00
Philipp Hansch
39c8f84f3b
Add run-rustfix for needless_bool lint
This splits up the needless_bool tests into `fixable.rs` and
`simple.rs`. `simple.rs` contains the code that triggers the lint
diagnostic without a suggestion.
2019-08-05 22:10:56 +02:00
Philipp Hansch
4cfb0966a1
Fix needless_bool suggestion with if-else-if-else
Closes #4334
2019-08-05 20:52:38 +02:00
flip1995
dabf599c90
Ignore no_std-test on windows and macos 2019-08-05 17:53:55 +02:00
Vincent Dal Maso
77b21b644f
Move expression check to LateLintPass
Changes:
- Move from EarlyLintPass
- Fix entrypoint check with function path def_id.
2019-08-05 13:23:30 +02:00
Vincent Dal Maso
4eab691db6
Add recursion check on main function
Changes:
- Add MainRecursion lint to clippy
- Check for no-std setup

fixes #333
2019-08-05 13:23:30 +02:00
bors
ca6a9beb31 Auto merge of #4338 - flip1995:rollup-9cm4jbr, r=flip1995
Rollup of 4 pull requests

Successful merges:

 - #4329 (Doctests: Enable running doc tests for pedantic lints)
 - #4330 (Doctests: Enable running doc tests for nursery lints)
 - #4331 (Doctests: Enable running doc tests for restriction lints)
 - #4332 (Split up cast.rs tests, run-rustfix for unnecessary_cast)

Failed merges:

r? @ghost

changelog: none
2019-08-05 09:44:45 +00:00
Philipp Krones
9259eeb689
Rollup merge of #4332 - phansch:rustfix_unnecessary_cast, r=flip1995
Split up cast.rs tests, run-rustfix for unnecessary_cast

This splits up the cast.rs tests and enables rustfix tests for the part
of the `unnecessary_cast` lint that emits `MachineApplicable`
suggestions.

changelog: none

cc #3630
2019-08-05 10:50:07 +02:00
bors
a90b3ba301 Auto merge of #4337 - flip1995:let_unit, r=phansch
Make let_unit lint suggestion auto applicable

changelog: Make `let_unit` lint suggestion auto applicable
2019-08-05 08:41:24 +00:00
flip1995
385f4474da
Add tests for auto fixable let_unit suggestion 2019-08-05 09:31:08 +02:00
Philipp Hansch
a332febb04
Add run-rustfix for decimal_literal_representation lint
cc #3630
2019-08-04 10:21:52 +02:00
Philipp Hansch
2d84d0361d
Split up cast.rs tests, run-rustfix for unnecessary_cast
This splits up the cast.rs tests and enables rustfix tests for the part
of the `unnecessary_cast` lint that emits `MachineApplicable`
suggestions.

cc #3630
2019-08-04 08:24:23 +02:00
bors
18a7dce4da Auto merge of #4314 - chansuke:add-negation-to-is_empty, r=flip1995
Add negation to `len_zero` lint to show more explicit message.

Fixes #4304 I have updated the `len_zero` to show the required negation in case of like the below case.

```
fn main() {
    let v = vec![1];
    if v.len() > 0 {
    }
}
```

changelog: Clarify suggestion of `len_zero` lint.
2019-08-01 14:09:59 +00:00
chansuke
ccc3257c91 Update stderr file 2019-08-01 22:20:08 +09:00
bors
3087e91bed Auto merge of #4316 - phansch:method_rs_cleanup2, r=flip1995
UI Test Cleanup: No wrong_self_convention in methods.rs

These cases are already covered in `tests/ui/wrong_self_convention.rs`.

cc #2038

changelog: none
2019-08-01 08:40:15 +00:00
Michael Wright
be646ac0df Update formatting 2019-08-01 07:09:57 +02:00
Philipp Hansch
533abfa613
UI Test Cleanup: No wrong_self_convention in methods.rs
These cases are already covered in `tests/ui/wrong_self_convention.rs`.

cc #2038
2019-08-01 06:54:57 +02:00
bors
d1b4fc9853 Auto merge of #4313 - Manishearth:owl, r=yaahallo
Don't nudge people towards toilet closures when producing owl results

`.map_err(drop)` should never be linted since sometimes you want to produce `Result<(), ()>` and the alternative is `.map_err(|_| ())`, which can be ugly. We don't seem to, but it's good to specifically test for this.

changelog: none

r? @yaahallo
2019-07-31 17:57:57 +00:00
Manish Goregaokar
38e7bd20f2 Don't nudge people towards toilet closures when producing owl results 2019-07-31 09:10:34 -07:00
Jakub Wieczorek
41110b0039 Extend the use_self lint to suggest uses of Self::Variant. 2019-07-31 08:50:43 +00:00
xd009642
bba2c7f02c Updated tests.
Removed unnecessary type repetition in float test and regenerated stderr
Regenerated type_repetition stderr
2019-07-27 22:53:26 +01:00
xd009642
925e8207fa Respond to review comments
Update README and CHANGELOG using the util scripts, refine the help message and fix the float_cmp error.
2019-07-27 21:58:29 +01:00
xd009642
c962ddbd29 Updated test stderr 2019-07-27 12:07:02 +01:00
xd009642
f71d59e6a6 Lint for type repetition in trait bounds.
This lint adds warning if types are redundantly repeated in trait bounds i.e. `T: Copy, T: Clone` instead of `T: Copy + Clone`. This is a late pass trait lint and has necessitated the addition of code to allow hashing of TyKinds without taking into account Span information.
2019-07-24 21:14:21 +01:00
Matthias Krüger
b0373a5f6b update test stderr, not sure which rustc pull request caused this. 2019-07-24 02:25:03 +02:00
bors
d71e9c4f10 Auto merge of #4266 - uHOOCCOOHu:fix/async_fn_lifetime, r=flip1995
Ignore generated fresh lifetimes in elision check

<!--
Thank you for making Clippy better!

We're collecting our changelog from pull request descriptions.
If your PR only updates to the latest nightly, you can leave the
`changelog` entry as `none`. Otherwise, please write a short comment
explaining your change.

If your PR fixes an issue, you can add "fixes #issue_number" into this
PR description. This way the issue will be automatically closed when
your PR is merged.

If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.

- [ ] Followed [lint naming conventions][lint_naming]
- [ ] Added passing UI tests (including committed `.stderr` file)
- [ ] `cargo test` passes locally
- [ ] Executed `util/dev update_lints`
- [ ] Added lint documentation
- [ ] Run `cargo fmt`

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

Delete this line and everything above before opening your PR -->

fixes #3988

changelog: Ignore generated fresh lifetimes in elision check.

**HELP**: It seems `tests/ui` are compiled under edition 2015, and I don't know how to add tests for this properly.

Here is the test input it had already passed:
```rust
#![feature(async_await)]
#![allow(dead_code)]

async fn sink1<'a>(_: &'a str) {} // lint
async fn sink1_elided(_: &str) {} // ok

async fn one_to_one<'a>(s: &'a str) -> &'a str { s } // lint
async fn one_to_one_elided(s: &str) -> &str { s } // ok
async fn all_to_one<'a>(a: &'a str, _b: &'a str) -> &'a str { a } // ok
// async fn unrelated(_: &str, _: &str) {} // Not allowed in async fn

// #3988
struct Foo;
impl Foo {
    pub async fn foo(&mut self) {} // ok
}

// rust-lang/rust#61115
async fn print(s: &str) { // ok
    println!("{}", s);
}

fn main() {}

```
2019-07-23 09:52:18 +00:00
uHOOCCOOHu
5265ab8723
Fix tests for edition 2018 compatibility 2019-07-23 03:59:09 +08:00
uHOOCCOOHu
434f83a6c7
Revert "Revert global fmt config and use rustfmt::skip"
This reverts commit b70b3b14aa.
2019-07-23 02:57:49 +08:00
Michael Wright
67db88f645 Fix breakage due to rust-lang/rust#62705
Also rename `OUTER_EXPN_INFO` to `OUTER_EXPN_EXPN_INFO` to match new
function names.
2019-07-21 09:36:31 +02:00
uHOOCCOOHu
b70b3b14aa
Revert global fmt config and use rustfmt::skip 2019-07-20 00:50:18 +08:00
uHOOCCOOHu
2cc373ac54
Fix fmt 2019-07-19 23:03:34 +08:00
bors
958af10f12 Auto merge of #4286 - phansch:update_pulldown_cmark3, r=flip1995
Update pulldown-cmark to 0.5.3

Fixes a couple of crashes of which I added one example to our tests.

changelog: Update `pulldown-cmark` to 0.5.3 to fix potential crashes in `doc_markdown` lint
2019-07-19 07:25:55 +00:00
Philipp Hansch
8dc6a462f8
Update pulldown-cmark to 0.5.3 2019-07-19 07:29:25 +02:00
Matthias Krüger
deb586a0c6 rustup https://github.com/rust-lang/rust/pull/62764
(was merged as part of https://github.com/rust-lang/rust/pull/62782 )
2019-07-19 00:35:32 +02:00
uHOOCCOOHu
e6bbed909e
Add test 2019-07-19 02:43:10 +08:00
bors
d509b5afef Auto merge of #4274 - daxpedda:implicit_return_fixes, r=flip1995
false positives fixes of `implicit_return`

-  Handle returning macro statements properly (remove "this error originates in a macro outside of the current crate")
-  Handle functions that return never type
-  Handle functions that panic but do not return never type

changelog: Fix false positives in `implicit_return` lint pertaining to macros and panics
2019-07-18 18:20:40 +00:00
bors
0626674d3c Auto merge of #4280 - phansch:uitests_matches, r=flip1995
UI Test Cleanup: Extract match_ref_pats tests

changelog: none

cc #2038
2019-07-17 08:08:18 +00:00
bors
5dfb5adbac Auto merge of #4259 - Darth-Revan:origin/inherent_to_string, r=flip1995
Implement lint for inherent to_string() method.

Fixes #4247

changelog: Implement two new lints: `inherent_to_string` and `inherent_to_string_shadow_display`

1) Emits a warning if a type implements an inherent method `to_string(&self) -> String`
2) Emits an error if a type implements an inherent method `to_string(&self) -> String` and also implements the `Display` trait
2019-07-17 07:23:25 +00:00
Darth-Revan
b7145fbb66
Fix "unkown clippy lint" error in UI test. 2019-07-17 08:58:36 +02:00
Darth-Revan
f0dc97965a
Corrections for PR review. 2019-07-17 08:58:36 +02:00
Darth-Revan
0513202d25
Implement lint for inherent to_string() method. 2019-07-17 08:58:32 +02:00
bors
fb35311e9a Auto merge of #4278 - phansch:uitestcleanup_indexing, r=flip1995
UI Test Cleanup: Split out out_of_bounds_indexing

This moves the `out_of_bounds_indexing` lint tests to their own
directory.

changelog: none

cc #2038
2019-07-17 06:48:53 +00:00
Philipp Hansch
022b9876c2
UI Test Cleanup: Extract match_ref_pats tests 2019-07-17 08:08:26 +02:00
Philipp Hansch
38b6156a51
Update UI tests 2019-07-16 22:26:47 +02:00
bors
7498a5f13c Auto merge of #4276 - phansch:uitestcleanup, r=flip1995
UI Test Cleanup: Split up checked_unwrap tests

Let's slowly bring that ticket closer to the finish line 🐌 🏁

This splits up `tests/ui/checked_unwrap.rs` into:

 * `tests/ui/checked_unwrap/complex.rs`
 * `tests/ui/checked_unwrap/simple.rs`

Based on the naming of the methods in the tests.

changelog: none

cc #2038
2019-07-16 20:24:03 +00:00
Philipp Hansch
7a888968f9
Allow no_effect lint
for cleaner stderr file

Co-Authored-By: Philipp Krones <hello@philkrones.com>
2019-07-16 21:29:03 +02:00
Philipp Hansch
65e9477b84
Remove comment
Co-Authored-By: Philipp Krones <hello@philkrones.com>
2019-07-16 21:28:37 +02:00
Philipp Hansch
633934da18
cargo fmt 2019-07-16 21:28:03 +02:00
Philipp Hansch
48bff49484
UI Test Cleanup: Split up checked_unwrap tests
This splits up `tests/ui/checked_unwrap.rs` into:

 * `tests/ui/checked_unwrap/complex.rs`
 * `tests/ui/checked_unwrap/simple.rs`

Based on the naming of the methods in the tests.

cc #2038
2019-07-16 21:23:43 +02:00
daxpedda
a2b63af746
Removed lintining on never type.
Abstracted repeating strings into statics.
2019-07-16 14:46:33 +02:00
Philipp Hansch
33010ae7e6
UI Test Cleanup: Split out out_of_bounds_indexing
This moves the `out_of_bounds_indexing` lint tests to their own
directory.
2019-07-16 07:30:23 +02:00
Jerry Hardee
8adbf7f2c1 Fix float_cmp false positive when comparing signum
f1.signum() == f2.signum()
f1.signum() != f2.signum()
should not trigger a warning.
2019-07-15 12:46:58 -05:00
daxpedda
6c067bf50e
false positives fixes of implicit_return
-  Handle returning macro statements properly
-  Handle functions that return never type
-  Handle functions that panic but do not return never type
2019-07-15 16:02:50 +02:00
Michael Wright
de7749832c Fix bug in implicit_hasher causing crashes
Skip linting if the type is from an external macro. Closes #4260.
2019-07-11 08:47:05 +02:00
bors
032ae96856 Auto merge of #4257 - skade:improve-cast-alignment, r=flip1995
Improve cast_ptr_alignment lint

<!--
Thank you for making Clippy better!

We're collecting our changelog from pull request descriptions.
If your PR only updates to the latest nightly, you can leave the
`changelog` entry as `none`. Otherwise, please write a short comment
explaining your change.

If your PR fixes an issue, you can add "fixes #issue_number" into this
PR description. This way the issue will be automatically closed when
your PR is merged.

If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.

- [x] Followed [lint naming conventions][lint_naming]
- [x] Added passing UI tests (including committed `.stderr` file)
- [x] `cargo test` passes locally
- [x] Executed `util/dev update_lints`
- [x] Added lint documentation
- [x] Run `cargo fmt`

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

Delete this line and everything above before opening your PR -->

* print alignment in bytes in the lint message
* ignore ZST left-hand types

Fixes #3797 and #4256
changelog:
* `cast_ptr_alignment`: Print alignment in bytes in the lint message
* `cast_ptr_alignment`: Ignore casting from ZST left-hand types
2019-07-09 15:28:26 +00:00
Florian Gilcher
aa72cac87a
Improve cast_ptr_alignment lint
* print alignment in bytes in the lint message
* ignore ZST left-hand types
2019-07-09 17:02:26 +02:00
bors
5c921a9f61 Auto merge of #4233 - thiagoarrais:jens1o-fix-1208, r=phansch,flip1995
Avoid reporting string_lit_as_bytes for long strings

Port of @jens1o code ([b76f939][jens1o_commit])

Fixes #1208

[jens1o_commit]: b76f939ac2

<!--
Thank you for making Clippy better!

We're collecting our changelog from pull request descriptions.
If your PR only updates to the latest nightly, you can leave the
`changelog` entry as `none`. Otherwise, please write a short comment
explaining your change.

If your PR fixes an issue, you can add "fixes #issue_number" into this
PR description. This way the issue will be automatically closed when
your PR is merged.

If you added a new lint, here's a checklist for things that will be
checked during review or continuous integration.

- [ ] Followed [lint naming conventions][lint_naming]
- [ ] Added passing UI tests (including committed `.stderr` file)
- [ ] `cargo test` passes locally
- [ ] Executed `util/dev update_lints`
- [ ] Added lint documentation
- [ ] Run `cargo fmt`

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

Delete this line and everything above before opening your PR -->

changelog: bugfix for long strings as bytes
2019-07-09 09:48:33 +00:00
Bara
2fb73fe037 Use empty block instead of unit type for needless return 2019-07-08 20:45:51 +02:00
Jens Hausdorf
6d1aaac6c3 Avoid reporting string_lit_as_bytes for long strings
Port of @jens1o code ([b76f939][jens1o_commit])

Fixes #1208

[jens1o_commit]: b76f939ac2

Co-authored-by: Thiago Arrais <thiago.arrais@gmail.com>
2019-07-08 13:13:01 -03:00
Jeremy Stucki
1fd617d6df
Add test for unnecessary_flat_map 2019-07-08 17:11:52 +02:00
Lzu Tao
481499101b Remove lint for ONCE_INIT
ONCE_INIT will be deprecated in rust 1.38.0
2019-07-06 12:34:32 +07:00
Lzu Tao
3a76bea04b Update rustfix tests 2019-07-06 12:34:32 +07:00
Michael Wright
8fa023272f Fix allow bug in trivially_copy_pass_by_ref
Closes #3992
2019-07-03 07:15:21 +02:00
Michael Wright
c199d9068e Fix match_same_arms false negative
Closes #4244
2019-07-02 08:18:55 +02:00
flip1995
fb56e90e12
Test for melted ICE #4121 2019-07-01 15:53:48 +02:00
bors
47ada9ae07 Auto merge of #4243 - mikerite:fix-4058, r=flip1995
Fix `never_loop` false positive

Closes #4058

changelog: none
2019-07-01 08:10:25 +00:00
bors
ad638a3e42 Auto merge of #4222 - jfrikker:try_err, r=flip1995
Adding try_err lint

changelog: Adds the "try_err" lint, which catches instances of the following: Err(x)?
fixes #4212
2019-07-01 07:41:33 +00:00
Michael Wright
7c98915da9 Fix never_loop false positive
Closes #4058
2019-07-01 07:22:04 +02:00
Joe Frikker
c96bb2c303 Running rustfmt on test 2019-06-30 18:28:12 -04:00
Alex Gaynor
fffdbc0e8f Removed use of intrinsics::uninit from tests.
This is in preperation for https://github.com/rust-lang/rust/pull/62150

Also allows deprecations in preperations for intrinsics::init being deprecated, which is a planned future step.
2019-06-29 09:34:42 -04:00
Joe Frikker
8880677b4f Making try_err machine applicable 2019-06-24 21:28:46 -04:00
Joe Frikker
1e6c6976dd PR comments 2019-06-23 18:02:13 -04:00
Mazdak Farrokhzad
6ef8b57e34 Account for let_chains in collapsible_if ui test cases. 2019-06-23 17:24:45 +02:00
Joe Frikker
60a80849ce Adding try_err lint 2019-06-22 16:37:05 -04:00
Daniele D'Orazio
66dbc02b05 more idiomatic code 2019-06-21 14:46:34 +02:00