Commit graph

2971 commits

Author SHA1 Message Date
BO41
3f56cb5d8b Add example to a perf lint 2019-08-22 15:41:07 +02:00
BO41
43a2ba34e6 Add examples to some correctness lints 2019-08-22 15:41:07 +02:00
bors
57c67a29d2 Auto merge of #4352 - phansch:fix_redundant_pattern_matching, r=flip1995
Fix some suggestions for redundant_pattern_matching

.. and change the Applicability to `MaybeIncorrect`.

Fixes the problem displayed in https://github.com/rust-lang/rust-clippy/issues/4344#issuecomment-519206388.

We now append `{}` to the suggestion so that the conditional has the
correct syntax again.

(If we were to _remove_ the `if` instead, it would trigger the
`unused_must_use` warning for `#[must_use]` types.)

changelog: Fix some suggestions for `redundant_pattern_matching`
2019-08-21 08:15:36 +00:00
Michael Wright
59893bcab0 Fix temporary_cstring_as_ptr false negative
Fixes #4375.

Changes the check to test when `.unwrap().as_ptr()` is called on any
`Result<CString, _>` as suggested by @flip1995
(https://github.com/rust-lang/rust-clippy/issues/4375#issuecomment-520724123).
2019-08-21 07:35:04 +02:00
Philipp Hansch
0d85d7e60f
Fix suggestions for redundant_pattern_matching
Fixes the problem displayed in https://github.com/rust-lang/rust-clippy/issues/4344#issuecomment-519206388.

We now append `{}` to the suggestion so that the conditional has the
correct syntax again.

(If we were to _remove_ the `if` instead, it would trigger the
`unused_must_use` warning for `#[must_use]` types.
2019-08-21 07:29:44 +02:00
bors
835205b8da Auto merge of #4401 - JJJollyjim:literal-separation-suggestion, r=flip1995
Add autofixable suggestion for unseparated integer literal suffixes

changelog: Add autofixable suggestion for unseparated integer literal suffixes

Somewhat WIP, since I haven't been able to get this working when adding `// run-rustfix` to `ui/literals.rs`. I think the issue is that there are multiple suggestions operating on one numerical literal, and I'm not sure what the best approach is to work around that.

Thanks
2019-08-20 07:54:25 +00:00
Philipp Hansch
1055cf5b9f
Merge pull request #4416 from SimonSapin/plugin
Import rustc_plugin from its new location
2019-08-20 07:28:59 +02:00
KRAAI, MATTHEW [VISUS]
eaf8f08390 Restore en dashes 2019-08-19 12:38:33 -07:00
KRAAI, MATTHEW [VISUS]
204b2f3658 Remove in_macro_or_desugar 2019-08-19 09:30:32 -07:00
Simon Sapin
08d8ffc6a9 Import rustc_plugin from its new location
Depends on https://github.com/rust-lang/rust/pull/62727
2019-08-19 17:52:10 +02:00
bors
5c71c1b838 Auto merge of #4411 - mikerite:fix-4384, r=flip1995
Fix `clone_on_copy` false positives

Closes #4384

changelog: Fix `clone_on_copy` false positives
2019-08-19 08:04:12 +00:00
bors
d1f1844f46 Auto merge of #4386 - lzutao:lint-option-and_then-some, r=flip1995
Add option_and_then_some lint

changelog: Add complexity lint to warn about `option.and_then(|o| Some(x))` and suggest replacing with `option.map(|o| x)`.

Closes #4299
2019-08-19 07:35:53 +00:00
Michael Wright
68a1af540c Fix clone_on_copy false positives
Closes #4384
2019-08-19 08:19:54 +02:00
Matthias Krüger
88f417e446 try to fix build in rustc repo 2019-08-19 06:10:00 +02:00
Lzu Tao
7065239da5 Add option_and_then_some lint 2019-08-19 03:54:40 +00:00
Jamie McClymont
4ee9d02efa Requested changes 2019-08-19 14:20:38 +12:00
bors
f01a0c0e08 Auto merge of #4403 - xd009642:type_repetition_improvements, r=phansch,flip1995
Improvements to `type_repetition_in_bounds`

Improvements to the `type_repetition_in_bounds` trait based on feedback from #4380 #4326 #4323

Currently just make it pedantic. Hopefully, more to come

changelog: move `type_repetition_in_bounds` to `pedantic`
2019-08-18 21:03:21 +00:00
bors
6668e629ba Auto merge of #4404 - BO41:patch-1, r=flip1995
Add "could be written as" example to MANUAL_MEMCPY

<!--
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 `./util/dev fmt`

[lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints

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: none
2019-08-18 20:34:25 +00:00
xd009642
76598adafb Run update_lints 2019-08-18 16:59:31 +01:00
Jeremy Stucki
9c39c02b75
Change lint type to 'complexity' 2019-08-18 16:49:11 +02:00
Jamie McClymont
c8fb62148e Add autofixable suggestion for unseparated integer literal suffices 2019-08-19 02:46:12 +12:00
Jeremy Stucki
5df84f2192
Merge branch 'origin/master' into suspicious_map 2019-08-18 16:37:31 +02:00
Michael Wright
b313d25350 Fix breakage due to rust-lang/rust#61708 2019-08-18 13:14:47 +02:00
Lzu Tao
533bdfbdbc Fix assertions_on_constants lint 2019-08-18 02:34:30 +07:00
Lzu Tao
439284b584 Make code cleaner and more readable 2019-08-18 01:47:45 +07:00
BO41
b17cb32bcb
Add "could be written as" example to MANUAL_MEMCPY 2019-08-17 13:09:03 +00:00
xd009642
c1e57402d3 Made lint pedantic 2019-08-17 11:45:05 +01:00
bors
49dff2c9f3 Auto merge of #4397 - kraai:remove-a, r=flip1995
Remove "a" from single_match_else description

changelog: none
2019-08-16 20:04:39 +00:00
flip1995
2456b355f2
Run rustfmt 2019-08-16 19:05:44 +02:00
KRAAI, MATTHEW [VISUS]
f74d9db7f4 Use outer_expn_data instead of outer_expn_info 2019-08-16 09:31:12 -07:00
KRAAI, MATTHEW [VISUS]
a68abc03a2 Remove "a" from single_match_else description 2019-08-16 05:41:35 -07:00
Lzu Tao
65b906a8fc Rustup "Remove Spanned from {ast,hir}::FieldPat" 2019-08-16 09:32:27 +07:00
Jeremy Stucki
f4f31a4ff4
Implement lint 'suspicious_map' 2019-08-15 22:58:32 +02:00
flip1995
ebd3eeaede
Also specify patch version of toml crate 2019-08-15 15:58:36 +02:00
bors
607b8299c5 Auto merge of #4382 - jeremystucki:unnecessary_fold_span, r=flip1995
Change span of unnecessary_fold lint

Resolves #4381

changelog: Change linted span of `unnecessary_fold`
2019-08-15 12:57:51 +00:00
bors
a3da66d6d3 Auto merge of #4348 - phansch:deprecate-unused-unused-collect, r=flip1995
Deprecate unused_collect lint

I found this because we only had two test cases in total for this lint.
It turns out the functionality is fully covered by rustc these days.

[Playground Examples](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=eb8ee6db389c77180c9fb152d3c608f4)

changelog: Deprecate `unused_collect` lint. This is fully covered by rustc's `#[must_use]` on `collect`

cc #2846
2019-08-15 10:47:20 +00:00
flip1995
9533fa5b19
Rustup to rust-lang/rust#63543 2019-08-15 10:14:06 +02:00
Philipp Hansch
42f03539ca
Deprecate unused_collect lint
I found this because we only had two test cases in total for this lint.
It turns out the functionality is fully covered by rustc these days.

[Playground Examples](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=eb8ee6db389c77180c9fb152d3c608f4)

changelog: Deprecate `unused_collect` lint. This is fully covered by
rustc's `#[must_use]` on `collect`

cc #2846
2019-08-14 21:47:11 +02:00
Jeremy Stucki
fdf82eb1a8
Remove unused import 2019-08-14 20:24:05 +02:00
Jeremy Stucki
08f658bc72
Use different span 2019-08-14 19:35:06 +02:00
bors
dbe2bb4256 Auto merge of #4379 - matthiaskrgr:url_dep, r=phansch
update url dependency from 1.7.0 to 2.1.0

changelog: none
2019-08-14 13:07:19 +00:00
bors
06430e7af4 Auto merge of #4363 - phansch:fix_lint_deprecation, r=flip1995
Update lint deprecation for tool lints

changelog: Allow tool lints (`clippy::*`) to be deprecated

Our lint deprecation previously didn't work for tool lints, because
`register_removed` was registering lints to be removed _without_ the
`clippy` prefix.

Fixes #4349
2019-08-14 11:37:10 +00:00
Matthias Krüger
37d79d9a29 update url dependency from 1.7.0 to 2.1.0 2019-08-14 13:04:17 +02:00
bors
63d2d066f9 Auto merge of #4369 - mikerite:fix-4293, r=flip1995
Fix `wrong_self_convention` issue

Resolves #4293

changelog: Fix `wrong_self_convention` issue
2019-08-14 10:59:36 +00:00
Jeremy Stucki
2bfcf89f82
Merge branch 'origin/master' into flat-map 2019-08-14 07:36:37 +02:00
Jeremy Stucki
d578c43c51
Use correct span 2019-08-13 21:50:42 +02:00
Jeremy Stucki
4275d7b6ac
Run 'update_lints' 2019-08-12 21:47:12 +02:00
Jeremy Stucki
d51136d594
Use 'span_lint_and_sugg' 2019-08-12 21:42:57 +02:00
Jeremy Stucki
3a65e4e75a
Minor refactoring 2019-08-12 21:29:33 +02:00
Philipp Hansch
b50c13c578
Fix invalid_ref deprecation 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
Jeremy Stucki
09e9568c26
Change lint type from 'pedantic' → 'complexity' 2019-08-12 10:53:23 +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
df9063013e
Update rustdoc 2019-08-11 22:18:58 +02:00
Jeremy Stucki
5fd7d44f36
Refactor if_chain
Co-authored-by: Philipp Krones <hello@philkrones.com>
2019-08-11 21:02:01 +02: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
Vallentin
b7460ad70b Fixed repeated word 2019-08-11 12:56:30 +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
Michael Wright
170d4861c6 Simplify wrong_self_convention code
Use actual types instead of hir types.
2019-08-10 06:00:27 +02:00
Michael Wright
ebd24985bf Rename implitem to impl_item
`impl_item` is proper snake case and used everywhere else.
2019-08-10 05:58:52 +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
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
d23e6b396a Auto merge of #4358 - lzutao:cleanup_implicit_return, r=flip1995
Use source_callsite() instead of recursive outer_expn_info()

changelog: none
2019-08-08 16:36:44 +00: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
59a35874c1 Use source_callsite() instead of recursive outer_expn_info() 2019-08-08 21:28:40 +07:00
Lzu Tao
90a7b60413 Use snippet_with_macro_callsite suggested by flip1995 2019-08-08 21:21:59 +07:00
Lzu Tao
0487b58f9a Fix macro expansion in try_err lint 2019-08-08 20:22:52 +07:00
bors
286d528a45 Auto merge of #4345 - phansch:enum_variants_fix, r=flip1995
Don't emit enum_variant_names if remainder starts with a numeric

changelog: Fix false positive in `pub_enum_variant_names` and `enum_variant_names`

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 case the remainder would start with a numeric.

Fixes #739
2019-08-07 10:22:06 +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
Lzu Tao
e4f8cd9672 Rustup https://github.com/rust-lang/rust/pull/59369 2019-08-06 19:20:41 +07:00
Philipp Hansch
cdfb72a5e1
fmt 2019-08-05 20:53:24 +02:00
Philipp Hansch
4cfb0966a1
Fix needless_bool suggestion with if-else-if-else
Closes #4334
2019-08-05 20:52:38 +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
93c3da223f
Rollup merge of #4331 - phansch:doctests_restriction, r=flip1995
Doctests: Enable running doc tests for restriction lints

changelog: Enabled remaining doc tests for lint documentation page

master: 202 passed; 0 failed; 122 ignored; 0 measured; 0 filtered out
this PR: 231 passed; 0 failed; 123 ignored; 0 measured; 0 filtered out

Closes #4319 (assuming this is merged after #4329 and #4330)
2019-08-05 10:50:06 +02:00
Philipp Krones
f5db24a59f
Rollup merge of #4330 - phansch:doctests_nursery, r=flip1995
Doctests: Enable running doc tests for nursery lints

changelog: none

master: 202 passed; 0 failed; 122 ignored; 0 measured; 0 filtered out
this PR: 213 passed; 0 failed; 122 ignored; 0 measured; 0 filtered out

cc #4319
2019-08-05 10:50:04 +02:00
Philipp Krones
713ad964af
Rollup merge of #4329 - phansch:doctests_pedantic, r=flip1995
Doctests: Enable running doc tests for pedantic lints

changelog: none

master: 202 passed; 0 failed; 122 ignored; 0 measured; 0 filtered out
this PR: 254 passed; 0 failed; 131 ignored; 0 measured; 0 filtered out

cc #4319
2019-08-05 10:50:03 +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
c5ad0b075a
Make let_unit lint suggestion auto applicable 2019-08-05 09:31:08 +02:00
Philipp Hansch
71a943820b
Rustup to https://github.com/rust-lang/rust/pull/63213 2019-08-05 07:30:01 +02:00
Philipp Hansch
b608e02e1c
Doctests: Enable running doc tests for restriction lints 2019-08-03 21:24:50 +02:00
Philipp Hansch
2f48effc92
Doctests: Enable running doc tests for nursery lints 2019-08-03 21:01:23 +02:00
Philipp Hansch
1dc9a5012e
Doctests: Enable running doc tests for pedantic lints 2019-08-03 20:36:38 +02:00
bors
5c1e30ab05 Auto merge of #4327 - phansch:doctests_perf, r=flip1995
Doctests: Enable running doc tests for perf lints

changelog: none

This should be possible to merge independently of #4325

cc #4319
2019-08-03 14:06:13 +00:00
bors
3dc91838e4 Auto merge of #4325 - phansch:doctests_complexity, r=flip1995
Doctests: Enable running doc tests for complexity lints

changelog: none

master: `113 passed; 0 failed; 91 ignored; 0 measured; 0 filtered out`
this PR: `181 passed; 0 failed; 110 ignored; 0 measured; 0 filtered out`

cc #4319
2019-08-03 13:24:07 +00:00
Philipp Hansch
d61df4f609
Rustup to latest rustc master
Broken due to:

* https://github.com/rust-lang/rust/pull/63180 (`Existential` -> `OpaqueTy`)
* https://github.com/rust-lang/rust/pull/63121 (New fields for `FormatSpec`)
2019-08-03 08:44:32 +02:00
Philipp Hansch
eb68dc9a1a
Also enable doc tests for internal lints
Because there were fixed in the parent commit.
2019-08-03 08:12:53 +02:00
Philipp Hansch
c0cdfd296e
Doctests: Enable running doc tests for perf lints
This should be possible to merge independently of #4325

cc #4319
2019-08-03 08:08:00 +02:00
Philipp Hansch
abfa8a952c
Doctests: Fix all complexity lint docs
cc #4319
2019-08-02 18:16:35 +02:00
bors
d43ef7aa3f Auto merge of #4322 - Y0hy0h:patch-1, r=phansch
Improve documentation on implicit_hasher lint

Provide an example of how to fix the implicit_hasher lint.

Fixes #3475.

changelog: none
2019-08-01 18:58:11 +00:00
Y0hy0h
5decadd93e
Fix missing import 2019-08-01 17:54:22 +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
flip1995
feca48d8a2
Fix doc tests 2019-08-01 15:14:06 +02:00
flip1995
7a73b8fdfa
Remove Known problems for UNNECESSARY_UNWRAP
This shouldn't happen with NLL
2019-08-01 15:14:06 +02:00
flip1995
e6a836e2e8
Move UNNECESSARY_UNWRAP to complexity and PANICKING_UNWRAP to correctness 2019-08-01 15:14:06 +02:00
bors
c8e5352d9b Auto merge of #4318 - izik1:typo, r=phansch
Fix `for on` typo

<!--
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 -->

closes #4317

changelog: minor typo fix
2019-08-01 09:20:32 +00:00
Y0hy0h
d7224a6341
Improve documentation on implicit_hasher lint
Provide an example of how to fix the lint.
2019-08-01 10:51:39 +02:00
bors
5d061d7058 Auto merge of #4315 - phansch:fn_to_numeric_cast_applicability, r=flip1995
Mark `fn_to_numeric_cast` lints as MaybeIncorrect

At least for now so that `cargo fix --clippy` is not causing problems
with this lint. See #3896 for the remaining problems with the suggestions of this lint.

changelog: none

cc #3630, #3896
2019-08-01 07:59:51 +00:00
Zachery Gyurkovitz
b8a50cae4c
Fix for on typo 2019-07-31 22:24:57 -07:00
Michael Wright
be646ac0df Update formatting 2019-08-01 07:09:57 +02:00
Philipp Hansch
04ca58a691
Mark fn_to_numeric_cast lints as MaybeIncorrect
At least for now so that `cargo fix --clippy` is not causing problems
with this lint.

cc #3630, #3896
2019-07-31 21:05:31 +02:00
chansuke
2d467dca62 Add required negation in non_zero lint 2019-08-01 00:23:09 +09:00
Jakub Wieczorek
2a13e83f2b Update all the code to pass the updated use_self lint.
One struct required a temporary `#[allow(dead_code)]` annotation due to
a bug in the Rust compiler: https://github.com/rust-lang/rust/issues/63151.
2019-07-31 08:50:43 +00: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
2f5c1d031d Fix breakage due to rust-lang/rust#61856 2019-07-30 06:39:51 +02:00
xd009642
78ebcaa526 Fix dogfood test 2019-07-28 09:31:05 +01:00
xd009642
03c543515a Hash discriminant of lifetime.name 2019-07-27 23:04:36 +01:00
xd009642
ad637193f0 Hash discriminant of Lifetime::Name 2019-07-27 22:59:46 +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
5e9906b2c6 Added doc comment fixed type printout
Added a doc comment for the lint and fixed the printout of the type so it prints T not type(T)
2019-07-27 12:06:25 +01:00
xd009642
cac69ec063 Respond to comments and improve printout
Now get the trait names for the diagnostic message and removed more
`let c: fn(_) -> _ = T; hashes from hir_utils
2019-07-27 11:51:27 +01:00
Matthias Krüger
f195550148 rustup https://github.com/rust-lang/rust/pull/62964 2019-07-26 22:58:31 +02:00
xd009642
7853dac662 Responded to comments and fixed compile bug
Removed the hash of `let c: fn(_,_) -> _ = ExprKind::Cast` and
fixed compile issue by collecting HirVec into an actual Vec
2019-07-26 16:46:47 +01:00
xd009642
c0259179c3 Fixed more compile errors
Moved to rustc::hir::Ty
2019-07-24 22:59:32 +01:00
xd009642
792153104c Fix some of the compile errors 2019-07-24 22:27:12 +01:00
xd009642
f3e4467c10 Changed Ty to ty, added lifetime 'tcx 2019-07-24 21:14:21 +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
2221fc8124 rustup https://github.com/rust-lang/rust/pull/62859 2019-07-24 02:20:36 +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
Michael Wright
f05e295685 Fix breakage due to rust-lang/rust#60913 2019-07-21 12:52:14 +02: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
Philipp Hansch
8dc6a462f8
Update pulldown-cmark to 0.5.3 2019-07-19 07:29:25 +02: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
flip1995
fc57b43f79
Format code 2019-07-18 17:23:22 +02:00
daxpedda
9e5e0f8f84
Improved imports 2019-07-17 20:44:09 +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
daxpedda
a2b63af746
Removed lintining on never type.
Abstracted repeating strings into statics.
2019-07-16 14:46:33 +02:00
Jerry Hardee
8a8eedf388 Lint 2019-07-15 14:00:07 -05: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
b523d35d41 Deny warnings in CI 2019-07-15 07:35:02 +02:00
bors
10b915fa7e Auto merge of #4268 - mikerite:fix-4260, r=flip1995
Fix bug in `implicit_hasher` causing crashes

Skip linting if the type is from an external macro. Closes #4260.

changelog: Fix bug in `implicit_hasher` causing crashes
2019-07-13 08:59:12 +00:00
Lzu Tao
27c5348793 Rustup macro expansion and resolution 2019-07-12 00:26:36 +07: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
uHOOCCOOHu
a9bec0c8a6
Ignore generated fresh lifetimes in elision check. 2019-07-10 01:57:25 +08: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
Vinzent Steinberg
f831b0979e
cast_ptr_alignment: Mention legal use under known problems
Refs #2881.
2019-07-09 14:48:48 +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
Thiago Arrais
7d1a9447ea Extract semantic constant 2019-07-08 17:51:13 -03:00
Bara
2fb73fe037 Use empty block instead of unit type for needless return 2019-07-08 20:45:51 +02:00