Commit graph

2327 commits

Author SHA1 Message Date
Lzu Tao
0487b58f9a Fix macro expansion in try_err lint 2019-08-08 20:22:52 +07: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
Michael Wright
fd9c5a3c71 Merge branch 'master' into dev-fmt-20190728 2019-08-01 07:02:48 +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
bors
c3e913650e Auto merge of #3766 - xd009642:issue-3764, r=flip1995
trait bounds lint - repeated types

This PR is to tackle https://github.com/rust-lang/rust-clippy/issues/3764 it's still a WIP and doesn't work but this is an initial stab. It builds though I haven't added any tests as I'm not sure where lint tests should go?

Unfortunately, it seems id isn't tied to the type itself but I guess where it is in the AST? Looking at https://manishearth.github.io/rust-internals-docs/syntax/ast/struct.Ty.html I can't see any members that would let me tell if a type was repeated in multiple trait bounds.

There may be other issues with how I've implemented this so any assistance is appreciated!

changelog: Add new lint: `type_repetition_in_bounds`
2019-07-30 12:11:17 +00:00
Michael Wright
a9714227bd Enable rustfmt tests
This reverts commit d73a953db7.
2019-07-28 06:45:23 +02:00
Michael Wright
dae4076760 Skip fmt test if rustfmt is unavailble 2019-07-28 06:45:09 +02: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
Matthias Krüger
d73a953db7 ci: temporarily disable rustfmt checks/tetss since it's broken for nightly 2019-07-27 17:47:51 +02: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