Commit Graph

301225 Commits

Author SHA1 Message Date
Trevor Gross
2fcea9fb68 Rollup merge of #143859 - orlp:thread-into-raw-align, r=jhpratt
Guarantee 8 bytes of alignment in Thread::into_raw

When using `AtomicPtr` for synchronization it's incredibly useful when you've got a couple bits you can stuff metadata in. By guaranteeing that `Thread`'s `Inner` struct is aligned to 8 bytes everyone can use the bottom 3 bits to signal other things, such as a critical section, etc.

This guarantee is thus very useful and costs us nothing.
2025-07-26 02:19:29 -05:00
Trevor Gross
75ed6de1ee Rollup merge of #143698 - benschulz:unused-parens-2, r=lcnr,compiler-errors
Fix unused_parens false positive

Resolves rust-lang/rust#143653.

The "no bounds exception" was indiscriminately set to `OneBound` for referents and pointees. However, if the reference or pointer type itself appears in no-bounds position, any constraints it has must be propagated.

```rust
// unused parens: not in no-bounds position
fn foo(_: Box<(dyn Send)>) {}

// unused parens: in no-bounds position, but one-bound exception applies
fn bar(_: Box<dyn Fn(&u32) -> &(dyn Send)>) {}

// *NOT* unused parens: in no-bounds position, but no exceptions to be made
fn baz(_: Box<dyn Fn(&u32) -> &(dyn Send) + Send>) {}
```
2025-07-26 02:19:28 -05:00
Trevor Gross
d8f4ceb8c0 Rollup merge of #143585 - folkertdev:loop-match-suggest-const-block, r=oli-obk
`loop_match`: suggest extracting to a `const` item

tracking issue: https://github.com/rust-lang/rust/issues/132306
fixes https://github.com/rust-lang/rust/issues/143310
fixes https://github.com/rust-lang/rust/issues/143936
2025-07-26 02:19:28 -05:00
Trevor Gross
3b99668f83 Rollup merge of #143272 - tgross35:bump-fortanix, r=jhpratt,jethrogb
Upgrade the `fortanix-sgx-abi` dependency

0.6.1 removes the `compiler-builtins` dependency, part of RUST-142265. The breaking change from 0.5 to 0.6 is for an update to the `insecure_time` API [1].

I validated that `./x c library --target x86_64-fortanix-unknown-sgx` completes successfully with this change.

Link: a34e9767f3 [1]
2025-07-26 02:19:27 -05:00
Trevor Gross
7abb4e2b4c Rollup merge of #141663 - lolbinarycat:rustdoc-collapse-impl-134429, r=GuillaumeGomez
rustdoc: add ways of collapsing all impl blocks

either shift+click the Summary button,
or use the `_` key.

this collapses everything,
including (inherent) impl blocks.

no need for a special "expand all impl blocks"
method, as impl blocks are expanded during regular "expand all".
doing "expand all" -> "collapse all" will always
result in only impl blocks being expaned.

not sure the best way to add a GUI test.

fixes https://github.com/rust-lang/rust/issues/134429
2025-07-26 02:19:26 -05:00
Trevor Gross
33ed3fc07f Rollup merge of #140871 - Amanieu:naked-asm-label, r=compiler-errors
Don't lint against named labels in `naked_asm!`

Naked functions are allowed to define global labels, just like `global_asm!`.
2025-07-26 02:19:26 -05:00
bors
f32b23204a Auto merge of #139597 - Kobzol:lint-skip, r=BoxyUwU
Do not run per-module late lints if they can be all skipped

We run ~70 late lints for all dependencies even if they use `--cap-lints=allow`, which seems wasteful. It looks like these lints are super fast (unlike early lints), but still.

r? `@ghost`
2025-07-26 02:31:12 +00:00
Amanieu d'Antras
1f4561b63d Don't lint against named labels in naked_asm!
Naked functions are allowed to define global labels, just like
`global_asm!`.
2025-07-26 00:42:21 +01:00
bors
0dd07bd216 Auto merge of #144338 - weihanglo:update-cargo, r=weihanglo
Update cargo

8 commits in 6833aa715d724437dc1247d0166afe314ab6854e..9b296973b425ffb159e12cf3cd56580fd5c85382
2025-07-13 02:25:52 +0000 to 2025-07-25 17:10:08 +0000
- Allow using Cargo-as-a-library with gix's reqwest backend (rust-lang/cargo#15653)
- Make timings graphs scalable to user's window (rust-lang/cargo#15766)
- refactor: rename arg `mode` to `intent` (rust-lang/cargo#15774)
- fix: `no-proc-macro` is overridden by subsequent edges (rust-lang/cargo#15764)
- Use `gix` for `cargo package` (rust-lang/cargo#15534)
- cargo-credential-libsecret: give FFI correctly-sized object (rust-lang/cargo#15767)
- Remove unnecessary target-c-int-width from target specs (rust-lang/cargo#15759)
- Expose artifact dependency getters in cargo-as-a-library (rust-lang/cargo#15753)
2025-07-25 23:29:17 +00:00
Folkert de Vries
730d33dd64 loop_match: suggest extracting to a const item
if the expression cannot be evaluated in a straightforward way
2025-07-26 00:10:56 +02:00
Weihang Lo
a1e292a63a Update cargo
ring is brought into Cargo transitively because Cargo now
provides optional (unstable) reqwest HTTP backend.
2025-07-25 17:19:39 -04:00
bors
430d6eddfc Auto merge of #144449 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? `@Manishearth`
2025-07-25 19:19:45 +00:00
Philipp Krones
9660038cea Allow approx-constant in x clippy library 2025-07-25 17:02:52 +02:00
Philipp Krones
a0b18b3318 Merge commit '1db89a1b1ca87f24bf22d0bad21d14b2d81b3e99' into clippy-subtree-update 2025-07-25 15:54:22 +02:00
Philipp Krones
1db89a1b1c Rustup (#15341)
r? @ghost

changelog: none
2025-07-25 13:14:01 +00:00
Philipp Krones
d0fa808df5 Fix if_same_then_else with if let conditions
Apparently they are no longer split 1 LHS + rest RHS
2025-07-25 15:08:50 +02:00
Philipp Krones
31baffd6ee Bump nightly version -> 2025-07-25 2025-07-25 15:08:44 +02:00
Philipp Krones
d64eb62e2c Update .gitignore
Add !clippy_test_deps/Cargo.lock and clippy_lints_internal/target
2025-07-25 15:08:39 +02:00
Philipp Krones
c98e60a56e Merge remote-tracking branch 'upstream/master' into rustup 2025-07-25 15:04:01 +02:00
bors
a955f1cd09 Auto merge of #144440 - matthiaskrgr:rollup-peb88gb, r=matthiaskrgr
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#142569 (Suggest clone in user-write-code instead of inside macro)
 - rust-lang/rust#143401 (tests: Don't check for self-printed output in std-backtrace.rs test)
 - rust-lang/rust#143424 (clippy fix: rely on autoderef)
 - rust-lang/rust#143970 (Update core::mem::copy documentation)
 - rust-lang/rust#143979 (Test fixes for Arm64EC Windows)
 - rust-lang/rust#144200 (Tweak output for non-`Clone` values moved into closures)
 - rust-lang/rust#144209 (Don't emit two `assume`s in transmutes when one is a subset of the other)
 - rust-lang/rust#144314 (Hint that choose_pivot returns index in bounds)
 - rust-lang/rust#144340 (UI test suite clarity changes: Rename `tests/ui/SUMMARY.md` and update rustc dev guide on `error-pattern`)
 - rust-lang/rust#144368 (resolve: Remove `Scope::CrateRoot`)
 - rust-lang/rust#144390 (Remove dead code and extend test coverage and diagnostics around it)
 - rust-lang/rust#144392 (rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-25 10:40:01 +00:00
Matthias Krüger
1caf701653 Rollup merge of #144392 - makai410:rm-mov, r=scottmcm
rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine`

Part of rust-lang/rust#119174 .
I think we should be good now to sync this change in rustc_public.
2025-07-25 11:16:39 +02:00
Matthias Krüger
acd4a1ccd2 Rollup merge of #144390 - oli-obk:arbitrary-enum-discrs, r=SparrowLii
Remove dead code and extend test coverage and diagnostics around it

I was staring a bit at the `dont_niche_optimize_enum` variable and figured out that part of it is dead code (at least today it is). I changed the diagnostic and test around the code that makes that part dead code, so everything that makes removing that code sound is visible in this PR
2025-07-25 11:16:39 +02:00
Matthias Krüger
9c257e59c2 Rollup merge of #144368 - petrochenkov:rmrootscope, r=b-naber
resolve: Remove `Scope::CrateRoot`

Use `Scope::Module` with the crate root module inside instead, which should be identical.
This is a simplification by itself, but it will be even larger simplification if something like https://github.com/rust-lang/rust/pull/144131 is implemented, because `Scope::CrateRoot` is also a module with two actual scopes in it (for globs and non-globs).

I also did some renamings for consistency:
- `ScopeSet::AbsolutePath` -> `ScopeSet::ModuleAndExternPrelude`
- `ModuleOrUniformRoot::CrateRootAndExternPrelude` -> `ModuleOrUniformRoot::ModuleAndExternPrelude`
- `is_absolute_path` -> `module_and_extern_prelude`
2025-07-25 11:16:38 +02:00
Matthias Krüger
405b2e6c06 Rollup merge of #144340 - Oneirical:uncertain-illusion, r=jieyouxu
UI test suite clarity changes: Rename `tests/ui/SUMMARY.md` and update rustc dev guide on `error-pattern`

To match convention, rename `tests/ui/SUMMARY.md` to `tests/ui/README.md`.

Also, remove misleading lines in the rustc development guide about `error-pattern` being "not recommended", when it really is just a last resort which *should* be used in the niche situations where it is useful.

r? ````@jieyouxu````
2025-07-25 11:16:38 +02:00
Matthias Krüger
a2681f943c Rollup merge of #144314 - kornelski:pivot-safely, r=jhpratt
Hint that choose_pivot returns index in bounds

Instead of using `unsafe` in multiple places, one `hint::assert_unchecked` allows use of safe code instead.

Part of #rust-lang/rust#144326
2025-07-25 11:16:37 +02:00
Matthias Krüger
f414e7ac54 Rollup merge of #144209 - scottmcm:assume_less, r=lcnr,dianqk
Don't emit two `assume`s in transmutes when one is a subset of the other

For example, transmuting between `bool` and `Ordering` doesn't need two `assume`s because one range is a superset of the other.

Multiple are still used for things like `char` <-> `NonZero<u32>`, which overlap but where neither fully contains the other.
2025-07-25 11:16:36 +02:00
Matthias Krüger
33a9e4f821 Rollup merge of #144200 - estebank:dont-point-at-closure, r=lcnr
Tweak output for non-`Clone` values moved into closures

When we encounter a non-`Clone` value being moved into a closure, try to find the corresponding type of the binding being moved, if it is a `let`-binding or a function parameter. If any of those cases, we point at them with the note explaining that the type is not `Copy`, instead of giving that label to the place where it is captured. When it is a `let`-binding with no explicit type, we point at the initializer (if it fits in a single line).

```
error[E0507]: cannot move out of `foo`, a captured variable in an `Fn` closure
  --> f111.rs:14:25
   |
13 | fn do_stuff(foo: Option<Foo>) {
   |             ---  ----------- move occurs because `foo` has type `Option<Foo>`, which does not implement the `Copy` trait
   |             |
   |             captured outer variable
14 |     require_fn_trait(|| async {
   |                      -- ^^^^^ `foo` is moved here
   |                      |
   |                      captured by this `Fn` closure
15 |         if foo.map_or(false, |f| f.foo()) {
   |            --- variable moved due to use in coroutine
```

instead of

```
error[E0507]: cannot move out of `foo`, a captured variable in an `Fn` closure
  --> f111.rs:14:25
   |
13 | fn do_stuff(foo: Option<Foo>) {
   |             --- captured outer variable
14 |     require_fn_trait(|| async {
   |                      -- ^^^^^ `foo` is moved here
   |                      |
   |                      captured by this `Fn` closure
15 |         if foo.map_or(false, |f| f.foo()) {
   |            ---
   |            |
   |            variable moved due to use in coroutine
   |            move occurs because `foo` has type `Option<Foo>`, which does not implement the `Copy` trait
```
2025-07-25 11:16:36 +02:00
Matthias Krüger
dfbd0c4e5a Rollup merge of #143979 - dpaoliello:arm64ectest, r=petrochenkov
Test fixes for Arm64EC Windows

* `tests/ui/cfg/conditional-compile-arch.rs` needs an Arm64EC case.
* `tests/ui/runtime/backtrace-debuginfo.rs` should skip Arm64EC as it suffers from the same truncated backtraces as Arm64 Windows.
* `tests/ui/linkage-attr/incompatible-flavor.rs` is a general issue: it assumes that the Rust compiler is always built with the x86 target enabled in the backend, but I only enabled AArch64 when building locally to speed up the LLVM compilation.
2025-07-25 11:16:35 +02:00
Matthias Krüger
e3b07352a6 Rollup merge of #143970 - SunkenPotato:update_mem_copy_docs, r=scottmcm
Update core::mem::copy documentation

Update the documentation of `core::mem::copy` to include a `const` on the definition of the function.
2025-07-25 11:16:34 +02:00
Matthias Krüger
dd159ee24e Rollup merge of #143424 - hkBst:auto-deref, r=jhpratt
clippy fix: rely on autoderef

Changes instances of `&**self` to `self`.
2025-07-25 11:16:34 +02:00
Matthias Krüger
e9744c9ec1 Rollup merge of #143401 - Enselic:no-stack-backtrace-print-in-display, r=davidtwco
tests: Don't check for self-printed output in std-backtrace.rs test

The `Display` implementation for `Backtrace` used to print

    stack backtrace:

but that print was since removed. See https://github.com/rust-lang/backtrace-rs/pull/286 and https://github.com/rust-lang/rust/pull/69042. To make the existing test pass, the print was added to the test instead. But it doesn't make sense to check for something that the test itself does since that will not detect any regressions in the implementation of `Backtrace`.

What the test _should_ check is that "stack backtrace:" is _not_ printed in `Display` of `Backtrace`. So do that instead.

This is one small steps towards resolving https://github.com/rust-lang/rust/issues/71706. The next steps after this step involves extending and hardening that test further.
2025-07-25 11:16:33 +02:00
Matthias Krüger
2e54f7f0a1 Rollup merge of #142569 - xizheyin:139253, r=davidtwco
Suggest clone in user-write-code instead of inside macro

Fixes rust-lang/rust#139253

Inspired by rust-lang/rust#142543

r? ````@fmease````
2025-07-25 11:16:32 +02:00
dswij
e85b1dd6da Remove "Known problems" section for clippy::redundant_closure (#15331)
Remove "Known problems" section for `clippy::redundant_closure` since it
was fixed by [this
PR](https://github.com/rust-lang/rust-clippy/pull/4008)
We can see this by running examples from [the
issue](https://github.com/rust-lang/rust-clippy/issues/1439), for ex.
[this
one](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=6562527b4c3f6dcebb3c43718341af98)

changelog: none
2025-07-25 08:10:05 +00:00
Alejandra González
98205e60cc Fix if_then_some_else_none FP when require type coercion (#15267)
Closes rust-lang/rust-clippy#15257

changelog: [`if_then_some_else_none`] fix FP when require type coercion
2025-07-24 23:50:14 +00:00
Oneirical
94c0cf891e Rename tests/ui/SUMMARY.md and update rustc dev guide on error-pattern 2025-07-24 17:09:42 -04:00
bors
b56aaec52b Auto merge of #144389 - scottmcm:no-more-mir-cast-assume, r=davidtwco
MIR-build: No longer emit assumes in enum-as casting

This just uses the `valid_range` from the backend, so it's duplicating the range metadata that now we include on parameters and loads, and thus no longer seems to be useful -- notably there's no codegen test failures from removing it.

(Because it's using data from the same source as the backend annotations, it doesn't do anything to mitigate things like rust-lang/rust#144388 where the range in the layout is more permissive than the actual possible discriminants.  A variant of this that actually checked the discriminants more specifically might be useful, so could potentially be added in future, but I don't think the *current* checks are actually providing value.)

r? mir

Randomly turns out that this
Fixes https://github.com/rust-lang/rust/issues/121097
2025-07-24 20:38:53 +00:00
Ben Schulz
307f66436b Replace unwrap_or with explicit match 2025-07-24 20:44:10 +02:00
Ben Schulz
6fc68c16e7 Add test case for single bound 2025-07-24 20:44:10 +02:00
Ben Schulz
e958b20af7 Fix unused_parens false positive 2025-07-24 20:44:09 +02:00
Scott McMurray
01524abb05 MIR-build: No longer emit assumes in enum-as casting
This just uses the `valid_range` from the backend, so it's duplicating the range metadata that now we include on parameters and loads.
2025-07-24 10:18:37 -07:00
bors
246733a3d9 Auto merge of #144398 - fmease:rollup-z6vq7mi, r=fmease
Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#143374 (Unquerify extern_mod_stmt_cnum.)
 - rust-lang/rust#143838 (std: net: uefi: Add support to query connection data)
 - rust-lang/rust#144014 (don't link to the nightly version of the Edition Guide in stable lints)
 - rust-lang/rust#144094 (Ensure we codegen the main fn)
 - rust-lang/rust#144218 (Use serde for target spec json deserialize)
 - rust-lang/rust#144221 (generate elf symbol version in raw-dylib)
 - rust-lang/rust#144240 (Add more test case to check if the false note related to sealed trait suppressed)
 - rust-lang/rust#144247 (coretests/num: use ldexp instead of hard-coding a power of 2)
 - rust-lang/rust#144276 (Use less HIR in check_private_in_public.)
 - rust-lang/rust#144278 (add Rev::into_inner)
 - rust-lang/rust#144317 (pass build.npm from bootstrap to tidy and use it for npm install)
 - rust-lang/rust#144320 (rustdoc: avoid allocating a temp String for aliases in search index)
 - rust-lang/rust#144334 (rustc_resolve: get rid of unused rustdoc::span_of_fragments_with_expansion)
 - rust-lang/rust#144335 (Don't suggest assoc ty bound on non-angle-bracketed problematic assoc ty binding)
 - rust-lang/rust#144358 (Stop using the old `validate_attr` logic for stability attributes)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-24 17:15:38 +00:00
León Orell Valerian Liehr
6dc41520e9 Rollup merge of #144358 - JonathanBrouwer:fix-stability-malformed, r=oli-obk
Stop using the old `validate_attr` logic for stability attributes

I think this was accidentally missed when implementing the stability attributes?

r? `````@oli-obk`````
cc `````@jdonszelmann`````
2025-07-24 15:08:28 +02:00
León Orell Valerian Liehr
237098c92d Rollup merge of #144335 - fmease:no-angle-no-colon, r=SparrowLii
Don't suggest assoc ty bound on non-angle-bracketed problematic assoc ty binding

Fixes https://github.com/rust-lang/rust/issues/140543.
2025-07-24 15:08:28 +02:00
León Orell Valerian Liehr
456acaa4eb Rollup merge of #144334 - lolbinarycat:rustdoc-span_of_fragments-revert, r=GuillaumeGomez
rustc_resolve: get rid of unused rustdoc::span_of_fragments_with_expansion

This function can cause false negatives if used incorrectly (usually "do any of the doc fragments come from a macro" is the wrong question to ask), and thus it is unused.

r? `````@GuillaumeGomez`````
2025-07-24 15:08:27 +02:00
León Orell Valerian Liehr
7413ecee4b Rollup merge of #144320 - lolbinarycat:rustdoc-search_index-BTreeMap-str, r=GuillaumeGomez
rustdoc: avoid allocating a temp String for aliases in search index

Here's the optimization I talked about in https://github.com/rust-lang/rust/pull/143988#discussion_r2208524163

I got around the Serialize issue using the newtype pattern.  The wrapper type could be factored out into a helper that would work with anything that impls `AsRef<&str>`, but I'm not sure if that would be helpful anywhere else.

r? ``````@GuillaumeGomez``````
2025-07-24 15:08:26 +02:00
León Orell Valerian Liehr
352e02bce1 Rollup merge of #144317 - lolbinarycat:tidy-obey-build.npm, r=Kobzol
pass build.npm from bootstrap to tidy and use it for npm install

followup to rust-lang/rust#142924

r? ```@Kobzol```
2025-07-24 15:08:26 +02:00
León Orell Valerian Liehr
488fc49e05 Rollup merge of #144278 - Qelxiros:rev-into-inner, r=tgross35
add Rev::into_inner

Tracking issue: rust-lang/rust#144277
2025-07-24 15:08:25 +02:00
León Orell Valerian Liehr
ac4ffdce9a Rollup merge of #144276 - cjgillot:no-hir-privacy, r=petrochenkov
Use less HIR in check_private_in_public.

r? ````````@petrochenkov````````
2025-07-24 15:08:25 +02:00
León Orell Valerian Liehr
0897a9f069 Rollup merge of #144247 - RalfJung:ldexp, r=tgross35
coretests/num: use ldexp instead of hard-coding a power of 2

r? `````@tgross35`````
2025-07-24 15:08:24 +02:00
León Orell Valerian Liehr
3d82cccab4 Rollup merge of #144240 - yuk1ty:false-sealed-traits-note-reported-in-another-issue, r=fee1-dead
Add more test case to check if the false note related to sealed trait suppressed

Closes rust-lang/rust#143121

I started to fix the issue but I found that this one has already been addressed in this PR (https://github.com/rust-lang/rust/pull/143431). I added an additional test to prove the reported thing has been resolved just in case.

I think we can discard this pull request if there's no need to add such kind of tests👍🏻
2025-07-24 15:08:23 +02:00