Commit Graph

10533 Commits

Author SHA1 Message Date
bors
75bdbfcea5 Auto merge of #11853 - J-ZhengLi:issue11814, r=llogiq
expending lint [`blocks_in_if_conditions`] to check match expr as well

closes: #11814

changelog: rename lint `blocks_in_if_conditions` to [`blocks_in_conditions`] and expand it to check blocks in match scrutinees
2023-12-02 14:03:46 +00:00
bors
ee8376075d Auto merge of #11837 - y21:issue11835, r=dswij
[`missing_asserts_for_indexing`]: accept length equality checks

Fixes #11835

The lint now allows indexing with indices 0 and 1 when an `assert!(x.len() == 2);` is found.
(Also fixed a typo in the doc example)

changelog: [`missing_asserts_for_indexing`]: accept len equality checks as a valid assertion
2023-12-01 19:02:59 +00:00
bors
5ac76ac54f Auto merge of #11597 - y21:repeat_vec_with_capacity, r=dswij
new lint: `repeat_vec_with_capacity`

Closes #11537

[Lint description](https://github.com/y21/rust-clippy/blob/repeat_vec_with_capacity/clippy_lints/src/repeat_vec_with_capacity.rs#L14) should explain this PR :)

changelog: new lint: `repeat_vec_with_capacity`
2023-12-01 18:00:50 +00:00
Philipp Krones
c9a43b18f1 Merge commit 'f0cdee4a3f094416189261481eae374b76792af1' into clippy-subtree-sync 2023-12-01 18:21:58 +01:00
Philipp Krones
a9867e1847
Merge remote-tracking branch 'upstream/master' into rustup 2023-12-01 18:06:03 +01:00
y21
76eb781336 use iter::repeat_with in suggestion and add examples 2023-12-01 17:24:34 +01:00
y21
504941591f new lint: repeat_vec_with_capacity 2023-12-01 16:52:34 +01:00
Martin Nordholts
512f302fd2 needless_borrows_for_generic_args: Handle when field operand impl Drop
Before this fix, the lint had a false positive, namely when a reference
was taken to a field when the field operand implements a custom Drop.
The compiler will refuse to partially move a type that implements Drop,
because that would put the operand in a weird state. See added
regression test.
2023-12-01 09:14:56 +01:00
Samuel Tardieu
6275e77e6a Do not check twice whether qpath is a QPath::TypeRelative variant 2023-11-30 18:07:43 +01:00
clubby789
2cda044f8c Allow allowing upper_case_acronyms on enum variants 2023-11-30 16:00:40 +00:00
bors
646b28f5f6 Auto merge of #11896 - samueltardieu:issue-11893, r=Alexendoo
`option_if_let_else`: do not trigger on expressions returning `()`

Fix #11893

Trigerring on expressions returning `()` uses the arguments of the `map_or_else()` rewrite only for their side effects. This does lead to code which is harder to read than the original.

changelog: [`option_if_let_else`]: do not trigger on unit expressions
2023-11-30 15:17:29 +00:00
bors
665fd5219a Auto merge of #11872 - llogiq:test-attr-in-doctest, r=xFrednet
add lint against unit tests in doctests

During RustLab, Alice Ryhl brought to my attention that the Andoid team stumbled over the fact that if one attempts to write a unit test within a doctest, it will be summarily ignored. So this lint should help people wondering why their tests won't run.

---

changelog: New lint: [`test_attr_in_doctest`]
[#11872](https://github.com/rust-lang/rust-clippy/pull/11872)
2023-11-30 10:24:16 +00:00
J-ZhengLi
40b558af76 rename [blocks_in_if_conditions] to [blocks_in_conditions];
add more test cases with `match`;
minor fixes in message output regarding review feedback
2023-11-30 15:41:54 +08:00
J-ZhengLi
fff7aa0e18 expending lint [blocks_in_if_conditions] to check match expr as well 2023-11-30 14:44:27 +08:00
Samuel Tardieu
e3c73f17ec option_if_let_else: do not trigger on expressions returning ()
Fix #11893

Trigerring on expressions returning `()` uses the arguments of the
`map_or_else()` rewrite only for their side effects. This does lead
to code which is harder to read than the original.
2023-11-29 19:38:02 +01:00
bors
8b0bf6423d Auto merge of #11818 - y21:more_redundant_guards, r=llogiq
[`redundant_guards`]: catch `is_empty`, `starts_with` and `ends_with` on slices and `str`s

Fixes #11807

Few things worth mentioning:
- Taking `snippet`s is now done at callsite, instead of passing a span and doing it in `emit_redundant_guards`. This is because we now need custom suggestion strings in certain places, like `""` for `str::is_empty`.
- This now uses `snippet` instead of `snippet_with_applicability`. I don't think this really makes any difference for `MaybeIncorrect`, though?
- This could also lint byte strings, as they're of type `&[u8; N]`, but that can be ugly so I decided to leave it out for now

changelog: [`redundant_guards`]: catch `str::is_empty`, `slice::is_empty`, `slice::starts_with` and `slice::ends_with`
2023-11-29 13:20:59 +00:00
Matthias Krüger
071f8f610d Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errors
Add `never_patterns` feature gate

This PR adds the feature gate and most basic parsing for the experimental `never_patterns` feature. See the tracking issue (https://github.com/rust-lang/rust/issues/118155) for details on the experiment.

`@scottmcm` has agreed to be my lang-team liaison for this experiment.
2023-11-29 12:34:47 +01:00
Nadrieril
02e50f03bf Add never_patterns feature gate 2023-11-29 03:58:29 +01:00
Andre Bogus
0ba9bf9f9a add lint against unit tests in doctests 2023-11-28 21:29:08 +01:00
bors
57397a5190 Auto merge of #11363 - KisaragiEffective:fix_redundant_closure_call_on_closure_returns_async_block, r=llogiq
[`redundant_closure_call`]: avoid duplicated `async` keyword when triggering on closure that returns `async` block

close #11357

----

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: [`redundant_closure_call`]: avoid duplicated `async` keyword when triggering on closure that returns `async` block
2023-11-28 20:27:48 +00:00
y21
0565267f37 rename DocMarkdown to Documentation 2023-11-28 19:14:37 +01:00
J-ZhengLi
758d0e8661 change name to [infinite_loop];
& apply review suggestions;
2023-11-28 10:28:55 +08:00
Nicholas Nethercote
684c4bfef1 Rework ast::BinOpKind::to_string and ast::UnOp::to_string.
- Rename them both `as_str`, which is the typical name for a function
  that returns a `&str`. (`to_string` is appropriate for functions
  returning `String` or maybe `Cow<'a, str>`.)
- Change `UnOp::as_str` from an associated function (weird!) to a
  method.
- Avoid needless `self` dereferences.
2023-11-28 09:42:07 +11:00
bors
e6f33905e8 Auto merge of #11836 - lukaslueg:issue11831, r=Alexendoo
Don't suggest `a.mul_add(b, c)` if parameters are not float

clippy::suboptimal_flops used to not check if the second parameter to f32/f64.mul_add() was float. Since the method is only defined to take `Self` as parameters, the suggestion was wrong.

Fixes #11831

changelog: [`suboptimal_float`]: Don't suggest `a.mul_add(b, c)` if parameters are not f32/f64
2023-11-27 20:37:34 +00:00
bors
003e910760 Auto merge of #11817 - y21:ptr_arg_mut_ref, r=Alexendoo
[`ptr_arg`]: recognize methods that also exist on slices

Fixes #11816

Not a new lint, just a very small improvement to the existing `ptr_arg` lint which would have caught the linked issue.

The problem was that the lint checks if a `Vec`-specific method was called, that is, if the receiver is `Vec<_>`.
This is the case for `len` and `is_empty`, however these methods also exist on slices so we can still lint there.
This logic exists in a different lint, so we can just reuse that here.

Interestingly, there was even a comment up top that explained what it should have been doing, but the logic for it just wasn't there?

changelog: [`ptr_arg`]: recognize methods that also exist on slices

<sub>Also, this is my 100th PR to clippy 🎉 </sub>
2023-11-27 20:26:31 +00:00
bors
caa73941f8 Auto merge of #11879 - samueltardieu:issue-11876, r=Alexendoo
`manual_try_fold`: check that `fold` is really `Iterator::fold`

Fix #11876

changelog: [`manual_try_fold`]: suggest using `try_fold` only for `Iterator::fold` uses
2023-11-27 20:18:40 +00:00
Kisaragi Marine
0426913ca9
fix dogfood 2023-11-28 00:40:13 +09:00
Kisaragi Marine
33182495ac
don't add paren on occurrences that is in call args 2023-11-28 00:27:51 +09:00
Kisaragi Marine
1661e7ee76
re-implement fix for rust-lang#11357 2023-11-27 23:43:39 +09:00
J-ZhengLi
0d26f9183b eliminate the second visit to save a bit performance.
Thanks @y21 for the hint!
2023-11-27 10:30:47 +08:00
bors
f30a859ae3 Auto merge of #11867 - y21:implied_bounds_in_impls_complexity, r=Jarcho
Move `implied_bounds_in_impls` back to complexity

This lint was originally in the complexity category when I PR'd it. It was then moved to nursery by me due to a number of issues (a false positive, an invalid suggestion and an ICE), but that was probably an overreaction and all of the issues were fixed quickly after.
This is a useful lint imo and there hasn't been any issues with it in a few months, so I say we should give it another try and move it back to complexity.

I did a lintcheck run on the top 400 crates and all of them are legitimate, with 18 warnings. Most of them are from anstyle having a `impl Display + Copy + Clone` return type, or the bitvec crate with a return type like `impl Iterator + DoubleEndedIterator`.

changelog: Move [`implied_bounds_in_impls`] to `complexity` (Now warn-by-default)
[#11867](https://github.com/rust-lang/rust-clippy/pull/11867)
2023-11-26 22:28:13 +00:00
Samuel Tardieu
0d09cb0a6b manual_try_fold: check that fold is really Iterator::fold 2023-11-26 22:46:13 +01:00
Samuel Tardieu
23d533264f Fix box_default behaviour with empty vec![] coming from macro arg 2023-11-26 18:40:50 +01:00
Vadim Petrochenkov
bf86fe130c rustc: hir().local_def_id_to_hir_id() -> tcx.local_def_id_to_hir_id() cleanup 2023-11-26 12:41:21 +03:00
bors
a79a7d6510 Auto merge of #118250 - petrochenkov:optdefkind, r=compiler-errors
rustc: Make `def_kind` mandatory for all `DefId`s

Prerequisite for https://github.com/rust-lang/rust/pull/118188.
2023-11-26 04:44:20 +00:00
Michael Goulet
fffee10632 Appease the clippy 2023-11-25 18:02:11 +00:00
Alex Macleod
7093444bfa Use absolute path for declare_tool_lint in declare_clippy_lint 2023-11-25 17:45:27 +00:00
y21
5689a86fb8 move implied_bounds_in_impls to complexity 2023-11-25 13:54:37 +01:00
Vadim Petrochenkov
bafa200f6e rustc: Make def_kind mandatory for all DefIds 2023-11-25 14:49:43 +03:00
bors
3664d6328d Auto merge of #11864 - GuillaumeGomez:option_map_or_err_ok, r=flip1995
Create new lint `option_map_or_err_ok`

Fixes #10045.

For the following code:

```rust
let opt = Some(1);
opt.map_or(Err("error"), Ok);
```

It suggests to instead write:

```rust
let opt = Some(1);
opt.ok_or("error");
```

r? `@flip1995`

changelog: Create new lint `option_map_or_err_ok`
2023-11-25 11:35:46 +00:00
bors
fbf13cea16 Auto merge of #11866 - GuillaumeGomez:simplify-code-result_map_or_else_none, r=flip1995
Simplify code for `result_map_or_else_none`

As mentioned in https://github.com/rust-lang/rust-clippy/pull/11864.

r? `@flip1995`

changelog: Simplify code for `result_map_or_else_none`
2023-11-25 11:24:17 +00:00
Guillaume Gomez
148cd04140 Simplify code for result_map_or_else_none 2023-11-25 11:07:59 +01:00
bors
6cfbe57075 Auto merge of #11862 - christophbeberweil:7125-single-element-loop-over-range, r=llogiq
suggest alternatives to iterate an array of ranges

works towards #7125
changelog: [`single_element_loop`]: suggest better syntax when iterating over an array of a single range

`@thinkerdreamer` and myself worked on this issue during a workshop by `@llogiq` at the RustLab 2023 conference. It is our first contribution to clippy.

When iterating over an array of only one element, _which is a range_, our change suggests to replace the array with the contained range itself. Additionally, a hint is printed stating that the user probably intended to iterate over the range and not the array. If the single element in the array is not a range, the previous suggestion in the form of `let {pat_snip} = {prefix}{arg_snip};{block_str}`is used.

This change lints the array with the single range directly, so any prefixes or suffixes are covered as well.
2023-11-24 17:15:33 +00:00
Guillaume Gomez
ea733172e6 Create new lint option_map_or_err_ok 2023-11-24 18:14:34 +01:00
Christoph Beberweil
f9c6335a0f feat: 7125 code snippets are wrapped in backticks 2023-11-24 17:47:31 +01:00
Christoph Beberweil
bce869f0c0 fix: 7125 lint message should start with a small letter 2023-11-24 17:29:03 +01:00
bors
3e7a63b8d1 Auto merge of #11863 - smoelius:patch-1, r=dswij
Nit re `matches!` formatting

I think formatting `matches!` with `if` guards is [still unsupported](https://github.com/rust-lang/rustfmt/issues/5547), which is probably why this was missed.

changelog: none
2023-11-24 14:58:07 +00:00
bors
e075823e2c Auto merge of #11850 - Nilstrieb:tbd, r=dswij
[`deprecated_semver`]: Allow `#[deprecated(since = "TBD")]`

"TBD" is allowed by rustdoc, saying that it will be deprecated in a future version. rustc will also not actually warn on it.
I found this while checking the rust-lang/rust with clippy.

changelog: [`deprecated_semver`]: allow using `since = "TBD"`
2023-11-24 14:46:50 +00:00
bors
96eab0655f Auto merge of #11859 - y21:issue11856, r=blyxyas
[`missing_asserts_for_indexing`]: work with bodies instead of blocks separately

Fixes #11856

Before this change, this lint would check blocks independently of each other, which means that it misses `assert!()`s from parent blocks.
```rs
// check_block
assert!(x.len() > 1);

{
  // check_block
  // no assert here
  let _ = x[0] + x[1];
}
```

This PR changes it to work with bodies rather than individual blocks. That means that a function will be checked in one go and we can remember if an `assert!` occurred anywhere.

Eventually it would be nice to have a more control flow-aware analysis, possibly by rewriting it as a MIR lint, but that's more complicated and I wanted this fixed first.

changelog: [`missing_asserts_for_indexing`]: accept `assert!`s from parent blocks
2023-11-24 12:18:11 +00:00
Samuel Moelius
4937fba456
Nit re matches! formatting 2023-11-24 07:10:28 -05:00
Christoph Beberweil
2512341fe4 feat: 7125 shorten lint text 2023-11-24 10:38:45 +01:00
Christoph Beberweil
c58d692e1f fix: 7125 update lint applicability to Unspecified 2023-11-24 10:30:19 +01:00
Christoph Beberweil
447edf92b4 suggest alternatives to iterate an array of ranges
Co-authored-by: ThinkerDreamer <74881094+ThinkerDreamer@users.noreply.github.com>
2023-11-23 23:07:36 +01:00
Guillaume Gomez
6c84b96886 Improve error messages format 2023-11-23 13:32:41 +01:00
Guillaume Gomez
2817c5fc14 Extend result_map_or_into_option lint to handle Result::map_or_else(|_| None, Some) 2023-11-23 10:57:37 +01:00
y21
553857bb2b check on a per-body level instead of blocks independently 2023-11-23 09:31:49 +01:00
bors
c24784ed81 Auto merge of #11757 - matthri:iter-kv-map-msrv-fix, r=Alexendoo
Fix iter_kv_map false positive into_keys and into_values suggestion

fixes: #11752

changelog: [`iter_kv_map`]: fix false positive: Don't suggest `into_keys()` and `into_values()` if the MSRV is to low
2023-11-22 20:39:44 +00:00
bors
a72730e9a1 Auto merge of #11844 - GuillaumeGomez:manual_non_exhaustive-rm-underscore-check, r=flip1995
Remove underscore check for `manual_non_exhaustive` lint

Fixes https://github.com/rust-lang/rust-clippy/issues/10550.

As indicated in https://github.com/rust-lang/rust-clippy/pull/10559, the underscore check should be removed.

changelog: remove underscore check for `manual_non_exhaustive` lint

r? `@blyxyas`
2023-11-22 13:37:31 +00:00
Guillaume Gomez
91fc4b3001 Remove underscore check for manual_non_exhaustive lint 2023-11-22 13:42:13 +01:00
bors
a8b0e5ffad Auto merge of #11627 - y21:issue11616, r=giraffate
[`needless_return_with_question_mark`]: don't lint if never type is used for coercion

Fixes #11616

When we have something like
```rs
let _x: String = {
  return Err(())?;
};
```
we shouldn't suggest removing the `return` because the `!`-ness of `return` is used to coerce the enclosing block to some other type. That will lead to a typeck error without a diverging expression like `return`.

changelog: [`needless_return_with_question_mark`]: don't lint if `return`s never typed-ness is used for coercion
2023-11-22 04:49:00 +00:00
Nicholas Nethercote
fa7cd2548c Update itertools to 0.11.
Because the API for `with_position` improved in 0.11 and I want to use
it.
2023-11-22 08:13:21 +11:00
Nilstrieb
43d8d51b6d Allow #[deprecated(since = "TBD")]
"TBD" is allowed by rustdoc, saying that it will be deprecated in a future version.
rustc will also not actually warn on it.
2023-11-21 22:03:00 +01:00
y21
a74fa97fab [needless_return_with_question_mark]: dont lint in case of coercion 2023-11-21 12:02:12 +01:00
Guillaume Gomez
abd9deb9f4 [missing_safety_doc], [unnecessary_safety_doc], [missing_panics_doc], [missing_errors_doc]: Added the [check-private-items] configuration to enable lints on private items.
[#11842](https://github.com/rust-lang/rust-clippy/pull/11842)
2023-11-21 11:42:42 +01:00
J-ZhengLi
3e9a6d142e stop warning never-returning calls
and add more test cases
2023-11-21 16:18:18 +08:00
bors
72c0d80f46 Auto merge of #11801 - y21:split_doc_pass, r=blyxyas
Split `doc.rs` up into a subdirectory

So, first, sorry for the bad diff. 😅

In #11798, `@flip1995`  suggested splitting `doc.rs` up, much like how we have the `methods/`, `matches/`, `types/` subdirectories.
I agree with this, the file is getting bigger as we add more and more doc lints that it makes sense to do this refactoring.

This is purely an internal change that moves things around a bit.
(**EDIT:** depending on the outcome of https://github.com/rust-lang/rust-clippy/pull/11801#issuecomment-1816715615 , this may change the lint group name from `doc_markdoc` to `doc`).

I tried to not change any of the actual logic of the lints and as such some things weren't as easy to move to a separate file. So we still have some `span_lint*` calls in the `doc/mod.rs` file, which I think is fine. This is also the case in `methods/mod.rs`.

Also worth mentioning that the lints missing_errors_doc, missing_panics_doc, missing_safety_doc and unnecessary_safety_doc have a lot of the same logic so it didn't make much sense for each of these to be in their own file. Instead I just put them all in `missing_headers.rs`

I also added a bit of documentation to the involved `check_{attrs,doc}` methods.

changelog: none
2023-11-20 17:22:05 +00:00
ofeeg
34d9e88a47
New lint clippy::join_absolute_paths
* `join_absolute_paths` Address PR review
* Move `clippy::join_absolute_paths` to `clippy::suspicious`
* `join_absolute_paths`: Address PR review

Co-Authored-By: ofeeg <mhanna0000@gmail.com>
2023-11-20 13:28:28 +01:00
y21
56cee3c587 move doc.rs to its own subdirectory 2023-11-20 12:08:07 +01:00
bors
41140e3cb8 Auto merge of #11840 - GuillaumeGomez:improve-maybe_misused_cfg, r=blyxyas
Improve maybe misused cfg

Follow-up of the improvements that were suggested to me in https://github.com/rust-lang/rust-clippy/pull/11821:

 * I unified the output to use the same terms.
 * I updated the code to prevent creating a new symbol.

r? `@blyxyas`

changelog: [`maybe_misued_cfg`]: Output and code improvements
2023-11-19 22:31:11 +00:00
Guillaume Gomez
dfbca7ffa8 Improve maybe_misused_cfg lint output
Small performance improvement when comparing symbols for `maybe_misused_cfg`
Improve suggestion for `maybe_misused_cfg` lint
2023-11-19 22:46:19 +01:00
Esteban Küber
82babe0303 Don't sort span_suggestions, leave that to caller 2023-11-19 17:50:45 +00:00
bors
9c3a365fd2 Auto merge of #11781 - partiallytyped:11710, r=xFrednet
Verify Borrow<T> semantics for types that implement Hash, Borrow<str> and Borrow<[u8]>.

Fixes #11710

The essence of the issue is that types that implement Borrow<T> provide a facet or a representation of the underlying type. Under these semantics `hash(a) == hash(a.borrow())`.

This is a problem when a type implements `Borrow<str>`, `Borrow<[u8]>` and Hash, it is expected that the hash of all three types is identical. The problem is that the hash of [u8] is not the same as that of a String, even when the byte reference ([u8]) is derived from `.as_bytes()`

- [x] 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`

---

 - [x] Explanation of the issue in the code
 - [x] Tests reproducing the issue
 - [x] Lint rule and emission

---

changelog: New lint: [`impl_hash_borrow_with_str_and_bytes`]
[#11781](https://github.com/rust-lang/rust-clippy/pull/11781)
2023-11-19 10:59:34 +00:00
Quinn Sinclair
3c1e0afa58 New Lint [impl_hash_with_borrow_str_and_bytes]
Implements a lint to prevent implementation of Hash, Borrow<str> and
Borrow<[u8]> as it breaks Borrow<T> "semantics". According to the book,
types that implement Borrow<A> and Borrow<B> must ensure equality of
borrow results under Eq,Ord and Hash.

> In particular Eq, Ord and Hash must be equivalent for borrowed and
owned values: x.borrow() == y.borrow() should give the same result as x == y.

In the same way, hash(x) == hash(x as Borrow<[u8]>) != hash(x as Borrow<str>).

changelog: newlint [`impl_hash_with_borrow_str_and_bytes`]
2023-11-19 11:33:01 +01:00
bors
dbd19f9b48 Auto merge of #11691 - sjwang05:lines-filter-map-ok-fix, r=Centri3
Lint `flatten()` under `lines_filter_map_ok`

Fixes #11686

changelog: [`lines_filter_map_ok`]: Also lint calls to `flatten()`
2023-11-19 01:50:24 +00:00
bors
9263f806d8 Auto merge of #11782 - Alexendoo:macro-use-imports-ordering, r=Centri3
Make `macro_use_imports` lint ordering more stable

changelog: none

Fixes [the `macro_use_imports` ordering dependence](https://github.com/rust-lang/rust/pull/117649#issuecomment-1797716088) on the hash of `Span`s
2023-11-19 01:39:06 +00:00
bors
6eb935a578 Auto merge of #11826 - kpreid:typo, r=Alexendoo
Fix typos in recent lint documentation.

Fixes typos and markup errors, and also makes the examples more realistic by hiding the `;`s so as not to visibly be discarding the computed value. Affected lints:

* `redundant_as_str`
* `unnecessary_map_on_constructor`

changelog: none
2023-11-18 19:49:46 +00:00
Kevin Reid
b3f4a9015c Remove space and rephrase map() advice. 2023-11-18 10:53:03 -08:00
y21
4de845e375 [missing_asserts_for_indexing]: accept len equality checks 2023-11-18 14:59:24 +01:00
Lukas Lueg
a2e396badf Don't suggest a.mul_add(b, c) if parameters are not float
clippy::suboptimal_flops used to not check if the second parameter to f32/f64.mul_add() was float. Since the method is
only defined to take `Self` as paremters, the suggestion was wrong.

Fixes #11831
2023-11-18 13:50:18 +01:00
bors
e8e9510219 Auto merge of #11002 - y21:issue9422, r=Jarcho
teach `eager_or_lazy` about panicky arithmetic operations

Fixes #9422
Fixes #9814
Fixes #11793

It's a bit sad that we have to do this because arithmetic operations seemed to me like the prime example where a closure would not be necessary, but this has "side effects" (changes behavior when going from lazy to eager) as some of these panic on overflow/underflow if compiled with `-Coverflow-checks` (which is the default in debug mode).
Given the number of backlinks in the mentioned issues, this seems to be a FP that is worth fixing, probably.

changelog: [`unnecessary_lazy_evaluations`]: don't lint if closure has panicky arithmetic operations
2023-11-17 18:53:15 +00:00
Kevin Reid
bffb664fbf Fix markup in recent lint documentation.
Also make the examples more realistic by hiding the `;`s so as not to
visibly be discarding the computed value.
2023-11-17 10:12:12 -08:00
bors
31e38fee23 Auto merge of #11821 - GuillaumeGomez:misspelled-cfg, r=blyxyas
Extend `maybe_misused_cfg` lint over `cfg(test)`

Fixes #11240.

One thought I had is that we could use the levenshtein distance (of 1) to ensure this is indeed `test` that was targeted. But maybe it's overkill, not sure.

changelog: [`maybe_misused_cfg`]: Extend lint over `cfg(test)`

r? `@blyxyas`
2023-11-17 11:49:20 +00:00
J-ZhengLi
2d9fc6dfc8 implement unoptimized code logic for [infinite_loops] 2023-11-17 18:10:50 +08:00
lcnr
8c6c542443 rename bound region instantiation
- `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased`
- `replace_late_bound_regions_X` -> `instantiate_bound_regions_X`
2023-11-17 09:29:48 +00:00
Nathan Stocks
4143acf4c8
fix typo 2023-11-16 17:18:48 -07:00
Philipp Krones
6246f0446a Merge commit 'edb720b199083f4107b858a8761648065bf38d86' into clippyup 2023-11-16 19:13:24 +01:00
Philipp Krones
6f952fbe53
Bump Clippy version -> 0.1.76 2023-11-16 19:02:33 +01:00
Philipp Krones
6fab1485c3
Merge remote-tracking branch 'upstream/master' into rustup 2023-11-16 19:02:04 +01:00
Guillaume Gomez
f08037c2f5 Update documentation for MAYBE_MISUSED_CFG lint 2023-11-16 18:07:26 +01:00
Guillaume Gomez
74451cd060 Extend maybe_misused_cfg lint over cfg(test) 2023-11-16 18:05:00 +01:00
y21
1e0597cb68 [match_same_arms]: respect allow attrs on arms 2023-11-16 17:28:37 +01:00
y21
8f9c738ce9 dogfood clippy 2023-11-15 21:34:48 +01:00
y21
1b4e2ef3d7 fix empty needle corner case and add tests 2023-11-15 21:10:03 +01:00
y21
676f1f6ef8 [redundant_guards]: lint slice::{starts_with,ends_with} 2023-11-15 20:53:43 +01:00
y21
998a311a13 [redundant_guards]: lint empty slice checks 2023-11-15 19:37:36 +01:00
y21
ef587d22a4 [redundant_guards]: lint empty string checks 2023-11-15 19:33:30 +01:00
y21
bb694615b8 [ptr_arg]: recognize methods that also exist on slices 2023-11-15 14:59:11 +01:00
bors
406d953820 Auto merge of #11806 - xFrednet:changelog-1-74, r=Alexendoo
Changelog for Rust 1.74 🎃

Roses are red,
Halloween is over,
Have you considered,
Buying a Mars rover?

---

### The cats of this release:

<img height=500 src="https://github.com/rust-lang/rust-clippy/assets/17087237/095bd32e-b5e3-41db-8f0f-bdef7ca1a6d0" alt="The cats of this Clippy release" />

<sub>The cat for the next release can be nominated in the comments</sub>

---

changelog: none
2023-11-15 12:31:24 +00:00
bors
3ea5bcf5ee Auto merge of #11809 - hrxi:pr_if_same_then_else_style, r=Alexendoo
Change `if_same_then_else` to be a `style` lint

CC #3770

From https://github.com/rust-lang/rust-clippy/issues/3770#issuecomment-687565594 (`@flip1995):`

> Oh I thought I replied to this: I definitely see now that having this
> as a correctness lint might be the wrong categorization. What we might
> want to do is to just allow this lint, if there are comments in the
> arm bodies. But a good first step would be to downgrade this lint to
> style or complexity. I would vote for style since merging two arms is
> not always less complex.

changelog: [`if_same_then_else`]: Change to be a `style` lint
2023-11-15 12:11:14 +00:00
bors
7ad3373bb1 Auto merge of #11802 - dswij:issue-11765, r=xFrednet
`needless_return_with_question_mark` ignore let-else

Fixes #11765

This PR makes `needless_return_with_question_mark` to ignore expr inside let-else.

changelog: [`needless_return_with_question_mark`] ignore let-else
2023-11-15 10:15:47 +00:00