Commit Graph

17763 Commits

Author SHA1 Message Date
blyxyas
b2e1ede39c
Change Tokio example description to Core 2023-08-17 22:56:39 +02:00
blyxyas
94387efc83
Fixes based on reviews 2023-08-17 22:56:38 +02:00
blyxyas
3c50a0a18d
Add new chapter: "Trait Checking" 2023-08-17 22:56:37 +02:00
bors
d5298bea7f Auto merge of #11314 - GuillaumeGomez:needless_ref_mut_async_block, r=Centri3
Correctly handle async blocks for NEEDLESS_PASS_BY_REF_MUT

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

The problem was that the `async block`s are popping a closure which we didn't go into, making it miss the mutable access to the variables.

cc `@Centri3`

changelog: none
2023-08-17 15:55:23 +00:00
Guillaume Gomez
5875bd2b5f Use HirId from PlaceWithHirId rather than using the one provided to the function 2023-08-17 17:45:17 +02:00
bors
701e77c87f Auto merge of #11070 - y21:issue11065, r=flip1995
[`useless_conversion`]: only lint on paths to fn items and fix FP in macro

Fixes #11065 (which is actually two issues: an ICE and a false positive)

It now makes sure that the function call path points to a function-like item (and not e.g. a `const` like in the linked issue), so that calling `TyCtxt::fn_sig` later in the lint does not ICE (fixes https://github.com/rust-lang/rust-clippy/issues/11065#issuecomment-1616836099).
It *also* makes sure that the expression is not part of a macro call (fixes https://github.com/rust-lang/rust-clippy/issues/11065#issuecomment-1616919639). ~~I'm not sure if there's a better way to check this other than to walk the parent expr chain and see if any of them are expansions.~~ (edit: it doesn't do this anymore)

changelog: [`useless_conversion`]: fix ICE when call receiver is a non-fn item
changelog: [`useless_conversion`]: don't lint if argument is a macro argument (fixes a FP)

r? `@llogiq` (reviewed #10814, which introduced these issues)
2023-08-17 14:41:46 +00:00
Guillaume Gomez
7e46217362 Add new regression test for needless_pass_by_ref_mut 2023-08-17 14:24:04 +02:00
bors
d43486dc8c Auto merge of #10644 - blyxyas:book-method_checking, r=flip1995
Clippy Book Chapter Updates Reborn: Method Checking

This PR adds a new chapter to the book: "Method Checking". Some major re-phrasing was done and some changes in the code comments (apart from grammar and minor changes).

## Notes

- Requires #10595 **and** #10622 to be merged before this, or else several links will be broken
- To talk about the whole project, please use the tracking issue for the project #10597 (It also contains a timeline, discussions and more information)

changelog: Add a new "Method Checking" chapter to the book.

r? `@flip1995`
2023-08-16 12:57:18 +00:00
Philipp Krones
1dbc8dd0cf
Fix define_lints->defining_lints typo in link 2023-08-16 14:54:47 +02:00
Philipp Krones
e8d79b8645
Formatting 2023-08-16 14:50:40 +02:00
blyxyas
9e4a2d7fca
Fixes based on reviews 2023-08-16 14:50:40 +02:00
blyxyas
111f0229da
Add "Method Checking"
Co-authored-by: Nahua <kangnahua@gmail.com>
2023-08-16 14:50:40 +02:00
bors
87d148759a Auto merge of #10595 - blyxyas:book-define_lints, r=flip1995
Clippy Book Chapter Updates Reborn: Defining Lints

Revival of #9659, I've made a few changes (mainly ones from reviews from #9426, like removing mid-section storytelling) and some re-writes. The goal of the project would be to slowly re-write the Clippy book (only chapters that need it) to more up-to-date style.

## Notes

- Things like `git status` commands have changed, we need to make sure that they're correct.
- As this is a team-wide effort, I would please ask anyone and everyone to read it and give your opinion.
- To talk about the whole project, please use the tracking issue for the project #10597  (It also contains a timeline, discussions and more information)

---

changelog: Add a new "Defining lints" chapter to the book

r? `@flip1995`
2023-08-16 12:37:22 +00:00
Philipp Krones
783c119768
Address review comments and formatting 2023-08-16 14:36:09 +02:00
blyxyas
6076cda3c5
Fix CI 2023-08-16 14:30:39 +02:00
blyxyas
b91d676b60
Move "Lint types to the top" 2023-08-16 14:30:39 +02:00
blyxyas
7465436270
Improve briefness 2023-08-16 14:30:39 +02:00
blyxyas
735380b2cc
Try to clear up confusion between type and category. 2023-08-16 14:30:39 +02:00
blyxyas
c22906b37f
Fix CI formatting issues 2023-08-16 14:30:38 +02:00
blyxyas
97d31c8ae0
New chapter: Defining Lints
Co-authored-by: Nahua <kangnahua@gmail.com>
2023-08-16 14:30:38 +02:00
bors
710db18ccd Auto merge of #11336 - Alexendoo:uitest-backslash, r=flip1995
Use ui_test's Windows path backslash heuristic

changelog: none

Instead of unconditionally replacing `\` with `/` we now use [`Match::PathBackslash`](https://docs.rs/ui_test/latest/ui_test/enum.Match.html#variant.PathBackslash) to only replace backslashes in paths that look like windows paths

`ui-toml` and `ui-cargo` tests still use the old way because they produce verbatim paths on windows in some tests (`\\?\C:\foo\...`) which was finnicky to get the replacement order correct with

Also removes the `ui_test` -> `compiletest` alias and `VarGuard`
2023-08-15 15:22:29 +00:00
bors
11efa0133f Auto merge of #11321 - J-ZhengLi:issue11281, r=giraffate
allow calling `to_owned` on borrowed value for [`implicit_clone`]

fixes: #11281

a small and simple fix that give up checking for `referenced_value.to_owned()` usage.

changelog: allow calling `to_owned` with borrowed value for [`implicit_clone`]
2023-08-15 11:42:05 +00:00
J-ZhengLi
aa8995e589 allow calling to_owned with borrowed value for [implicit_clone] 2023-08-15 09:41:15 +08:00
Alex Macleod
77d10ac63d Use ui_test's Windows path backslash heuristic 2023-08-14 15:59:00 +00:00
y21
f47165c703 find expansions more efficiently 2023-08-14 16:50:31 +02:00
y21
2820d980cb [useless_conversion]: fix FP in macro and add test 2023-08-14 16:28:04 +02:00
y21
34348f72f4 [useless_conversion]: make sure path points to fn-like item 2023-08-14 16:28:04 +02:00
bors
b5bfd1176b Auto merge of #11289 - lengyijun:filter_find, r=blyxyas
[iter_overeager_cloned]: detect `.cloned().filter()` and `.cloned().find()`

changelog: [`iter_overeager_cloned`]: detect `.cloned().filter()` and `.cloned().find()`

Key idea:
```
// before
iter.cloned().filter(|x| unimplemented!() )
// after
iter.filter(|&x| unimplemented!() ).cloned()

// before
iter.cloned().filter( foo )
// after
// notice `iter` must be `Iterator<Item= &T>` (callee of `cloned()`)
// so the parameter in the closure of `filter` must be `&&T`
// so the deref is safe
iter.filter(|&x| foo(x) ).cloned()
```
2023-08-14 11:15:45 +00:00
lengyijun
fc061890d6 [iter_overeager_cloned]: detect .cloned().filter() and .cloned().find()
Key idea:
```
// before
iter.cloned().filter(|x| unimplemented!() )
// after
iter.filter(|&x| unimplemented!() ).cloned()

// before
iter.cloned().filter( foo )
// after
iter.filter(|&x| foo(x) ).cloned()
```
2023-08-14 09:13:01 +08:00
bors
344ae115db Auto merge of #11329 - unvalley:lint-binary-heap-retain, r=Alexendoo
[`manual_retain`]: add lint case for `binary_heap`

Closes #9059

This PR adds changes to perform linting on the `binary_heap` as well, under the [manual_retain rule](https://rust-lang.github.io/rust-clippy/master/index.html#/manual_retain).

changelog: [manual_retain]: update for lint `binary_heap`
2023-08-13 14:45:01 +00:00
bors
83afad4cf1 Auto merge of #11333 - Alexendoo:uitest-default-check, r=flip1995
Do not bless by default in ui tests

This restores the default behaviour to check the `.stderr`, it was changed in #11239 to bless by default in `cargo test` (unless in github actions), but check by default in `cargo uitest` which is fairly confusing

It also meant `cargo uitest -F internal` no longer worked

`--bless` prevents the use of `Args::test` but we can look at reintegrating with that after `@oli-obk's` vacation

r? `@flip1995`

changelog: none
2023-08-13 14:33:45 +00:00
unvalley
1eff39ddb6 fix: change msrv to 1.69 for binary heap 2023-08-13 22:52:06 +09:00
Alex Macleod
3ac06a12a5 Do not bless by default in ui tests 2023-08-13 13:25:48 +00:00
unvalley
d5dbee4aa0 feat: update manual_retain to lint binary_heap_retain
refactor: rename variable

chore: reorder

test: update naming for msrv
2023-08-13 17:09:39 +09:00
bors
75370e0671 Auto merge of #11325 - oli-obk:SPEEDTEST, r=flip1995
Fix SPEEDTEST instructions and output

* `--nocapture` hasn't been needed anymore since forever (even before `ui_test`)
* the result was dividing by 1000 instead of the number of test runs, giving bogus (but still useful for the purpose) timing results.

changelog: fix SPEEDTEST instructions and output
2023-08-11 15:30:38 +00:00
Oli Scherer
cd8f12dd36 Show correct measurements in SPEEDTEST 2023-08-11 15:22:23 +00:00
Oli Scherer
a7af8bc6ec Fix SPEEDTEST instructions 2023-08-11 15:22:06 +00:00
bors
739faf3641 Auto merge of #11239 - oli-obk:ui_test, r=Alexendoo,flip1995
Update ui test crate

This update also removes the `//`@run-rustfix`` flag, and just runs rustfix on all tests. This means I had to opt out of running rustfix on ~100 tests, but it also allowed me to remove the rustfix coverage check entirely, as it is now effectively builtin.

changelog: update ui-test crate to 0.13 (automatically runs rustfix on all tests)
2023-08-11 15:14:09 +00:00
Oli Scherer
665a61938d Bump ui_test 2023-08-11 15:08:48 +00:00
Oli Scherer
43f04e12ad Bump ui_test crate 2023-08-11 14:03:06 +00:00
Oli Scherer
1088507a30 Canonicalize paths in a single location 2023-08-11 14:02:52 +00:00
Oli Scherer
00919a4f92 Update ui test crate to auto-detect aux build crate kind 2023-08-11 14:02:35 +00:00
Oli Scherer
3d88fae050 Update ui test crate 2023-08-11 14:02:28 +00:00
Oli Scherer
0afd38b093 Make a panic message more informative if binary files are accidentally created somewhere in the test folder 2023-08-11 14:01:53 +00:00
Oli Scherer
4c779da913 Remove some leftover cruft from compiletest-rs 2023-08-11 13:59:54 +00:00
bors
1e8fdf4928 Auto merge of #11320 - max-niederman:redundant_locals_shadow_mutated, r=Alexendoo
redundant_locals: fix FPs on mutated shadows

Fixes #11290.

When a mutable binding is shadowed by
a mutable binding of the same name in a different scope, mutations in that scope have different meaning.
This PR fixes spurious `redundant_locals` emissions on such locals.

cc `@Centri3,` `@flip1995`

changelog: [`redundant_locals`]: fix false positives on mutated shadows
2023-08-11 10:58:13 +00:00
bors
8703661a9a Auto merge of #11316 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

cc `@max-niederman` With the latest sync, I'm getting a lot of FP in the `redundant_locals` lint you recently added. Any ideas where this could come from?

changelog: none
2023-08-11 08:54:35 +00:00
Philipp Krones
3927677234
Dogfood and bless tests 2023-08-11 10:53:18 +02:00
Philipp Krones
0fc051ddba
Fix redundant_locals for Async desugaring 2023-08-11 10:51:18 +02:00
Max Niederman
a5f62bdfcd
redundant_locals: fix FPs on mutated shadows
When a mutable binding is shadowed by
a mutable binding of the same name in a different scope,
mutations in that scope have different meaning.
This commit fixes spurious `redundant_locals` emissions
on such locals.
2023-08-10 19:53:45 -07:00