Commit graph

15873 commits

Author SHA1 Message Date
koka
ebb0759bb3
Add a test for regular wildcard
fix
2022-12-18 21:07:18 +09:00
Niki4tap
dae54fad3e Doc codeblock fixup 2022-12-18 03:20:04 +03:00
Niki4tap
54a9168efb Remove useless pattern matching 2022-12-18 03:02:45 +03:00
Niki4tap
42106e0495 Add lint fn_null_check 2022-12-18 03:02:45 +03:00
Niki4tap
3cc67d0856 Relax clippy_utils::consts::miri_to_const pointer type restrictiveness 2022-12-18 03:02:45 +03:00
Niki4tap
6afe5471cf Add lint transmute_null_to_fn 2022-12-18 03:02:37 +03:00
Samuel Tardieu
af39a8a4a8 Identify more cases of useless into_iter() calls
If the type of the result of a call to `IntoIterator::into_iter()`
and the type of the receiver are the same, then the receiver
implements `Iterator` and `into_iter()` is the identity function.

The call to `into_iter()` may be removed in all but two cases:

- If the receiver implements `Copy`, `into_iter()` will produce
  a copy of the receiver and cannot be removed. For example,
  `x.into_iter().next()` will not advance `x` while `x.next()` will.
- If the receiver is an immutable local variable and the call to
  `into_iter()` appears in a larger expression, removing the call to
  `into_iter()` might cause mutability issues. For example, if `x`
  is an immutable local variable, `x.into_iter().next()` will
  compile while `x.next()` will not as `next()` receives
  `&mut self`.
2022-12-17 16:20:43 +01:00
Philipp Krones
1c422524c7 Merge commit '4bdfb0741dbcecd5279a2635c3280726db0604b5' into clippyup 2022-12-17 14:12:54 +01:00
bors
4bdfb0741d Auto merge of #10097 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

I'm on the train and my internet is too bad to download the necessary toolchain, so I have to use CI to find sync fallout.

changelog: none
<!-- changelog_checked -->
2022-12-17 13:08:47 +00:00
Philipp Krones
7198989d45
Bump nightly version -> 2022-12-17 2022-12-17 13:57:48 +01:00
Philipp Krones
1f1d23cf51
Bump Clippy version -> 0.1.68 2022-12-17 13:57:41 +01:00
Philipp Krones
d6488ae144
Merge remote-tracking branch 'upstream/master' into rustup 2022-12-17 13:56:32 +01:00
bors
391b2a6fac Auto merge of #10096 - feniljain:fix-seek-rewind, r=xFrednet
fix: not suggest seek_to_start_instead_of_rewind when expr is used

changelog: [`seek_to_start_instead_of_rewind`]: No longer lints, if the return of `seek` is used.
[#10096](https://github.com/rust-lang/rust-clippy/pull/10096)
<!-- changelog_checked -->

Fixes #10065
2022-12-17 12:35:26 +00:00
feniljain
c39849a34d fix: not suggest seek_to_start_instead_of_rewind when expr is used 2022-12-17 17:31:34 +05:30
bors
b62319ce02 Auto merge of #10094 - EricWu2003:increment-visitor-fix, r=xFrednet
fix logic in IncrementVisitor

There used to be a logical bug where IncrementVisitor would completely stop checking an expression/block after seeing a continue statement.

I am a little unsure of whether my fix to `IncrementVisitor` is logically sound (I hope it makes sense). Let me know what you think, and thanks in advance for the review!

fixes #10058

---

changelog: FP: [`explicit_counter_loop`]: No longer ignores counter changes after `continue` expressions
[#10094](https://github.com/rust-lang/rust-clippy/pull/10094)
<!-- changelog_checked -->
2022-12-17 11:36:50 +00:00
chansuke
033f1ec797 Add 2018/2021 edition tests for wildcard_imports 2022-12-17 20:26:41 +09:00
Eric Wu
97c12e0460 fix logic in IncrementVisitor
There used to be a logical bug where IncrementVisitor would
completely stop checking an expression/block after seeing a continue
statement. This led to issue #10058 where a variable incremented
(or otherwise modified) after any continue statement would still be
considered incremented only once.

The solution is to continue scanning the expression after seeing a
`continue` statement, but increment self.depth so that the Visitor
thinks that the rest of the loop is within a conditional.
2022-12-16 10:54:12 -05:00
Eric Wu
3c14075b46 manual_filter: add a related test
The related issue is #9766 where the `manual_filter`
lint would remove side effects
2022-12-16 09:29:32 -05:00
Eric Wu
5b3a6669f7 fix manual_filter false positive
do explicit checks for the other branch being None
2022-12-15 23:53:28 -05:00
bors
02f3959f2b Auto merge of #10086 - nbdd0121:master, r=matthiaskrgr
Fix new_return_no_self with recursive bounds

Fix #10041

This uses a hash set, as described in https://github.com/rust-lang/rust-clippy/pull/10068#issuecomment-1352528391

changelog: [`new_return_no_self`]: fix stack overflow when the return type is `impl Trait` and contains recursive bounds
2022-12-16 02:08:39 +00:00
Matthias Krüger
cfe1e040e7 Rollup merge of #105743 - nnethercote:SimplifiedType-cleanups, r=lcnr
`SimplifiedType` cleanups

r? `@lcnr`
2022-12-15 22:03:01 +01:00
Gary Guo
7574c98371 Fix new_return_no_self with recursive bounds 2022-12-15 18:56:13 +00:00
bors
3905f51230 Auto merge of #10073 - xFrednet:changelog-1-66, r=Alexendoo
Changelog 1.66

It's really nice to see a changelog with so many suggestion fixes and improvements. Not much else to say. This should be merged with the coming release on 2022-12-15. For the reviewer, please review it and approve it if it looks good. The merge should wait until the release :)

---

changelog: none

<!-- changelog_checked -->
2022-12-15 16:12:12 +00:00
bors
f43e4f30d8 Auto merge of #9927 - xFrednet:0000-rustc-tool-macro-update, r=matthiaskrgr
Cleanup `rustc_tool_util` and add a convenient macro for `build.rs`

changelog: none
<!-- changelog_checked -->

If possible, I'd like to have a new release for this, maybe `v0.3.0` to use the changes in another project. Then we can also remove the `path = "./rustc_tools_util"` from `Cargo.toml`. I'd be happy to help with the release on crates.io if you'd like the help :)

r? `@matthiaskrgr`
2022-12-15 12:04:30 +00:00
xFrednet
004b885c0a
rustc_tools_util: changelog and 0.3.0 release 2022-12-15 13:01:02 +01:00
Nicholas Nethercote
e723fc4f56 Merge SimplifiedTypeGen<D> into SimplifiedType.
`SimplifiedTypeGen<DefId>` is the only instantiation used, so we don't
need the generic parameter.
2022-12-15 15:13:19 +11:00
Fridtjof Stoldt
71019aa076
Address review comments <3
Co-authored-by: Takayuki Nakata <f.seasons017@gmail.com>
Co-authored-by: Alex Macleod <alex@macleod.io>
2022-12-14 19:48:49 +01:00
Oli Scherer
fa87abf963 Remove TraitRef::new 2022-12-14 15:36:39 +00:00
Oli Scherer
65069d5c5b Ensure no one constructs AliasTys themselves 2022-12-14 15:36:39 +00:00
bors
be15e60d00 Auto merge of #10053 - naosense:fix_9933, r=xFrednet
improve `manual_is_ascii_check ` check

Sorry, not familiar the api, i can only check the method name of expression `<expr-1>.contains(<expr-2>)` after read clippy book and hints from #9933 . i dont know how to check
1.  if <expr-1> is a specific range
2. <expr-2> is a character

r? `@xFrednet` could you please provide some more hints? 😝️

---

changelog: Enhancement: [`manual_is_ascii_check`]: Now detects ranges with `.contains()` calls
[#10053](https://github.com/rust-lang/rust-clippy/pull/10053)
<!-- changelog_checked -->
2022-12-14 13:48:53 +00:00
xFrednet
2855a0f117
Changelog for Rust 1.66 🎅 2022-12-13 23:48:27 +01:00
xFrednet
2532c56d86
Update version attribute for 1.66 lints 2022-12-13 23:36:47 +01:00
Michael Goulet
957ab6ae52 Combine projection and opaque into alias 2022-12-13 17:48:55 +00:00
Michael Goulet
89b8840543 squash OpaqueTy and ProjectionTy into AliasTy 2022-12-13 17:40:27 +00:00
Michael Goulet
a274e7e9a2 ProjectionTy.item_def_id -> ProjectionTy.def_id 2022-12-13 17:34:44 +00:00
Michael Goulet
ad55e4c972 Use ty::OpaqueTy everywhere 2022-12-13 17:29:26 +00:00
naosense
1f862c2ad3 remove assert macro 2022-12-13 21:43:16 +08:00
naosense
949d0709bd improve document 2022-12-13 16:52:55 +08:00
naosense
55fdd1e78c replace reference with value 2022-12-13 16:52:55 +08:00
naosense
de92da2974 add more test, limits check 2022-12-13 16:52:55 +08:00
naosense
25c9718c04 check ranges with .contains calls 2022-12-13 16:52:55 +08:00
bors
17a092f467 Auto merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkov
Remove `token::Lit` from `ast::MetaItemLit`.

Currently `ast::MetaItemLit` represents the literal kind twice. This PR removes that redundancy. Best reviewed one commit at a time.

r? `@petrochenkov`
2022-12-12 05:16:50 +00:00
bors
3b67e6af9e Auto merge of #10059 - alex-semenyuk:fix_badge_book, r=flip1995
Fix badge

Apply this #9734 for book
changelog: none
2022-12-10 22:24:29 +00:00
alex-semenyuk
3b6bbf7d16 Fix match_single_binding suggestion introduced an extra semicolon 2022-12-10 20:35:49 +03:00
alexey semenyuk
55f1698a6c
Fix badge 2022-12-10 19:15:08 +03:00
koka
055f349670
Avoid match_wildcard_for_single_variants on guarded wild matches
fix #9993
changlog: [`match_wildcard_for_single_variants`] avoid suggestion on wildcard with guard
2022-12-10 21:05:08 +09:00
bors
c0130e45df Auto merge of #10055 - taiki-e:uninlined_format_args, r=llogiq
uninlined_format_args: Ignore assert! and debug_assert! before 2021 edition

Similar to https://github.com/rust-lang/rust-clippy/pull/9605, but for `assert!` and `debug_assert!` macros. ([non_fmt_panics lint triggers them](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=18b20c408ec62a67f1503cd5d284424b))

changelog: [`uninlined_format_args`]: Do not inline `assert!` and `debug_assert!` macros before 2021 edition

r? `@llogiq`
2022-12-10 09:48:11 +00:00
Taiki Endo
e5010c996e uninlined_format_args: Ignore assert! and debug_assert! before 2021 edition 2022-12-10 18:35:24 +09:00
bors
ef2018cc49 Auto merge of #10043 - phtown:master, r=Jarcho
Add lint `almost_complete_digit_range`

changelog: [`almost_complete_digit_range`]: Add digit analog to `almost_complete_letter_range`

I have added a lint that will detect `'0'..'9'` and suggest converting it to `'0'..='9'`, the same way `almost_complete_letter_range` does for ascii letters. I tied into the implementation of `AlmostCompleteLetterRange` in order to do that, but I didn't change its interface.
This is my first contribution to Clippy, so please let me know if there's anything I should do differently. I'll be happy to incorporate any suggestions you have.
Thanks!
2022-12-09 19:40:21 +00:00
Hannah Town
4c80f210c3 Add lint almost_complete_range
This replaces and expands `almost_complete_letter_range`.
2022-12-09 13:29:50 -05:00