Commit Graph

24277 Commits

Author SHA1 Message Date
Samuel Tardieu 0ea973e49c Fix adjustments 2025-11-18 09:21:21 +01:00
Philipp Krones 62589a21d3 Rustup (#16094)
r? @ghost

changelog: none
2025-11-15 00:05:34 +00:00
Philipp Krones 72fc40c3d0 Fix fn_to_numeric_cast 32 bit stderr 2025-11-15 00:58:12 +01:00
Philipp Krones ca4557c692 Bump nightly version -> 2025-11-15 2025-11-15 00:37:56 +01:00
Philipp Krones 03cd6b6dd8 Merge remote-tracking branch 'upstream/master' into rustup 2025-11-15 00:37:39 +01:00
Alejandra González c48592eb49 Use extend when creating the lint pass constructors (#15994)
Alternative to part of rust-lang/rust-clippy#14509.

changelog: none
2025-11-14 14:18:36 +00:00
llogiq f1c74612e0 refactor(rc_buffer): remove RcKind (#16089)
not really necessary

Follow-up to https://github.com/rust-lang/rust-clippy/pull/15803

changelog: none

r? @llogiq
2025-11-14 14:12:37 +00:00
Jason Newcomb 2027c0e02b Update dev new_lint to add passes to each array. 2025-11-14 07:50:55 -05:00
Jason Newcomb cd41914e31 Register late passes with extend instead of register_late_pass. 2025-11-14 07:50:21 -05:00
Jason Newcomb bffde26197 Register early passes with extend instead of register_early_pass. 2025-11-14 07:49:03 -05:00
llogiq 540e2f4a2a feat(ok_expect): add autofix (#15867)
changelog: [`ok_expect`]: add autofix
2025-11-14 12:12:31 +00:00
Ada Alakbarova 3bef3ff3d4 refactor(rc_buffer): remove RcKind
not really necessary
2025-11-14 12:03:05 +01:00
llogiq 663ef9b31b fix(rc_buffer): don't touch the path to Rc/Arc in the suggestion (#15803)
Fixes https://github.com/rust-lang/rust-clippy/issues/15802

changelog: [`rc_buffer`]: don't touch the path to `Rc`/`Arc` in the
suggestion
2025-11-14 09:52:59 +00:00
Samuel Tardieu 4016c0fdb8 Add documentation for clippy_utils::numeric_literal (#16078)
For rust-lang/rust-clippy#15569

changelog: none
2025-11-13 22:48:54 +00:00
Fernando Valentim Torres 44700b962e add documentation comments for clippy_utils::numeric_literal 2025-11-13 15:57:58 -03:00
Samuel Tardieu 801e5b3cc0 Fix website history interactions (#16060)
cc @GuillaumeGomez

- Searching/filtering no longer creates a new history entry per
keystroke/change
- Loading a URL with a specified search query now works. The search is
now stored as `?search=foo` instead of `#/foo`, not a breaking change
since this didn't work before
- The browser back/forward actions now update the filters/search and
displayed lints

The bulk of the changes are to support that last one, previously the
filter state was stored both in the DOM and as JS objects. The DOM is
now the single source of truth

changelog: none
2025-11-13 08:56:08 +00:00
Timo 0ac66461bb refactor(needless_arbitrary_self_type): give suggestions with finer diffs (#16005)
changelog: [`needless_arbitrary_self_type`]: give suggestions with finer
diffs
2025-11-12 20:49:39 +00:00
Philipp Krones da2a220a2e incompatible_msrv: Don't check the contents of any std macro. (#16083)
cc rust-lang/rust#148190 @flip1995 @RalfJung

This is a bit of a hack in that it hardcodes the list of crates with
stability attributes. This shouldn't be a big deal since that isn't a
set that changes very frequently and an internal lint could detect when
that happens.

The `fixme`s added aren't new issues and shouldn't get in the way of
unblocking the upstream issue.

changelog: none
2025-11-12 17:22:17 +00:00
Jason Newcomb a537e86e7f incompatible_msrv: Don't check the contents of any std macro. 2025-11-12 12:01:16 -05:00
Mara Bos 3352bea655 Bless clippy tests. 2025-11-12 14:43:05 +01:00
Mara Bos 7ae882efd0 Bless clippy tests. 2025-11-12 12:48:39 +01:00
Mara Bos 18de21629a Make clippy happy. 2025-11-12 12:48:36 +01:00
Mads Marquart 70cfebbddc Fix building rustdoc and clippy with jemalloc feature 2025-11-11 20:16:16 +01:00
Mads Marquart a72893f708 Simplify jemalloc setup
Using the new `override_allocator_on_supported_platforms` feature in
`tikv-jemalloc-sys v0.6.1` we can avoid the manual statics.
2025-11-11 20:16:15 +01:00
Samuel Tardieu d599529223 Fix single_range_in_vec_init FP for explicit Range (#16043)
Closes rust-lang/rust-clippy#16042
Closes rust-lang/rust-clippy#16044

changelog: [`single_range_in_vec_init`] fix FP for explicit `Range`
2025-11-11 10:28:46 +00:00
Stuart Cook 39107ffff6 Rollup merge of #141470 - GuillaumeGomez:function_casts_as_integer, r=urgau
Add new `function_casts_as_integer` lint

The `function_casts_as_integer` lint detects cases where users cast a function pointer into an integer.

*warn-by-default*

### Example

```rust
fn foo() {}
let x = foo as usize;
```

```
warning: casting a function into an integer implicitly
  --> $DIR/function_casts_as_integer.rs:9:17
   |
LL |     let x = foo as usize;
   |                 ^^^^^^^^
   |
help: add `fn() as usize`
   |
LL |     let x = foo as fn() as usize;
   |                 +++++++
```

### Explanation

You should never cast a function directly into an integer but go through a cast as `fn` first to make it obvious what's going on. It also allows to prevent confusion with (associated) constants.

Related to https://github.com/rust-lang/rust/issues/81686 and https://stackoverflow.com/questions/68701177/whats-the-meaning-of-casting-a-rust-enum-variant-to-a-numeric-data-type

r? ````@urgau````
2025-11-11 21:09:32 +11:00
llogiq 0b30af05dc Fix useless_let_if_seq FN when if is in the last expr of block (#16063)
Closes rust-lang/rust-clippy#16062
Closes rust-lang/rust-clippy#16064

changelog: [`useless_let_if_seq`] fix FN when `if` is in the last expr
of block
2025-11-10 23:54:24 +00:00
Linshu Yang e1ac7da6a1 fix: useless_let_if_seq wrongly unmangled macros 2025-11-10 20:01:15 +00:00
Linshu Yang 8a1dde1449 fix: useless_let_if_seq FN when if is in the last expr of block 2025-11-10 19:30:50 +00:00
Linshu Yang 6834ab61b1 fix: single_range_in_vec_init wrongly unmangles macros 2025-11-10 17:25:01 +00:00
Linshu Yang c8885d5313 fix: single_range_in_vec_init FP for explicit Range 2025-11-10 17:25:01 +00:00
Alex Macleod 4e35148a50 Fix website history interactions 2025-11-10 16:29:45 +00:00
dswij 3c3452a3b1 Fix mod_module_files false positive for tests in workspaces (#16048)
Workspaces don't have their integration tests in tests/ at the root, so
this check missed them.

This fixes rust-lang/rust-clippy#11775 for workspaces.

changelog: [`mod_module_files`]: Fix false positive for integration
tests in workspace crates.
2025-11-10 16:27:47 +00:00
Guillaume Gomez d16f26b944 Allow function_casts_as_integer in non-related clippy ui tests 2025-11-10 16:38:28 +01:00
Frank King 276053175d Implement &pin patterns and ref pin bindings 2025-11-10 09:57:08 +08:00
Stuart Cook f5ccdae676 Rollup merge of #128666 - pitaj:intrinsic-overflow_checks, r=BoxyUwU
Add `overflow_checks` intrinsic

This adds an intrinsic which allows code in a pre-built library to inherit the overflow checks option from a crate depending on it. This enables code in the standard library to explicitly change behavior based on whether `overflow_checks` are enabled, regardless of the setting used when standard library was compiled.

This is very similar to the `ub_checks` intrinsic, and refactors the two to use a common mechanism.

The primary use case for this is to allow the new `RangeFrom` iterator to yield the maximum element before overflowing, as requested [here](https://github.com/rust-lang/rust/issues/125687#issuecomment-2151118208). This PR includes a working `IterRangeFrom` implementation based on this new intrinsic that exhibits the desired behavior.

[Prior discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Ability.20to.20select.20code.20based.20on.20.60overflow_checks.60.3F)
2025-11-09 13:22:23 +11:00
bors 5b5709b248 Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU
mgca: Add ConstArg representation for const items

tracking issue: rust-lang/rust#132980
fixes rust-lang/rust#131046
fixes rust-lang/rust#134641

As part of implementing `min_generic_const_args`, we need to distinguish const items that can be used in the type system, such as in associated const equality projections, from const items containing arbitrary const code, which must be kept out of the type system. Specifically, all "type consts" must be either concrete (no generics) or generic with a trivial expression like `N` or a path to another type const item.

To syntactically distinguish these cases, we require, for now at least, that users annotate all type consts with the `#[type_const]` attribute. Then, we validate that the const's right-hand side is indeed eligible to be a type const and represent it differently in the HIR.

We accomplish this representation using a new `ConstItemRhs` enum in the HIR, and a similar but simpler enum in the AST. When `#[type_const]` is **not** applied to a const (e.g. on stable), we represent const item right-hand sides (rhs's) as HIR bodies, like before. However, when the attribute is applied, we instead lower to a `hir::ConstArg`. This syntactically distinguishes between trivial const args (paths) and arbitrary expressions, which are represented using `AnonConst`s. Then in `generics_of`, we can take advantage of the existing machinery to bar the `AnonConst` rhs's from using parent generics.
2025-11-08 22:31:33 +00:00
Noah Lev 7a745ff987 Use "rhs" terminology instead of "body" 2025-11-08 13:50:48 -05:00
Noah Lev 8cb6e1bfcf Fix clippy
When mgca is enabled, const rhs's that are paths may have false
negatives with the lints in non_copy_const.rs. But these should probably
be using the trait solver anyway, and it only happens under mgca.
2025-11-08 13:50:48 -05:00
Ada Alakbarova a4a88ea592 refactor(needless_arbitrary_self_type): give suggestions with finer diffs 2025-11-08 19:48:32 +01:00
Jason Newcomb d154da9773 chore(unnecessary_mut_passed): show the intention not to lint &raw references (#16049)
Supersedes https://github.com/rust-lang/rust-clippy/pull/15962

changelog: none

r? @Jarcho
2025-11-08 14:24:20 +00:00
Timo ee4390f070 perf(manual_is_power_of_two): perform the is_integer_literal check first (#16050)
.. as it's much cheaper than `count_ones_receiver`

changelog: none
2025-11-08 12:11:30 +00:00
Ada Alakbarova b59b2fdddb chore(unnecessary_mut_passed): show the intention not to lint &raw references 2025-11-08 10:15:17 +01:00
Alex Macleod 6e3348906c chore(unnecessary_map_on_constructor): clean-up (#16051)
- reduce indentation
- print constructor/method name in backticks

changelog: [`unnecessary_map_on_constructor`]: print constructor/method
name in backticks
2025-11-08 00:35:10 +00:00
Ada Alakbarova 21ddc50eec chore(unnecessary_map_on_constructor): clean-up
- reduce indentation
- print constructor/method name in backticks
2025-11-07 22:14:03 +01:00
Ada Alakbarova 9147a36ba6 perf(manual_is_power_of_two): perform the is_integer_literal check first
.. as it's much cheaper than `count_ones_receiver`
2025-11-07 21:37:51 +01:00
Philipp Krones dddaf0768c Make bug report issue template more similar to that of rust-lang/rust (#16047)
It's always a bit jarring to be required to provide the expected output
first, as usually one starts with having the existing output, and
modifies that.

This commit reorders the two steps, and also gives them the same names
as `rust-lang/rust` for some extra consistency

changelog: none
2025-11-07 16:22:18 +00:00
Tom Fryers da7bde794c Fix mod_module_files FP for tests in workspaces
Workspaces don't have their integration tests in tests/ at the root, so
this check missed them.
2025-11-07 12:59:25 +00:00
Ada Alakbarova e6a3dde496 Make bug report issue template more similar to that of rust-lang/rust
It's always a bit jarring to be required to provide the expected output
first, as usually one starts with having the existing output, and
modifies that.

This commit reorders the two steps, and also gives them the same names
as `rust-lang/rust` for some extra consistency
2025-11-07 08:26:12 +01:00
llogiq 8ed05abef3 Fix missing_asserts_for_indexing changes assert_eq to assert (#16040)
Closes rust-lang/rust-clippy#16026

changelog: [`missing_asserts_for_indexing`] fix wrongly changing
`assert_eq` to `assert`
2025-11-06 22:28:32 +00:00