Commit graph

20872 commits

Author SHA1 Message Date
blyxyas
5ea7044d72 Temporarily remove myself from reviewer rotation 2024-07-23 23:52:26 +02:00
bors
e91d82eabb Auto merge of #13143 - Alexendoo:transmute-ptr-to-ptr-suggestions, r=y21
Suggest `.cast`/`.cast_const`/`.cast_mut` in `transmute_ptr_as_ptr`

Essentially pre-applies `ptr_as_ptr` - https://github.com/rust-lang/rust-clippy/issues/6372#issuecomment-1830438907

changelog: none
2024-07-23 21:48:07 +00:00
Alex Macleod
493498b65f Make BindInsteadOfMap a struct
Makes it codegen once instead of three times
2024-07-23 20:57:35 +00:00
Alex Macleod
af6d49d97c Fix running compile-test under cargo nextest 2024-07-23 16:15:54 +00:00
bors
bd1224d8aa Auto merge of #13148 - xFrednet:lintcheck-link-correction-again, r=Alexendoo
Lintcheck: Support underscores replacement in URL crate names

The generated URLs use `{krate}` for the crate name. This works well for the first part of the docs.rs domain, but the second part is actually the root module, which requires a replacement of all dashes with underscores. This PR adds `{krate_}` for the root module name.

Diff:

```diff
 Removed `clippy::needless_borrows_for_generic_args` in `rustls-pemfile` at
-https://docs.rs/rustls-pemfile/2.1.2/src/rustls-pemfile/pemfile.rs.html#194
+https://docs.rs/rustls-pemfile/2.1.2/src/rustls_pemfile/pemfile.rs.html#194
```

> Example before: https://github.com/xFrednet/rust-clippy/actions/runs/10054236377?pr=4
> Example after: https://github.com/xFrednet/rust-clippy/actions/runs/10054878594?pr=4

---

changelog: none

r? `@Alexendoo`
2024-07-23 11:51:53 +00:00
Alex Macleod
7010d3c67e Don't suggest .cast_mut/.cast_const for types with erased lifetimes 2024-07-23 11:12:26 +00:00
jusexton
0cdf6e172c Fix while_let_on_iterator dropping loop label when applying fix. 2024-07-23 02:55:58 -05:00
xFrednet
04693a4eca
Lintcheck: Support underscores replacement in URL crate names 2024-07-23 09:46:59 +02:00
bors
df1baedfde Auto merge of #13050 - Jarcho:misc_small, r=xFrednet
Misc refactorings

Various small re-orderings to check the HIR tree or AST before doing other checks. Also includes a small bug fix for `arc_with_small_send_sync` not actually checking for `Arc::new`.

changelog: none
2024-07-22 20:25:05 +00:00
Michael Goulet
e2a7000b6b Get rid of infer_ctxt_ext 2024-07-22 16:15:52 -04:00
bors
f9c240720a Auto merge of #13072 - Jarcho:misc_small5, r=xFrednet
Misc refactorings part 5

`toplevel_ref_arg` gets a small fix so it can be allowed on function arguments. Otherwise just some rearrangements.

changelog: none
2024-07-22 19:58:25 +00:00
bors
637d39fab8 Auto merge of #13065 - Jarcho:misc_small2, r=xFrednet
Misc refactorings part 2

A couple of theses are a bit more involved. No behaviour changes included in this set.

changelog: none
2024-07-22 19:40:50 +00:00
xFrednet
d17f113474
Make restriction lint's use span_lint_and_then (m -> m) 2024-07-22 19:47:34 +02:00
xFrednet
bc8fc6b1d8
Make restriction lint's use span_lint_and_then (i -> l) 2024-07-22 19:47:29 +02:00
Alex Macleod
afe811ad30 Suggest .cast/.cast_const/.cast_mut in transmute_ptr_as_ptr 2024-07-22 17:31:45 +00:00
xFrednet
23b231a5d6
Lintcheck: Fix Errors, because of course 2024-07-22 18:19:37 +02:00
xFrednet
10bf729e3f
Lintcheck: Include truncated diff in CI artifacts 2024-07-22 18:10:03 +02:00
xFrednet
1f879fc0cf
Lintcheck: Minor cleanup and function moves 2024-07-22 18:02:39 +02:00
xFrednet
4fea5199e4
Lintcheck: Order summary by lint and truncate messages 2024-07-22 17:59:26 +02:00
xFrednet
4798383c33
Lintcheck: Limit summary size to 1024k and copy to logs 2024-07-22 17:59:09 +02:00
Oli Scherer
221ac86e09 Always pass the visitor as the first argument to walk* functions 2024-07-22 14:01:24 +00:00
Oli Scherer
3149037b57 Sync mut_visit function names with immut visit ones (s/noop_visit/walk/) 2024-07-22 14:01:24 +00:00
Michael Goulet
efde1c065b Fix tools 2024-07-21 22:34:37 -04:00
Michael Goulet
897c4d3adb Move all error reporting into rustc_trait_selection 2024-07-21 22:34:35 -04:00
bors
1807580a49 Auto merge of #12772 - phi-gamma:redundant-struct-recreation, r=y21
add lint for recreation of an entire struct

This lint makes Clippy warn about situations where an owned struct is
essentially recreated by moving all its fields into a new instance of
the struct. The lint is not machine-applicable because the source
struct may have been partially moved.

This lint originated in something I spotted during peer review. While
working on their branch a colleague ended up with a commit where a
function returned a struct that 1:1 replicated one of its owned inputs
from its members. Initially I suspected they hadn’t run their code
through Clippy but AFAICS there is no lint for this situation yet.

changelog: new lint: [`redundant_owned_struct_recreation`]

### New lint checklist

- \[+] Followed [lint naming conventions][lint_naming]
- \[+] Added passing UI tests (including committed `.stderr` file)
- \[+] `cargo test` passes locally
- \[+] Executed `cargo dev update_lints`
- \[+] Added lint documentation
- \[+] Run `cargo dev fmt`
2024-07-21 23:02:38 +00:00
bors
5f3d385421 Auto merge of #120812 - compiler-errors:impl-sorting, r=lcnr
Remove unnecessary impl sorting in queries and metadata

Removes unnecessary impl sorting because queries already return their keys in HIR definition order: https://github.com/rust-lang/rust/issues/120371#issuecomment-1926422838

r? `@cjgillot` or `@lcnr` -- unless I totally misunderstood what was being asked for here? 😆

fixes #120371
2024-07-21 22:43:47 +00:00
bors
7f0ed11213 Auto merge of #13133 - xFrednet:lintcheck-linkify-summary, r=Alexendoo
Lintcheck: Cleanup of Lintcheck's CI summery

This PR makes three changes to lintcheck's job summary:
* Adds links to the *Added*, *Removed*, *Changed* sections
* Added the crate name to the warning info
* Removes empty lines from the rendered output

This is what the new output roughly looks like:

![image](https://github.com/user-attachments/assets/3faae0a6-e5ee-4e70-9d4d-d19b18dc6a3a)
![image](https://github.com/user-attachments/assets/028c3a92-98dc-4e00-b7bb-fecf9450f5b1)

[🖼️ Old Output 🖼️](https://github.com/xFrednet/rust-clippy/actions/runs/10019681444)

[🖼️ New Output 🖼️](https://github.com/xFrednet/rust-clippy/actions/runs/10019598141)

The links for the sections are a bit weird as you have to click on them twice. I believe this is a bug from GH's side. But it works reasonably well :D

---

changelog: none

r? `@Alexendoo`
2024-07-21 12:37:00 +00:00
bors
8fe5c757d5 Auto merge of #11700 - lengyijun:pathbuf_join, r=xFrednet
[`pathbuf_init_then_push`]:  Checks for calls to `push` immediately a…

changelog: [`pathbuf_init_then_push`]: new lint: Checks for calls to `push` immediately after creating a new `PathBuf`

Just a mirror of VEC_INIT_THEN_PUSH
2024-07-21 06:39:01 +00:00
lengyijun
cb77f12600 [pathbuf_init_then_push]: Checks for calls to push immediately after creating a new PathBuf
Co-authored-by: Fridtjof Stoldt <xFrednet@gmail.com>
2024-07-21 14:22:48 +08:00
xFrednet
69c3289f2b
Lintcheck: Include the crate name in the CI job summary 2024-07-20 13:25:44 +02:00
xFrednet
83c8385ad1
Lintcheck: Remove empty lines from rendered CI output 2024-07-20 13:25:44 +02:00
xFrednet
09906b8221
Lintcheck: Linkify counts in CI summery 2024-07-20 13:13:13 +02:00
bors
b02cb2401d Auto merge of #13131 - waywardmonkeys:reduce-typo-count, r=Alexendoo
Reduce typo count.

changelog: none
2024-07-20 11:05:12 +00:00
Bruce Mitchener
cf4270d13b Reduce typo count. 2024-07-20 12:50:36 +07:00
Yuri Astrakhan
266abf3c08 Avoid ref when using format!
Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing).

Inlining format args prevents accidental `&` misuse.
2024-07-19 16:10:24 -04:00
bors
057c4ae287 Auto merge of #13124 - xFrednet:00000-lintcheck-crates, r=Alexendoo
Lintcheck: Update crates and expand CI testset to 200 crates

This PR adds a new `ci_crates.toml` to lintcheck for our CI. The 200 crates take about 14 minutes, which is slightly more than the 10 I aimed for but still reasonable. The testset is constructed from:

* 5 crates that compile to binaries
* 4 crates that have been mentioned in ICE issues
* 1 crates "random" crates from `lintcheck_crates.toml`
* 190 crates from the top 200 crates from crates.io

During testing, I noticed a few panics in lintcheck. I've fixed them where possible, or at least improved the error message.

The new test set generates 500+ MB of json lints, which are compressed to a ~24mb artifact.

---

This PR also updates our `lintcheck_crates.toml`. I mainly updated the versions, removed some very outdated crates, and added some new ones. I targeted 25 crates as those are pretty fast to lint and a good precursor for our CI.

---

Optional TODO:

* It's likely that some crates are compiled several times. We could potentially safe some time, by using `--recursive` in our CI.
    This is something I want to investigate, but it shouldn't be a blocker for this PR.

---

r? `@Alexendoo`

changelog: none
2024-07-19 18:07:52 +00:00
xFrednet
8940bc3c46
Lintcheck: New testset for Clippy's CI (200 crates for ~10 min) 2024-07-19 19:52:07 +02:00
xFrednet
4ece12da32
Lintcheck: Update the default testset for local lintcheck 2024-07-19 19:52:03 +02:00
xFrednet
46ebe0cb68
Lintcheck: Normalize thread IDs in shared_target_dir 2024-07-19 19:51:41 +02:00
bors
ac2ba15add Auto merge of #13129 - xFrednet:interesting-life-choices, r=xFrednet
Add xFrednet back to Clippy's reviewer roulette

What the title says.

---

cc: https://github.com/rust-lang/rust-clippy/pull/12947

changelog: none

r? `@ghost`
2024-07-19 15:55:25 +00:00
xFrednet
14e271121c
Triagebot: Add xFrednet back to Clippy's reviewer roulette 2024-07-19 17:52:22 +02:00
bors
8051d073d1 Auto merge of #125915 - camelid:const-arg-refactor, r=BoxyUwU
Represent type-level consts with new-and-improved `hir::ConstArg`

### Summary

This is a step toward `min_generic_const_exprs`. We now represent all const
generic arguments using an enum that differentiates between const *paths*
(temporarily just bare const params) and arbitrary anon consts that may perform
computations. This will enable us to cleanly implement the `min_generic_const_args`
plan of allowing the use of generics in paths used as const args, while
disallowing their use in arbitrary anon consts. Here is a summary of the salient
aspects of this change:

- Add `current_def_id_parent` to `LoweringContext`

  This is needed to track anon const parents properly once we implement
  `ConstArgKind::Path` (which requires moving anon const def-creation
  outside of `DefCollector`).

- Create `hir::ConstArgKind` enum with `Path` and `Anon` variants. Use it in the
  existing `hir::ConstArg` struct, replacing the previous `hir::AnonConst` field.

- Use `ConstArg` for all instances of const args. Specifically, use it instead
  of `AnonConst` for assoc item constraints, array lengths, and const param
  defaults.

- Some `ast::AnonConst`s now have their `DefId`s created in
  rustc_ast_lowering rather than `DefCollector`. This is because in some
  cases they will end up becoming a `ConstArgKind::Path` instead, which
  has no `DefId`. We have to solve this in a hacky way where we guess
  whether the `AnonConst` could end up as a path const since we can't
  know for sure until after name resolution (`N` could refer to a free
  const or a nullary struct). If it has no chance as being a const
  param, then we create a `DefId` in `DefCollector` -- otherwise we
  decide during ast_lowering. This will have to be updated once all path
  consts use `ConstArgKind::Path`.

- We explicitly use `ConstArgHasType` for array lengths, rather than
  implicitly relying on anon const type feeding -- this is due to the
  addition of `ConstArgKind::Path`.

- Some tests have their outputs changed, but the changes are for the
  most part minor (including removing duplicate or almost-duplicate
  errors). One test now ICEs, but it is for an incomplete, unstable
  feature and is now tracked at https://github.com/rust-lang/rust/issues/127009.

### Followup items post-merge

- Use `ConstArgKind::Path` for all const paths, not just const params.
- Fix (no github dont close this issue) #127009
- If a path in generic args doesn't resolve as a type, try to resolve as a const
  instead (do this in rustc_resolve). Then remove the special-casing from
  `rustc_ast_lowering`, so that all params will automatically be lowered as
  `ConstArgKind::Path`.
- (?) Consider making `const_evaluatable_unchecked` a hard error, or at least
  trying it in crater

r? `@BoxyUwU`
2024-07-19 08:44:51 +00:00
Michael Goulet
8a0ccd30d1 Make clippy and rustdoc happy 2024-07-18 16:51:05 -04:00
xFrednet
642ab11a48
Changelog for Clippy 1.80 🌞 2024-07-18 20:58:50 +02:00
apoisternex
58027e2657 Fix [redundant_slicing] when the slice is behind a mutable reference
Fixes #12751

changelog: Fix [`redundant_slicing`] when the slice is behind a mutable reference
2024-07-18 15:23:04 -03:00
xFrednet
e34db99b2e
Update version attribute for 1.80 lints 2024-07-18 20:13:39 +02:00
xFrednet
9d82fb460a
Lintcheck: More info on Diags without spans 2024-07-18 16:41:06 +02:00
xFrednet
31fdc2ec09
Lintcheck: Remove rust-toolchain from downloaded crates 2024-07-18 16:41:05 +02:00
bors
b31bce4f5f Auto merge of #13104 - xFrednet:00000-lintcheck-better-md-links, r=Alexendoo
Lintcheck: Add URL to lint emission place in diff

This PR adds links to the emission code in our lintcheck CI. When reviewing changes, I would like to be able to see the bigger context, which isn't always included in the lint message. This PR adds a nice link to the lintcheck diff that allows for simple investigation of the code in question.

At first, I wanted to simply use the doc.rs links and call it a day, but then I figured out that some crates might have their source files remapped. Cargo was the crate that made me notice this. As a response, I made the link configurable. (See https://github.com/rust-lang/docs.rs/issues/2551 for a detailed explanation and possible solution to remove this workaround in the future.)

It's probably easiest to review the individual commits. The last one is just a dummy to showcase the change.

[🖼️ rendered 🖼️](https://github.com/rust-lang/rust-clippy/actions/runs/9960834924?pr=13104)

---

r? `@Alexendoo`

changelog: none

---

That's it, I hope that everyone who's reading this has a beautiful day :D
2024-07-18 13:31:12 +00:00
xFrednet
0e3d19799c
Lintcheck: Construct links for sources 2024-07-18 15:28:14 +02:00