Commit graph

3984 commits

Author SHA1 Message Date
bors
61a3ee7935 Auto merge of #6506 - alex-700:add-path-buf-to-ptr-arg-lint, r=Manishearth
Lint "&PathBuf instead of &Path" in PTR_ARG

fixes #6502

changelog: lint "`&PathBuf` instead of `&Path`" in `PTR_ARG`
2020-12-27 17:59:52 +00:00
bors
3661848997 Auto merge of #6375 - camsteffen:reassign-default-private, r=flip1995
Reassign default private

changelog: fix field_reassign_with_default false positive

* Fix #6344
* Fix assumption that `field: Default::default()` is the same as `..Default::default()`
* Cleanup some redundant logic
2020-12-27 16:20:47 +00:00
Aleksei Latyshev
dfaea9c967
lint &PathBuf instead of &Path in PTR_ARG
- extract get_only_generic_arg_snippet to improve readability
2020-12-25 15:06:34 +03:00
Takayuki Nakata
e1743ef525 Fix a style of texts in map_err_ignore 2020-12-25 08:59:34 +09:00
Philipp Krones
7fa1d78c89
Revert "Pass Clippy args also trough RUSTFLAGS" 2020-12-22 19:17:59 +01:00
Cameron Steffen
c6450c70dd Fix field_reassign_with_default for private fields 2020-12-22 11:09:46 -06:00
Cameron Steffen
8bdf34e10c Fix default initialized fields in suggestion
The default value for a field type does not necessarily match the
default value for that field in the struct Default.
2020-12-22 10:51:56 -06: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
Bastian Kersting
53f4d437f4
Update from_over_into.stderr 2020-12-21 17:15:05 +01:00
Philipp Hansch
12bd244caa
Don't trigger large_enum_variant in external macros 2020-12-21 11:09:49 +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
Philipp Hansch
8ddf4ce87a
UI Tests: Separate suspicious_else_formatting tests 2020-12-19 13:54:38 +01: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
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
Andrew Houts
1eb7608a2e make needless_update ignore non_exhaustive structs 2020-12-17 21:28:16 -06: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
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
39aca5ff9f Auto merge of #78399 - vn-ki:gsgdt-graphviz, r=oli-obk
make MIR graphviz generation use gsgdt

gsgdt [https://crates.io/crates/gsgdt] is a crate which provides an
interface for stringly typed graphs. It also provides generation of
graphviz dot format from said graph.

This is the first in a series of PRs on moving graphviz code out of rustc into normal crates and then implementating graph diffing on top of these crates.

r? `@oli-obk`
2020-12-15 22:00:02 +00: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
Eduardo Broto
cc9695543e Pass Clippy args also trough RUSTFLAGS 2020-12-13 15:43:20 +01: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
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
bors
3b89a672e2 Auto merge of #6382 - giraffate:fix_fp_in_manual_range_contains_when_const_fn, r=llogiq
Fix FP of `manual_range_contains` in `const fn`

Fix #6373.

changelog: Fix FP of `manual_range_contains` in `const fn`
2020-12-12 21:09:20 +00:00
Philipp Hansch
4bd9ed9b88
Rewrite update-all-references bash scripts in Rust
This replaces the `update-all-references` scripts with a single

    cargo dev bless

command.

cc #5394
2020-12-12 15:09:57 +01: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
bors
baf5f2da8b Auto merge of #6401 - ebroto:pin_to_a_nightly, r=ebroto
📌 Pin Clippy to a nightly 📌

changelog: Pin Clippy to a specific nightly version (No more master/custom toolchain required to compile Clippy)

Addresses partially #5561. As proposed there in [this comment](https://github.com/rust-lang/rust-clippy/issues/5561#issuecomment-623109095), this kicks off the process, to help us get acquainted with how the syncs should work, before working on improving the tooling.

Open questions:
* When performing a rustup, we will need to exclude the commits that were merged that same day, or else wait until that nightly is released. I did not update the documentation about this part, mainly because I'm not sure about how to do that.
* When should we perform the rustups now? My first idea is to do it at the same time we do the clippyups, to have a clear cadence and to avoid the two copies of the repo to diverge enough to make the process painful.
* Who does the rustups now? If we follow my previous idea and do both rustup and clippyup at the same time, it would be more work for `@flip1995` who currently does the clippyups. I would prefer to establish some kind of rotation to spead the work. Other ideas?
* I'm not sure if this affects the release process in any way.
* ???

`@rust-lang/clippy` thoughts?

r? `@flip1995`
2020-12-11 16:25:13 +00: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
9f27b74283 add test for missing_const_for_fn. fix test stderr 2020-12-11 11:00:29 +05:30
suyash458
a7cfffef26 add MSRV to more lints specified in #6097
update tests
2020-12-11 11:00:03 +05:30
ThibsG
90a16e4397 Add tests for unsized trait in wrong_self_convention lint 2020-12-10 17:53:47 +01:00
Thibaud
1e0f85b264 Update tests/ui/use_self.rs
Co-authored-by: Eduardo Broto <ebroto@tutanota.com>
2020-12-10 17:08:42 +01:00
ThibsG
db98651e72 Allow wrong_self_convention in use_self test for trait def 2020-12-10 17:08:42 +01:00
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
flip1995
3f41fe2704
Error in integration test, if required toolchain is not installed 2020-12-10 12:44:27 +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
a2d99259a4 Auto merge of #6188 - ebroto:primary_package, r=flip1995
Add --no-deps option to avoid running on path dependencies in workspaces

Since rust-lang/cargo#8758 has hit nightly, this allows us to address the second bullet point and [the concern related to `--fix`](https://github.com/rust-lang/cargo/issues/8143#issuecomment-619289546) in the [RUSTC_WORKSPACE_WRAPPER tracking issue](https://github.com/rust-lang/cargo/issues/8143).

As a reminder stabilizing that env var will solve #4612 (Clippy not running after `cargo check` in stable) and would allow to stabilize the `--fix` option in Clippy.

changelog: Add `--no-deps` option to avoid running on path dependencies in workspaces

Fixes #3025
2020-12-09 15:37:20 +00: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