Commit graph

5119 commits

Author SHA1 Message Date
Takayuki Nakata
e1743ef525 Fix a style of texts in map_err_ignore 2020-12-25 08:59:34 +09:00
bors
25e9acb253 Auto merge of #6476 - 1c3t3a:1c3t3a-from-over-into, r=llogiq
Added from_over_into lint

Closes #6456
Added a lint that searches for implementations of `Into<..>` and suggests to implement `From<..>` instead, as it comes with a default implementation of `Into`. Category: style.

changelog: added `from_over_into` lint
2020-12-22 12:06:08 +00:00
Matthias Krüger
af22613a25 remove clone in manual_async_fn lint 2020-12-22 03:12:12 +01:00
Philipp Hansch
12bd244caa
Don't trigger large_enum_variant in external macros 2020-12-21 11:09:49 +01:00
llogiq
0d6c128bfd
Update clippy_lints/src/from_over_into.rs
Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
2020-12-21 09:18:30 +01:00
Bastian Kersting
7e641c8be7 Fixed error messages 2020-12-20 22:00:34 +01:00
flip1995
883a3d10c8
Merge remote-tracking branch 'upstream/master' into rustup 2020-12-20 16:48:04 +01:00
Bastian Kersting
dd005c17e7 Added MSRV and fixed typo 2020-12-20 13:00:17 +01:00
bors
9f9e9f7e52 Auto merge of #6316 - ThibsG:WrongSelfConventionTraitDef, r=ebroto
Lint also in trait def for `wrong_self_convention`

Extends `wrong_self_convention` to lint also in trait definition.

By the way, I think the `wrong_pub_self_convention` [example](dd826b4626/clippy_lints/src/methods/mod.rs (L197)) is misleading.
On [playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=32615ab3f6009e7e42cc3754be0ca17f), it fires `wrong_self_convention`, so the example (or the lint maybe?) needs to be reworked.
The difference with `wrong_self_convention` [example](dd826b4626/clippy_lints/src/methods/mod.rs (L172)) is mainly the `pub` keyword on the method `as_str`, but the lint doesn't use the function visibility as condition to choose which lint to fire (in fact it uses the visibility of the impl item).

fixes: #6307

changelog: Lint `wrong_self_convention` lint in trait def also
2020-12-19 21:39:19 +00:00
Bastian Kersting
a451b2af30 Added from_over_into lint 2020-12-19 17:00:40 +01:00
Jack Huey
f00b6ac24e More rebinds 2020-12-19 04:26:35 -05:00
bors
0718eeb648 Auto merge of #6464 - ahouts:make-needless_update-ignore-non_exhaustive-structs, r=phansch
make needless_update ignore non_exhaustive structs

changelog: make `needless_update` lint ignore `non_exhaustive` structs

fixes #6323
2020-12-19 07:35:04 +00:00
Andrew Houts
a24c6f14fa remove example 2020-12-18 19:15:05 -06:00
bors
896d82f7ff Auto merge of #6465 - Suyash458:master, r=flip1995
add more lints to msrv docs

Fixes #6097

changelog: None
2020-12-18 09:36:05 +00:00
bors
88323e856d Auto merge of #6458 - ebroto:6022_parse_doctest, r=Manishearth
needless_doctest_main: handle correctly parse errors

Before this change, finding an error when parsing a doctest would make Clippy exit without emitting an error. Now we properly catch a fatal error and ignore it.

Also, if a doctest specifies an edition in the info line, it will be used when parsing it.

changelog: needless_doctest_main: handle correctly parse errors

Fixes #6022
2020-12-18 06:57:21 +00:00
Suyash458
920c9a4aae add more lints to msrv docs 2020-12-18 10:55:09 +05:30
Andrew Houts
1eb7608a2e make needless_update ignore non_exhaustive structs 2020-12-17 21:28:16 -06:00
bors
8e9a538ae1 Auto merge of #79945 - jackh726:existential_trait_ref, r=nikomatsakis
Move binder for dyn to each list item

This essentially changes `ty::Binder<&'tcx List<ExistentialTraitRef>>` to `&'tcx List<ty::Binder<ExistentialTraitRef>>`.

This is a first step in moving the `dyn Trait` representation closer to Chalk, which we've talked about in `@rust-lang/wg-traits.`

r? `@nikomatsakis`
2020-12-17 18:21:20 +00:00
Eduardo Broto
bb68ec6cfc Apply suggestion from PR review 2020-12-17 15:28:05 +01:00
Yuki Okushi
286e492343 Rollup merge of #79051 - LeSeulArtichaut:if-let-guard, r=matthewjasper
Implement if-let match guards

Implements rust-lang/rfcs#2294 (tracking issue: #51114).

I probably should do a few more things before this can be merged:
- [x] Add tests (added basic tests, more advanced tests could be done in the future?)
- [x] Add lint for exhaustive if-let guard (comparable to normal if-let statements)
- [x] Fix clippy

However since this is a nightly feature maybe it's fine to land this and do those steps in follow-up PRs.

Thanks a lot `@matthewjasper` ❤️ for helping me with lowering to MIR! Would you be interested in reviewing this?
r? `@ghost` for now
2020-12-17 11:43:55 +09:00
Naughty
1d6fac6167
Typo: std::fs::crate_dir -> std::fs::create_dir 2020-12-16 20:48:03 -03:00
bors
142f0f5eda Auto merge of #6448 - mikerite:interning_defined_symbol, r=Manishearth
New internal lint: Interning defined symbol

New internal lint: interning_defined_symbol

changelog: none
2020-12-16 08:18:38 +00:00
Michael Wright
f732cc5cd6 Remove unsafe code 2020-12-16 06:05:25 +02:00
Eduardo Broto
41b5ebebfd needless_doctest_main: add edition support 2020-12-16 00:14:47 +01:00
Eduardo Broto
39bcf8e554 Handle fatal errors when parsing doctests 2020-12-15 23:18:03 +01:00
bors
d9241640e8 Auto merge of #6435 - xFrednet:5552-false-positive-match-single-binding, r=ebroto
Fixing a false positive for the `match_single_binding` lint #5552

This is a fix for a false positive in the `match_single_binding` lint when using `#[cfg()]` on a branch. It is sadly a bit hacky but maybe the best solution as rust removes the other branch from the AST before we can even validate it. This fix looks at the code snippet itself and returns if it includes another thick arrow `=>` besides the one matching arm we found. This can again cause false negatives if someone has the following code:
```rust
match x {
    // => <-- Causes a false negative
    _ => 1,
}
```

I thought about making the code more complex and maybe validating against other things like the `#[cfg()]` macro but I believe that this is the best solution. This has basically switched the issue from a false positive to a false negative in a very specific case.

I'm happy to make some changes if you have any suggestions 🙃.

---
Fixes #5552

changelog: Fixed a false positive in the `match_single_binding` lint with `#[cfg()]` macro
2020-12-13 21:28:38 +00:00
xFrednet
a37af06fea Removing false positive for the match_single_binding lint
* Applying suggested changes from the PR
2020-12-13 20:49:39 +00:00
bors
6b2b3576eb Auto merge of #6449 - matthiaskrgr:needless_borrow_ty, r=ebroto
needless_borrow: print the type in the lint message

changelog: needless_borrow: print type in lint message
2020-12-13 16:59:02 +00:00
bors
1df2e38219 Auto merge of #6443 - matthiaskrgr:clone_on_copy_type, r=ebroto
clone_on_copy: show the type in the lint message

changelog: clone_on_copy: show the type in the lint message
2020-12-13 16:47:33 +00:00
Matthias Krüger
cd2a62cb0c needless_borrow: print the type in the lint message
changelog: needless_borrow: print type in lint message
2020-12-13 15:29:18 +01:00
bors
b7db5bfc50 Auto merge of #6442 - matthiaskrgr:clone-double-ref-ty, r=llogiq
clone_double_ref: print reference type in lint message

changelog: clone_double_ref: print the type of the reference in lint message
2020-12-13 10:09:00 +00:00
Michael Wright
64e630c280 Run 'cargo dev update_lints' 2020-12-13 06:46:21 +02:00
Michael Wright
a6aa0acbea Fix dogfood errors 2020-12-13 06:32:41 +02:00
Michael Wright
3af09b8cf1 New internal lint: interning_defined_symbol 2020-12-13 06:32:41 +02:00
bors
89c282fb63 Auto merge of #6318 - camsteffen:article-description, r=Manishearth
Use article_and_description for missing docs

Moves closer to the current rustc missing_doc lint

changelog: none
2020-12-12 21:20:40 +00:00
Matthias Krüger
b2cb6ffbe3 clone_on_copy: show the type in the lint message
changelog: clone_on_copy: show the type in the lint message
2020-12-12 01:23:28 +01:00
Matthias Krüger
0b145d688b clone_double_ref: print reference type in lint message
changelog: clone_double_ref: print the type of the reference in lint message
2020-12-12 01:09:30 +01:00
Jack Huey
30ef1770d3 Move binder for dyn to each list item 2020-12-11 15:02:46 -05:00
Takayuki Nakata
26c61c7e49 Fix FP of manual_range_contains in const fn 2020-12-11 23:07:52 +09:00
bors
27fd6ed581 Auto merge of #6424 - Suyash458:master, r=flip1995
Add MSRV to more lints specified in #6097

add MSRV to more lints specified in #6097
add instructions for adding msrv in other lints
update tests

 - [x] `redundant_field_names` requires Rust 1.17 due to suggest feature stablized in that version.
 - [x] `redundant_static_lifetimes` requires Rust 1.17 due to suggest feature stablized in that version.
 - [x] `filter_map_next` requires Rust 1.30 due to suggest `Iterator::find_map`.
 - [x] `checked_conversions` requires Rust 1.34 due to suggest `TryFrom`.
 - [x] `match_like_matches_macro` requires Rust 1.42 due to suggest `matches!`. Addressed in #6201
 - [x] `manual_strip` requires Rust 1.45 due to suggest `str::{strip_prefix, strip_suffix}`. Addressed in #6201
 - [x] `option_as_ref_deref` requires Rust 1.40 due to suggest `Option::{as_deref, as_deref_mut}`. Addressed in #6201
 - [x] `manual_non_exhaustive` requires Rust 1.40 due to suggest `#[non_exhaustive]`. Addressed in #6201
 - [x] `manual_range_contains` requires Rust 1.35 due to suggest `Range*::contains`.
 - [x] `use_self` requires Rust 1.37 due to suggest `Self::Variant on enum`.
 - [x] `mem_replace_with_default` requires Rust 1.40 due to suggest `mem::take`.
 - [x] `map_unwrap_or` requires Rust 1.41 due to suggest `Result::{map_or, map_or_else}`.
 - [x] `missing_const_for_fn` requires Rust 1.46 due to `match/if/loop in const fn` needs that version.

changelog: Add MSRV config to more lints. ^This is now the complete list, AFAWK
2020-12-11 08:38:19 +00:00
suyash458
a7cfffef26 add MSRV to more lints specified in #6097
update tests
2020-12-11 11:00:03 +05:30
ThibsG
4af9382bec Common function to lint wrong self convention from impl and trait def 2020-12-10 17:08:42 +01:00
ThibsG
a6bb9276f7 Lint wrong self convention in trait also 2020-12-10 17:08:42 +01:00
Korrat
f77f1db35b Add a lint for maps with zero-sized values
Co-authored-by: Eduardo Broto <ebroto@tutanota.com>
2020-12-09 18:00:09 +01:00
bors
b02b0c737a Auto merge of #6367 - justjosias:6348-print-stderr, r=ebroto
Add lint print_stderr

Resolves #6348
Almost identical to print_stdout, this lint applies to the `eprintln!` and `eprint!` macros rather than `println!` and `print!`.

changelog: Add new lint [`print_stderr`]. [`println_empty_string`] and [`print_with_newline`] now apply to `eprint!()` and `eprintln!()` respectively.
2020-12-08 22:22:49 +00:00
Eduardo Broto
3187cad8ec Factor out some code in write.rs
Get rid of the too-many-lines error.
2020-12-08 23:17:12 +01:00
Takayuki Nakata
bd7f9c6c1c Merge remote-tracking branch 'upstream/master' into sync-from-rust 2020-12-08 17:01:25 +09:00
bors
50bca8af1d Auto merge of #6330 - camsteffen:redundant-else, r=ebroto
Add Redundant else lint

changelog: Add redundant_else lint

It seemed appropriate for "pedantic".

Closes #112 \*blows off dust*
2020-12-08 00:51:51 +00:00
dp304
bdad7900f4 Apply suggestions from code review
Use array slice instead of `Vec` in `find_macro_calls` as suggested by @ebroto

Co-authored-by: Eduardo Broto <ebroto@tutanota.com>
2020-12-08 00:10:39 +01:00
Dobe Peter
e58c7dd168 panic_in_result_fn: Extend to also check usages of [debug_]assert* macros
Also, the macro-finding logic has been moved to the util module, for
use by future lints.
2020-12-08 00:10:39 +01:00