Commit Graph

18158 Commits

Author SHA1 Message Date
bors
ef95be517c Auto merge of #11609 - y21:get_first_non_primitives, r=giraffate
[`get_first`]: lint on non-primitive slices

Fixes #11594

I left the issue open for a couple days before making the PR to see if anyone has something to say, but it looks like there aren't any objections to removing this check that prevented linting on non-primitive slices, so here's the PR now.
There's a couple of instances in clippy itself where we now emit the lint. The actual relevant change is in the first commit and fixing the `.get(0)` instances in clippy itself is in the 2nd commit.

changelog: [`get_first`]: lint on non-primitive slices
2023-10-15 23:53:22 +00:00
bors
c40359d97a Auto merge of #11664 - koka831:fix/11134, r=blyxyas
Fix/11134

Fix #11134

Hir of `qpath` will be `TypeRelative(Ty { kind: Path(LangItem...` when a closure contains macro (e.g. https://github.com/rust-lang/rust-clippy/issues/11651) and #11134, it causes panic.
This PR avoids panicking and emitting incomplete path string when `qpath` contains `LangItem`.

changelog: none
2023-10-13 10:18:49 +00:00
koka
9fc717dea3
add test for macro-in-loop 2023-10-13 17:12:41 +09:00
koka
eb6fb18a99
Avoid panic!, omit instead 2023-10-13 17:07:29 +09:00
bors
ff00e9c8c0 Auto merge of #11659 - aDotInTheVoid:hexdigit, r=Jarcho
[`manual_is_ascii_check`]: Also check for `is_ascii_hexdigt`

changelog: [`manual_is_ascii_check`]: Also check for `is_ascii_hexdigt`
2023-10-12 19:30:32 +00:00
Alona Enraght-Moony
b5488f9850 [manual_is_ascii_check]: Also check for is_ascii_hexdigt 2023-10-12 19:12:42 +00:00
bors
929a288aa7 Auto merge of #11645 - Alexendoo:ui_test, r=flip1995
Update ui_test to 0.21.2

Hopefully fixes #11489

r? `@flip1995`

changelog: none
2023-10-09 08:54:38 +00:00
bors
bde04824cc Auto merge of #11550 - blyxyas:fix-impl_trait_in_params-for_assocfn, r=dswij
`impl_trait_in_params` now supports impls and traits

Before this PR, the lint `impl_trait_in_params`. This PR gives the lint support for functions in impls and traits. (Also, some pretty heavy refactor)

fixes #11548
changelog:[`impl_trait_in_params`] now supports `impl` blocks and functions in traits
2023-10-08 21:57:56 +00:00
blyxyas
775573768e
Fix tests, only lint for public tests 2023-10-08 23:49:32 +02:00
blyxyas
5ed338dff9
impl_trait_in_params now supports impls and traits 2023-10-08 23:49:32 +02:00
Alex Macleod
850f2f5b61 Update ui_test to 0.21.2 2023-10-08 19:35:41 +01:00
bors
33f49f33d6 Auto merge of #11638 - samueltardieu:into-iter, r=Manishearth
Fix two typos in lint description

Fix #11636

changelog: none
2023-10-07 21:33:53 +00:00
bors
7624045997 Auto merge of #11639 - y21:issue11635, r=llogiq
[`into_iter_without_iter`]: walk up deref impl chain to find `iter` methods

Fixes #11635

changelog: [`into_iter_without_iter`]: walk up deref impl chain to find `iter` methods
2023-10-07 15:55:34 +00:00
y21
1c6fa2989d [into_iter_without_iter]: look for iter method in deref chains 2023-10-07 16:33:06 +02:00
Samuel Tardieu
bffba76b52 Fix two typos in lint description 2023-10-07 10:58:52 +02:00
bors
3662bd8f58 Auto merge of #11623 - koka831:fix/11619, r=llogiq
Fix ice in `redundant_locals`

Fixes #11619

Rebinding over macro like the code below, idents will be different (`x#4` and `x#0` in that case).

```rust
fn reassign_in_macro() {
  let x = 10;
  macro_rules! mac {
    ($i:ident) => {
      let mut x = x;
    }
  }
  mac!(y);
}
```

It causes unwrapping `None`.

9554e477c2/clippy_lints/src/redundant_locals.rs (L88-L98)

changelog: ICE: [`redundant_locals`]: No longer lints rebinding over macro
2023-10-06 17:24:50 +00:00
koka
68d2082d69
Fix ice 2023-10-07 01:28:06 +09:00
bors
b105fb4c39 Auto merge of #11629 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2023-10-06 15:34:34 +00:00
Philipp Krones
b8677e54d4
Bump Clippy version -> 0.1.75 2023-10-06 17:32:44 +02:00
Philipp Krones
50754da9fa
Bump nightly version -> 2023-10-06 2023-10-06 17:32:32 +02:00
Philipp Krones
82c3064c47
Merge remote-tracking branch 'upstream/master' into rustup 2023-10-06 17:31:44 +02:00
bors
7217c0f3ac Auto merge of #11628 - koka831:fix/11625, r=blyxyas
Improve `redundant_locals` help message

Fixes #11625

AFAIK, `span_lint_and_help` points the beginning of spans when we pass multiple spans to the second argument, so This PR I also modified its help span and its message.

lint result of the given example in the issue will be:

```console
error: redundant redefinition of a binding `apple`
 --> src/main.rs:5:5
  |
5 |     let apple = apple;
  |     ^^^^^^^^^^^^^^^^^^
  |
help: `apple` is initially defined here
 --> src/main.rs:4:9
  |
4 |     let apple = 42;
  |         ^^^^^
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_locals
```

I hope that this change might help reduce user confusion, but I'd appreciate alternative suggestions:)

changelog: [`redundant_locals`]: Now points at the rebinding of the variable
2023-10-06 15:06:00 +00:00
bors
279127ce2e Auto merge of #11611 - Alexendoo:items-after-test-module-check-crate, r=blyxyas
Fix `items_after_test_module` for non root modules, add applicable suggestion

Fixes #11050
Fixes #11153

changelog: [`items_after_test_module`]: Now suggests a machine-applicable suggestion.
changelog: [`items:after_test_module`]: Also lints for non root modules
2023-10-06 14:19:45 +00:00
koka
48d2770e52
Improve redundant_locals help message 2023-10-06 22:18:11 +09:00
Alex Macleod
dcc400191e Fix items_after_test_module for non root modules, add applicable suggestion 2023-10-06 12:46:04 +00:00
Michael Goulet
c5c6d703de Point to closure return instead of output if defaulted 2023-10-04 21:09:54 +00:00
Michael Goulet
56794fa5f1 Fix clippy 2023-10-04 21:09:54 +00:00
y21
e6f29f1900 dogfood 2023-10-04 18:08:30 +02:00
y21
31fd282732 [get_first]: lint on non-primitive types 2023-10-04 18:07:54 +02:00
bors
9554e477c2 Auto merge of #11605 - xFrednet:changelog-1-73, r=blyxyas
Changelog for Rust 1.73 🖊️

Roses are red,
violets are blue,
I'm tired... 💤
Oh nice, tea 🍵

---

### The cat of this release:

![cat-like-doritos](https://github.com/rust-lang/rust-clippy/assets/114838443/1ca9eb1e-3e5c-42a4-bda9-6f24a2e03015)

cc: `@Centri3` & `@blyxyas`

As the author, I call dibs on the 1.74 cat picture 🐈

---

changelog: none
2023-10-04 14:12:50 +00:00
bors
716f211030 Auto merge of #116360 - compiler-errors:async-span, r=oli-obk
Point to full `async fn` for future

Semi-follow-up to https://github.com/rust-lang/rust/pull/116296#discussion_r1342007575

cc `@asquared31415`
2023-10-04 09:55:02 +00:00
xFrednet
404217e631
Address PR Review <3 2023-10-04 10:28:52 +02:00
xFrednet
948355586f
sudo CI=green 2023-10-04 01:19:38 +02:00
xFrednet
8d920a8b03
Changelog for Rust 1.73 🖊️ 2023-10-04 01:09:46 +02:00
xFrednet
eab0a75ff9
Update version attribute for 1.73 lints 2023-10-04 01:08:45 +02:00
bors
b437069f59 Auto merge of #11603 - koka831:fix/11599, r=y21
Fix: avoid changing drop order

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

changelog: [`redundant_locals`] No longer lints which implements Drop trait to avoid reordering
2023-10-03 15:49:28 +00:00
koka
c7152679ef
Apply review suggestions from @y21 2023-10-04 00:13:53 +09:00
bors
29958f0764 Auto merge of #11602 - koka831:fix/11601, r=xFrednet
Avoid invoking `ignored_unit_patterns` in macro definition

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

The reported problem occured in [a derive macro](https://github.com/mpalmer/ct-structs/actions/runs/6386980382/job/17334587328#step:6:239). This PR avoid linting in macros.

changelog: [`ignored_unit_patterns`] No longer lints inside macro definitions
2023-10-03 13:07:13 +00:00
koka
1a56f90ee5
Fix: avoid changing drop order 2023-10-03 21:28:01 +09:00
koka
e465264d47
Avoid invoking ignored_unit_patterns in macro definition 2023-10-03 20:36:35 +09:00
bors
f107a50b23 Auto merge of #115025 - ouz-a:ouz_testing, r=lcnr
Make subtyping explicit in MIR

This adds new mir-opt that pushes new `ProjectionElem` called `ProjectionElem::Subtype(T)` to `Rvalue` of a subtyped assignment so we can unsoundness issues like https://github.com/rust-lang/rust/issues/107205

Addresses https://github.com/rust-lang/rust/issues/112651

r? `@lcnr`
2023-10-03 10:02:52 +00:00
Michael Goulet
2c525fd758 Point to full async fn for future 2023-10-03 02:25:32 +00:00
bors
81400e2db8 Auto merge of #11589 - koka831:fix/10198, r=giraffate
std_instead_of_core: avoid lint inside of proc-macro

- fixes https://github.com/rust-lang/rust-clippy/issues/10198

note: The lint for the reported `thiserror::Error` has been suppressed by [Don't lint unstable moves in std_instead_of_core](https://github.com/rust-lang/rust-clippy/pull/9545/files#diff-2cb8a24429cf9d9898de901450d640115503a10454d692dddc6a073a299fbb7eR29) because `thiserror::Error`  internally implements `std::error::Error for (derived struct)`.

changelog: [`std_intead_of_core`]: avoid linting inside proc-macro

I confirmed this change fixes the problem:
<details>
<summary>test result without the change</summary>

```console
error: used import from `std` instead of `core`
  --> tests/ui/std_instead_of_core.rs:65:14
   |
LL |     #[derive(ImplStructWithStdDisplay)]
   |              ^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the derive macro `ImplStructWithStdDisplay` (in Nightly builds, run with -Z macro-backtrace for more info)
```
</details>
2023-10-03 01:26:29 +00:00
ouz-a
ea4b38820b subtyping_projections 2023-10-02 23:37:49 +03:00
bors
08c429f241 Auto merge of #11596 - blyxyas:fix-fp-needless_pass_by_ref_mut, r=Jarcho
Move `needless_pass_by_ref_mut`: `suspicious` -> `nursery`

[Related to [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/needless_pass_by_ref_mut.20isn't.20ready.20for.20stable)]

`needless_pass_by_ref_mut` has been released with some important bugs (notably having a lot of reported false positives and an ICE). So it may not be really ready for being in stable until these problems are solved. This PR changes the lint's category from `suspicious` to `nursery`, just that.
changelog: none
2023-10-02 18:40:32 +00:00
blyxyas
07e63291ec
Modify tests to account for the new allow-by-default needless_pass_by_ref_mut 2023-10-02 20:14:43 +02:00
blyxyas
3f0da4dda2
Move needless_pass_by_ref_mut: suspicious -> nursery 2023-10-02 13:28:45 +02:00
bors
331d01e2bf Auto merge of #11265 - Alexendoo:print-literal-unicode-escapes, r=llogiq
Don't escape unicode escape braces in `print_literal`

Fixes #11264

changelog: none
2023-10-01 22:17:18 +00:00
Alex Macleod
258b9a8562 Don't escape unicode escape braces in print_literal 2023-10-01 21:43:09 +00:00
bors
aee3daf90b Auto merge of #11593 - koka831:fix/10511, r=xFrednet
Use Span#from_expansion instead of in_external_macro

- fixes #10511

I checked [the reported repository](https://github.com/rust-lang/rust-clippy/issues/10511#issuecomment-1474271205) and found that clippy hangs at [py_sync.rs#L85](842094068e/crates/python/src/py_sync.rs (L85)), where a macro(`py_function_sync_async`) defines type parameters. this macro is used in the same crate, so `in_external_macro` wouldn't catch them.

This PR fixes the problem by using `Span#from_expansion`.

---

changelog: ICE: [`implicit_hasher`]: No longer lints inside macros, which could cause ICEs
[#11593](https://github.com/rust-lang/rust-clippy/pull/11593)
2023-10-01 16:33:04 +00:00