Commit Graph

5147 Commits

Author SHA1 Message Date
bors
311186b9bb Auto merge of #6513 - nahuakang:fix/empty_enum_lint_never_type, r=flip1995
Fix: Empty enum never type suggested only if the feature is enabled

This PR addresses [Issue 6422](https://github.com/rust-lang/rust-clippy/issues/6422). Instead of always recommending `never type` for empty enums, Clippy would only recommend [the lint](https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum) if [LatePass.TyCtxt](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html) has `features().never_type` enabled.

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

*Please write a short comment explaining your change (or "none" for internal only changes)*
changelog: Only trigger [`empty_enum`] lint if `never_type` feature is enabled.
2021-01-05 09:37:19 +00:00
bors
976850b69b Auto merge of #6538 - Jarcho:vec_init_then_push, r=llogiq
New lint: vec_init_then_push

fixes: #1483

This will trigger on `new`, `default`, and `with_capacity` when the given capacity is less than or equal to the number of push calls. Is there anything else this should trigger on?

changelog: Added lint: `vec_init_then_push`
2021-01-04 20:42:18 +00:00
nahuakang
a8d47b4b78 Run cargo dev fmt 2021-01-04 18:41:42 +01:00
nahuakang
bc97f5d215 Address flip1995's review comments 2021-01-04 18:34:05 +01:00
bors
ae9ae9713c Auto merge of #6507 - bengsparks:lint/issue6410, r=flip1995
Needless Question Mark Lint

Fixes #6410, i.e the needless question mark lint

changelog: [`needless_question_mark`] New lint
2021-01-04 14:17:24 +00:00
Benjamin Sparks
ba87acb440
Implemented needless question mark lint 2021-01-04 14:51:48 +01:00
Matthias Krüger
6dcec6ae86 collapsible_if: split collapsible_else_if into its own lint so we can enable/disable it particularly
This splits up clippy::collapsible_if into collapsible_if for
if x {
  if y { }
}
=>
if x && y { }

and collapsible_else_if for

if x {
} else {
 if y { }
}

=>
if x {

} else if y {

}

so that we can lint for only the latter but not the first if we desire.

changelog: collapsible_if: split up linting for if x {} else { if y {} } into collapsible_else_if lint
2021-01-04 13:34:14 +01:00
Jason Newcomb
7b5f54954a
Fix docs: use type inference 2021-01-03 14:04:05 -05:00
bors
592f7eb7eb Auto merge of #6531 - matthiaskrgr:6522, r=ebroto
field_reassign_with_default: don't expand macros in suggestion

fixes #6522

changelog: field_reassign_with_default: don't expand macros in lint suggestion (#6522)
2021-01-02 23:38:23 +00:00
Jason Newcomb
d37ee6ffa0
Fix lint errors 2021-01-02 14:31:21 -05:00
Jason Newcomb
1853f8b228
Add lint 2021-01-02 11:08:56 -05:00
flip1995
e4fbc5f423
Bump Clippy version to 0.1.51 2021-01-02 16:26:10 +01:00
flip1995
d93692efa2
Merge remote-tracking branch 'upstream/master' into rustup 2021-01-02 16:03:26 +01:00
Matthias Krüger
5d48b91b40 field_reassign_with_default: don't expand macros in suggestion
fixes #6522

changelog: field_reassign_with_default: don't expand macros in lint suggestion (#6522)
2021-01-01 17:01:09 +01:00
Mara Bos
e5a1f22f48 Initial support for Rust 2021.
Clippy treated Rust 2021 as Rust 2015, because 2018 was checked with
`==` instead of `>=`. This fixes that, such that 2018-specific things
are also enabled for 2021.
2021-01-01 16:21:31 +01:00
Julian Knodt
48dec842f2 first pass at default values for const generics
- Adds optional default values to const generic parameters in the AST
  and HIR
- Parses these optional default values
- Adds a `const_generics_defaults` feature gate
2021-01-01 10:55:10 +01:00
Matthias Krüger
59397d6abb make clippy version number correspond to rustc version number.
clippy 0.1.50 corresponds to rustc 1.50.x

This bumps the clippy version number from 0.0.212 to 0.1.50

Fixes #6499
2020-12-31 16:29:26 +01:00
Joshua Nelson
5479bbaf72 Rename kw::Invalid -> kw::Empty
See https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Is.20there.20a.20symbol.20for.20the.20empty.20string.3F/near/220054471
for context.
2020-12-30 09:50:02 -05:00
nahuakang
275988cb73 Add additional lint doc to known problems section 2020-12-28 20:45:56 +01:00
nahuakang
469281c0dd Check if never type feature is enabled by TyCtxt before suggesting empty enum lint 2020-12-28 18:59:35 +01:00
Aleksei Latyshev
203715aa4e
don't ignore expression after first not matched method call in PtrCloneVisitor 2020-12-28 01:09:04 +03:00
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
Cameron Steffen
c6450c70dd Fix field_reassign_with_default for private fields 2020-12-22 11:09:46 -06:00
Cameron Steffen
73ce34a197 Remove redundant shadow check
There is already an assertion that consecutive lines assign to a struct
field.
2020-12-22 10:51:56 -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
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
f03edfd7a1 Merge commit '4911ab124c481430672a3833b37075e6435ec34d' into clippyup 2020-12-20 17:19:49 +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