Commit Graph

20962 Commits

Author SHA1 Message Date
bors
2d2e8cc21f Auto merge of #13485 - GnomedDev:reduce-large-threshold, r=xFrednet
Reduce default 'large array' threshold

As-is this threshold is `512kb`, but as #9449 points out this is way too high for most people to consider sensible (why would you want to copy `256kb` of data around on the stack or duplicate it via `const`) and didn't get any discussion when originally added. This PR reduces it the threshold to `1kb`, which is higher than the issue says ("a few cpu words") but helps out for actual codebases.

While reducing this, I found that `large_stack_arrays` was triggering for statically promoted arrays in constants/statics, so I also fixed that up as seen in the difference to [array_size_threshold.stderr](https://github.com/rust-lang/rust-clippy/compare/master...GnomedDev:rust-clippy:reduce-large-threshold?expand=1#diff-4c2a2a855d9ff7777f1d385be0c1bede2a3fc8aaab94837cde27a35235233fc7).

Closes #9449.

changelog: [`large_stack_arrays`]: No longer triggers in `static`/`const` context
changelog: [`large_const_arrays`]: Changed the default of [`array-size-threshold`] from `512kb` to `16kb`
2024-10-06 11:24:28 +00:00
bors
d0507302fc Auto merge of #130540 - veera-sivarajan:fix-87525, r=estebank
Add a Lint for Pointer to Integer Transmutes in Consts

Fixes #87525

This PR adds a MirLint for pointer to integer transmutes in const functions and associated consts. The implementation closely follows this comment: https://github.com/rust-lang/rust/pull/85769#issuecomment-880969112. More details about the implementation can be found in the comments.

Note: This could break some sound code as mentioned by RalfJung in https://github.com/rust-lang/rust/pull/85769#issuecomment-886491680:

> ... technically const-code could transmute/cast an int to a ptr and then transmute it back and that would be correct -- so the lint will deny some sound code. Does not seem terribly likely though.

References:
1. https://doc.rust-lang.org/std/mem/fn.transmute.html
2. https://doc.rust-lang.org/reference/items/associated-items.html#associated-constants
2024-10-06 02:39:23 +00:00
Samuel Tardieu
0596a04bf4 unused_result_ok: added in Clippy 1.82.0, not 1.70.0 2024-10-05 23:50:14 +02:00
Samuel Tardieu
846bd30cfe raw_strings: separate raw string detection from lint logic 2024-10-05 23:17:29 +02:00
bors
753629bb33 Auto merge of #13412 - GnomedDev:regex-comp-in-loop, r=y21
Implement lint for regex::Regex compilation inside a loop

Closes #598.

Seems like a pretty simple one, I'm not sure if I sorted out all the lint plumbing correctly because I was adding it to the existing regex pass, but seems to work. The name is a bit jank and I'm super open to suggestions for changing it.

changelog: [`regex_creation_in_loops`]: Added lint for Regex compilation inside loops.
2024-10-05 18:41:45 +00:00
bors
f173eb3aef Auto merge of #13505 - samueltardieu:lintcheck-bump-futures, r=y21
lintcheck: bump futures* crates to 0.3.31

changelog: none
2024-10-05 18:21:17 +00:00
Samuel Tardieu
9dd6820edd lintcheck: bump futures* crates to 0.3.31
Version 0.3.30 doesn't compile with our nightly version.
2024-10-05 19:04:45 +02:00
GnomedDev
196dbcf6d5
Avoid linting for Regexes compiled in items defined in loops 2024-10-05 17:10:21 +01:00
Veera
98b59a1cf6 Add a Lint for Pointer to Integer Transmutes in Consts 2024-10-05 12:48:02 +00:00
Matthias Krüger
a0653c5e98 Rollup merge of #131256 - RalfJung:f16-f128-const, r=ibraheemdev
move f16/f128 const fn under f16/f128 feature gate

The `*_const` features were added to work around https://github.com/rust-lang/rust/issues/129656, which should not be needed any more.
2024-10-05 13:15:58 +02:00
Ralf Jung
7f390d6fe0 move f16/f128 const fn under f16/f128 feature gate 2024-10-05 10:13:18 +02:00
bors
a1beaa1992 Auto merge of #129244 - cjgillot:opaque-hir, r=compiler-errors
Make opaque types regular HIR nodes

Having opaque types as HIR owner introduces all sorts of complications. This PR proposes to make them regular HIR nodes instead.

I haven't gone through all the test changes yet, so there may be a few surprises.

Many thanks to `@camelid` for the first draft.
Fixes https://github.com/rust-lang/rust/issues/129023

Fixes #129099
Fixes #125843
Fixes #119716
Fixes #121422
2024-10-05 06:19:35 +00:00
ismailarilik
0b632ec812 Handle clippy cases of rustc::potential_query_instability lint 2024-10-05 07:34:14 +03:00
Jubilee
7bac9cd747 Rollup merge of #129517 - cjgillot:known-panic-array, r=pnkfelix
Compute array length from type for unconditional panic lint.

Fixes https://github.com/rust-lang/rust/issues/98444

The cases that involve slicing are harder, so https://github.com/rust-lang/rust/issues/38035 remains open.
2024-10-04 19:19:22 -07:00
Camille GILLOT
810bd5dd09 Bless clippy. 2024-10-05 00:19:43 +00:00
Camille GILLOT
8ad3e13765 Adapt clippy. 2024-10-04 23:50:02 +00:00
Noah Lev
1a29a78335 rm ItemKind::OpaqueTy
This introduce an additional collection of opaques on HIR, as they can no
longer be listed using the free item list.
2024-10-04 23:28:22 +00:00
Jubilee
47b681d276 Rollup merge of #130518 - scottmcm:stabilize-controlflow-extra, r=dtolnay
Stabilize the `map`/`value` methods on `ControlFlow`

And fix the stability attribute on the `pub use` in `core::ops`.

libs-api in https://github.com/rust-lang/rust/issues/75744#issuecomment-2231214910 seemed reasonably happy with naming for these, so let's try for an FCP.

Summary:
```rust
impl<B, C> ControlFlow<B, C> {
    pub fn break_value(self) -> Option<B>;
    pub fn map_break<T>(self, f: impl FnOnce(B) -> T) -> ControlFlow<T, C>;
    pub fn continue_value(self) -> Option<C>;
    pub fn map_continue<T>(self, f: impl FnOnce(C) -> T) -> ControlFlow<B, T>;
}
```

Resolves #75744

``@rustbot`` label +needs-fcp +t-libs-api -t-libs

---

Aside, in case it keeps someone else from going down the same dead end: I looked at the `{break,continue}_value` methods and tried to make them `const` as part of this, but that's disallowed because of not having `const Drop`, so put it back to not even unstably-const.
2024-10-04 14:11:34 -07:00
GnomedDev
995eb95000
Fix TRAIT_METHODS being large const array 2024-10-04 19:07:40 +01:00
GnomedDev
26994e2519
Reduce default 'large array' threshold 2024-10-04 19:07:40 +01:00
GnomedDev
4b7c19018d
Fix large_stack_arrays triggering for static/constants 2024-10-04 19:06:39 +01:00
y21
19d1358b31 print cause chain in mutable_key_type 2024-10-03 21:27:05 +00:00
bors
a01975b152 Auto merge of #13493 - y21:trait_duplication_in_bounds_fix, r=Manishearth
Compare trait references in `trait_duplication_in_bounds` correctly

Fixes #13476
Fixes #11067
Fixes #9915
Fixes #9626

Currently, the `trait_duplication_in_bounds` lints has a helper type for a trait reference that can be used for comparison and hashing, represented as `{trait: Res, generic_args: Vec<Res>}`. However, there are a lot of issues with this. For one, a `Res` can't represent e.g. references, slices, or lots of other types, as well as const generics and associated type equality. In those cases, the lint simply ignores them and has no way of checking if they're actually the same.

So, instead of using `Res` for this, use `SpanlessEq` and `SpanlessHash` for comparisons with the trait path for checking if there are duplicates.

However, using `SpanlessEq` as is alone lead to a false negative in the test. `std::clone::Clone` + `foo::Clone` wasn't recognized as a duplicate, because it has different segments. So this also adds a new "mode" to SpanlessEq which compares by final resolution. (I've been wondering if this can't just be the default but it's quite a large scale change as it affects a lot of lints and I haven't yet looked at all uses of it to see if there are lints that really do care about having exactly the same path segments).

Maybe an alternative would be to turn the hir types/consts into middle types/consts and compare them instead but I'm not sure there's really a good way to do that

changelog: none
2024-10-03 21:16:22 +00:00
Matthias Krüger
743623d4f7 Rollup merge of #131183 - compiler-errors:opaque-ty-origin, r=estebank
Refactoring to `OpaqueTyOrigin`

Pulled out of a larger PR that uses these changes to do cross-crate encoding of opaque origin, so we can use them for edition 2024 migrations. These changes should be self-explanatory on their own, tho 😄
2024-10-03 21:52:46 +02:00
y21
d6be597fbc Use SpanlessEq for in trait_bounds lints 2024-10-03 15:49:37 +00:00
Philipp Krones
277c4e4baf Merge commit 'aa0d551351a9c15d8a95fdb3e2946b505893dda8' into clippy-subtree-update 2024-10-03 16:32:51 +02:00
bors
aa0d551351 Auto merge of #13492 - flip1995:rustup, r=flip1995
Rustup

r? `@ghost`

changelog: none
2024-10-03 13:34:02 +00:00
Philipp Krones
c994a60fd4
Bump nightly version -> 2024-10-03 2024-10-03 14:48:03 +02:00
Philipp Krones
d300cdfcda
Merge remote-tracking branch 'upstream/master' into rustup 2024-10-03 14:47:50 +02:00
Guillaume Gomez
603934336d Greatly reduce generated HTML page size 2024-10-03 11:17:33 +02:00
Guillaume Gomez
80eb9cfa14 Run syntax highlighting only when needed 2024-10-03 11:12:19 +02:00
Guillaume Gomez
823c1246ab Move inlined CSS into style.css 2024-10-03 11:12:19 +02:00
Guillaume Gomez
8a3d4e1a70 Replace rinja custom syntax with default syntax
Since all angular code was removed, there is no conflict anymore before angular and jinja2 syntaxes so we can just use plain jinja2 syntax.
2024-10-03 11:12:19 +02:00
Guillaume Gomez
d52b9aa564 Move theme handling JS into its own file to make theme being applied before first rendering 2024-10-03 11:12:19 +02:00
Guillaume Gomez
47f40d468a Improve rendering speed by moving settings generation after theme rendering 2024-10-03 11:12:19 +02:00
Guillaume Gomez
e0b0851ba8 Support version filter URL parameters 2024-10-03 11:12:19 +02:00
Guillaume Gomez
4bb4cc6fcb Add support for URL arguments 2024-10-03 11:12:19 +02:00
Guillaume Gomez
00c11df107 Add support for version filtering 2024-10-03 11:12:19 +02:00
Guillaume Gomez
59ccebe426 Support all filters except versions 2024-10-03 11:12:19 +02:00
Guillaume Gomez
aeb548a4f7 Put back interactions with settings menus 2024-10-03 11:12:11 +02:00
coekjan
2080634d33
Fix lint manual_slice_size_calculation when the slice is ref more than once 2024-10-03 12:47:15 +08:00
Michael Goulet
cbd64a4868 Use named fields for OpaqueTyOrigin 2024-10-02 22:04:18 -04:00
Michael Goulet
ce22fd34d9 Remove redundant in_trait from hir::TyKind::OpaqueDef 2024-10-02 21:59:55 -04:00
bors
398be8c842 Auto merge of #13443 - SpriteOvO:simplify-option-neg-methods, r=xFrednet
Simplify negative `Option::{is_some_and,is_none_or}`

Closes #13436.

Improved based on the existing lint `nonminimal_bool`, since there is already handling of similar methods `Option::{is_some,is_none}` and `Result::{is_ok,is_err}`, and there is a lot of reusable code.

When `is_some_and` or `is_none_or` have a negation, we invert it into another method by removing the Not sign and inverting the expression in the closure.

For the case where the closure block has statements, currently no simplification is implemented. (Should we do it?)

```rust
// Currently will not simplify this
_ = !opt.is_some_and(|x| {
    let complex_block = 100;
    x == complex_block
});
```

changelog: [`nonminimal_bool`]: Simplify negative `Option::{is_some_and,is_none_or}`
2024-10-02 08:54:12 +00:00
bors
d578f6ab0c Auto merge of #13122 - rshearman:fix-9854, r=blyxyas
Fix `mut_mutex_lock` when reference not ultimately mutable

When there is are multiple references where one of the references isn't mutable then this results in a false-positive for `mut_mutex_lock` as it only checks the mutability of the first reference level.

Fix this by using `peel_mid_ty_refs_is_mutable` which correctly determines whether the reference is ultimately mutable and thus whether `Mutex::get_lock()` can actually be used.

Fixes #9854

changelog: [`mut_mutex_lock`]: No longer lints if the mutex is behind multiple references and one of those references isn't mutable
2024-10-01 21:02:31 +00:00
Rob Shearman
c88cb08afc Fix mut_mutex_lock when reference not ultimately mutable
When there is are multiple references where one of the references
isn't mutable then this results in a false-positive for
`mut_mutex_lock` as it only checks the mutability of the first
reference level.

Fix this by using `peel_mid_ty_refs_is_mutable` which correctly
determines whether the reference is ultimately mutable and thus
whether `Mutex::get_lock()` can actually be used.

Fixes #9854
2024-10-01 22:19:42 +02:00
Ralf Jung
4891dd4627 make InterpResult a dedicated type to avoid accidentally discarding the error 2024-10-01 21:45:35 +02:00
Michael Goulet
3ac3c34951 Remove crashes and fix tests 2024-10-01 13:55:46 -04:00
blyxyas
13e2633f19 Also sanitize configuration 2024-10-01 19:43:19 +02:00
bors
71c7d445db Auto merge of #13462 - y21:issue13459, r=dswij
`zombie_processes`: consider `wait()` calls in nested bodies

Fixes #13459

Small oversight. We weren't considering uses of the local in closures.

changelog: none
2024-10-01 17:39:32 +00:00