Commit Graph

340064 Commits

Author SHA1 Message Date
Jonathan Brouwer
e7feb41dcd Rollup merge of #162766 - maxdexh:unleak-considered-harmful, r=hanna-kruppe,saethlin
stop unleaking `&mut`s in std and the compiler

As discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/channel/136281-t-opsem/topic/What.20is.20the.20current.20state.20of.20unleaking.20a.20.60Box.3CT.2C.20Global.3E.60.3F/with/623860839), this PR removes all the dubious uses (I could find) of `Box::leak` from rustc and std

r? libs
2026-09-14 19:23:28 +02:00
Jonathan Brouwer
4d21806694 Rollup merge of #162763 - maxdexh:remove-into-unique, r=RalfJung
Remove `Box::into_unique`

As discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/channel/136281-t-opsem/topic/What.20is.20the.20current.20state.20of.20unleaking.20a.20.60Box.3CT.2C.20Global.3E.60.3F/with/623860839), this PR removes the `Box::into_unique` method and also adds a test for `into_raw_with_allocator`.

Note that all uses of `into_unique` were already removed from std in rust-lang/rust#162732. The only remaining use was a Miri test.

I didn't copy over the "lose the tag" operation for the `into_raw_with_allocator` test, because the file you wanted me to put this in doesn't have `-Zmiri-permissive-provenance` ^^

r? RalfJung
2026-09-14 19:23:27 +02:00
Jonathan Brouwer
727e08088f Rollup merge of #162409 - RalfJung:intrinsic-const-stab, r=oli-obk
Fix gap in const stability checks around intrinsics

@N1ark managed to find a gap in our const stability checks around intrinsics. This PR fixes that gap.

Sadly the standard library already relies on the gap, so for now I added a `rustc_allow_const_fn_unstable` but that attribute usually needs some process to be approved.

Also fixes https://github.com/rust-lang/rust/issues/150961 by properly supporting & testing `rustc_do_not_const_check` on intrinsics.
2026-09-14 19:23:26 +02:00
Max Dexheimer
fe15c63bed stop unleaking &muts in std and the compiler 2026-09-14 15:44:58 +02:00
bors
a8a1e6fd9d Auto merge of #162767 - JonathanBrouwer:rollup-fqbZkYF, r=JonathanBrouwer
Rollup of 16 pull requests

Successful merges:

 - rust-lang/rust#162762 (Subtree sync for rustc_codegen_cranelift)
 - rust-lang/rust#162752 (`rust-analyzer` subtree update)
 - rust-lang/rust#161903 (Fix initialization cycle in `target_config`)
 - rust-lang/rust#162240 (Garbage-collect old incremental compilation sessions)
 - rust-lang/rust#162610 (fix tailcall indirect return)
 - rust-lang/rust#162634 (Implement semantic analysis for named `Fn` trait params)
 - rust-lang/rust#161675 (document that t-lang does not need involvement for unobservable intrisics)
 - rust-lang/rust#162160 (turn aligned-in-packed error into lint)
 - rust-lang/rust#162504 (Stabilize `unsafe_cell_access`)
 - rust-lang/rust#162516 (tidy: Sort multi-line types by treating `>` as a closing bracket)
 - rust-lang/rust#162630 (Simplify the `G` in `Diag<'a, G>`)
 - rust-lang/rust#162647 (Add regression test for previous overflow evaluating the requirement)
 - rust-lang/rust#162703 (regression test for valtree leaf const)
 - rust-lang/rust#162723 (Add regression test for unexpected type for constructor)
 - rust-lang/rust#162735 (Remove pointless `A: Allocator` bounds in boxed.rs)
 - rust-lang/rust#162736 (clean up trivial region constraint filtering)
2026-09-14 13:16:50 +00:00
Jonathan Brouwer
6a36f6b296 Rollup merge of #162736 - sjwang05:162032-followup, r=lcnr
clean up trivial region constraint filtering

cc https://github.com/rust-lang/rust/pull/162032#discussion_r3988093372

r? lcnr
2026-09-14 15:16:07 +02:00
Jonathan Brouwer
1a343b461e Rollup merge of #162735 - maxdexh:boundless-fun, r=jhpratt
Remove pointless `A: Allocator` bounds in boxed.rs

bottom text
2026-09-14 15:16:06 +02:00
Jonathan Brouwer
1d547c0115 Rollup merge of #162723 - lsunsi:issue162393, r=chenyukang
Add regression test for unexpected type for constructor

Closes rust-lang/rust#162393.
This fails on eca445e5. I think it was fixed yesterday, acording to @malezjaa
2026-09-14 15:16:05 +02:00
Jonathan Brouwer
a9828d9f15 Rollup merge of #162703 - malezjaa:regression-test-valtree-leaf-const, r=jieyouxu
regression test for valtree leaf const

Closes rust-lang/rust#162392. It no longer reproduces since nightly-2026-09-12.
Not sure if this is the right folder for this test.
2026-09-14 15:16:04 +02:00
Jonathan Brouwer
f81e978dea Rollup merge of #162647 - lsunsi:issue219, r=mu001999
Add regression test for previous overflow evaluating the requirement

Closes https://github.com/rust-lang/trait-system-refactor-initiative/issues/219

Same deal, the test fails on 5e91de65d7 just like in rust-lang/rust#162642.

Again, placing the test is challenging but I did my best on folder and naming.
2026-09-14 15:16:03 +02:00
Jonathan Brouwer
305d36bc80 Rollup merge of #162630 - nnethercote:simplify-Diag-G, r=oli-obk
Simplify the `G` in `Diag<'a, G>`

The `EmissionGuarantee` trait isn't necessary, and just complicates things. Details in individual commits.

r? @oli-obk
2026-09-14 15:16:02 +02:00
Jonathan Brouwer
8593edd412 Rollup merge of #162516 - Zalathar:tidy-alphabetical, r=Mark-Simulacrum
tidy: Sort multi-line types by treating `>` as a closing bracket

While tidying up some macros in the compiler, I noticed that `tidy-alphabetical-start` doesn't treat `>` as a closing bracket, so it gets confused when sorting lists where complex parameterized types have been broken across multiple lines.

This PR therefore changes tidy to treat `>` as a closing bracket, and adds some tests to verify the intended behaviour.

While we do have some places that sort lists of types, none of them happen to use multi-line types right now.
2026-09-14 15:16:02 +02:00
Jonathan Brouwer
f3727c46ed Rollup merge of #162504 - Fayti1703:stabilize/unsafe_cell_access, r=Mark-Simulacrum
Stabilize `unsafe_cell_access`

Closes rust-lang/rust#136327
2026-09-14 15:16:00 +02:00
Jonathan Brouwer
300ef7ae5b Rollup merge of #162160 - RalfJung:aligned-in-packed, r=mu001999
turn aligned-in-packed error into lint

Fixes https://github.com/rust-lang/rust/issues/80926:
The aligned-in-packed check ignores the fact that generics exist, so it can trivially be bypassed. Acknowledge that by downgrading the hard error to a lint. The lint also only fires for `repr(C)` types, because that's the only case where that is a problem: the type may not actually match what the C compiler for the target does, if that C compiler is MSVC. This is tied up with https://github.com/rust-lang/rfcs/pull/3845 and the general tension around `repr(C)` as a repr for predictable stable layout vs C compatibility. The error doesn't really help to make fixing the mess any easier though, so let's de-fang it.

Also fixes https://github.com/rust-lang/rfcs/issues/3060; see that issue for a usecase that's made unnecessarily hard by the status quo.

[Three years ago](https://github.com/rust-lang/rust/issues/80926#issuecomment-1716238277), the t-lang vibes seem to have been "yes let's downgrade this to a lint, that's kind of what it already is anyway".

Questions for t-lang:
- Are you still on-board with this?
- How should the lint be called? I went with `aligned_fields_in_packed`.
- When exactly should it fire? I currently require the outer packed type, the inner aligned type, and all the types in between to be `repr(C)`. For Rust types I see no reason at all to forbid this combination, we can just define whatever we want for the layout there and IMO the current behavior makes a lot of sense.
- What should the default lint level be? I went with "deny" since it was a hard error after all.

Cc @rust-lang/opsem
2026-09-14 15:16:00 +02:00
Jonathan Brouwer
41a52228db Rollup merge of #161675 - RalfJung:intrinsic-approval, r=traviscross,Urgau
document that t-lang does not need involvement for unobservable intrisics

This turns the [FCP](https://github.com/rust-lang/rust/pull/161081#issuecomment-5344298013) (completed [here](https://github.com/rust-lang/rust/pull/161081#issuecomment-5463256330)) about intrinsics that could already be written on stable into documentation.

Also use this opportunity to document `miri::intrinsic_fallback_is_spec`.

r? @tgross35
Cc @rust-lang/lang
2026-09-14 15:15:59 +02:00
Jonathan Brouwer
fa6e214d31 Rollup merge of #162634 - JonathanBrouwer:named-fn-trait-params-semantics, r=folkertdev
Implement semantic analysis for named `Fn` trait params

This PR can be reviewed commit by commit.
Every commit passes uitests individually.

The goal of this PR is to make the semantic of named fn trait parameters match those of `fn` pointers, which is what was decided on the RFC: https://github.com/rust-lang/rfcs/pull/3955.
This is achieved, which can be observed by the fact that the output of the `named-fn-trait-params.rs` test matches that of `fn-ptr-pattern.rs`.

This PR also marks the feature as complete.

Tracking issue: https://github.com/rust-lang/rust/issues/158499
2026-09-14 15:15:58 +02:00
Jonathan Brouwer
5c301f6b33 Rollup merge of #162610 - malezjaa:fix-tailcall-indirect-return, r=folkertdev
fix tailcall indirect return

Fixes rust-lang/rust#162585

This branch should only be intended for arguments, but it also marked return values as being passed on the stack. It later caused codegen to panic because return values can't use `on_stack`.
2026-09-14 15:15:57 +02:00
Jonathan Brouwer
f65463527e Rollup merge of #162240 - charliermarsh:charlie/incremental-session-gc, r=bjorn3
Garbage-collect old incremental compilation sessions

## Summary

rustc cleans up old incremental-cache snapshots twice during a compilation: once at startup (after loading the previous cache), and then again after finishing and finalizing the new cache.

In rust-lang/rust#147821, we started skipping the current session during cleanup. But that means we're also skipping cleanup _after_ the session has finished, so we're keeping _both_ the previous and the completed snapshot on disk. (The snapshots don't accumulate indefinitely -- the "extra" snapshot gets removed when the next compilation starts, but that compilation then leaves another snapshot behind when it finishes.)

This PR modifies the logic to skip the current session while it is still active, but remove it once finalized.

Testing it locally for [Ruff](https://github.com/astral-sh/ruff) and [uv](https://github.com/astral-sh/uv), the target directory shrinks significantly... The query caches are almost exactly 50% smaller, and `target` as a whole is 27.3% smaller in Ruff and 31.1% smaller in uv.
2026-09-14 15:15:56 +02:00
Jonathan Brouwer
09c7c12af1 Rollup merge of #161903 - nnethercote:fix-target_config-cycle, r=nikic
Fix initialization cycle in `target_config`

There is an initialization cycle in `target_config`. Details in the final commit. The previous commits are precursors that support the changes in the final commit.

r? @nikic
cc @cuviper @RalfJung @Zalathar @Patryk27
2026-09-14 15:15:56 +02:00
Jonathan Brouwer
32c397b134 Rollup merge of #162752 - lnicola:sync-from-ra, r=lnicola
`rust-analyzer` subtree update

Subtree update of `rust-analyzer` to 682a84e95b.

Created using https://github.com/rust-lang/josh-sync.

r? @ghost
2026-09-14 15:15:55 +02:00
Jonathan Brouwer
597ba9d0b2 Rollup merge of #162762 - bjorn3:sync_cg_clif-2026-09-14, r=bjorn3
Subtree sync for rustc_codegen_cranelift

Subtree update of `rustc_codegen_cranelift` to f6bcac9858.

This migrates from git-subtree to josh-sync.

Created using https://github.com/rust-lang/josh-sync.

r? @ghost

@rustbot label +A-codegen +A-cranelift +T-compiler +subtree-sync
2026-09-14 15:15:54 +02:00
Max Dexheimer
1a218186be Remove Box::into_unique, add a test for into_raw_with_allocator 2026-09-14 15:08:52 +02:00
bjorn3
41ec851012 Merge pull request #1700 from Kobzol/clif-sync
Initial Josh pull
2026-09-14 14:20:28 +02:00
Ralf Jung
ae76f42913 less pub 2026-09-14 11:54:08 +02:00
Jonathan Brouwer
99bb4bb257 Improve docs for GenericArgs::Parenthesized 2026-09-14 10:29:28 +02:00
Jonathan Brouwer
d5e94f259e Remove parse_param_general 2026-09-14 10:27:06 +02:00
Ralf Jung
4e99638c7f turn aligned-in-packed error into lint 2026-09-14 10:10:16 +02:00
bors
ed77b7b869 Auto merge of #162315 - nnethercote:clean-up-AST-visitor-some-more, r=fee1-dead
Clean up AST visitor some more



A sequel to rust-lang/rust#162226. Details in individual commits.

r? @fee1-dead
2026-09-14 07:27:12 +00:00
bors
b722b5567e Auto merge of #162742 - jhpratt:rollup-EpKtQu5, r=jhpratt
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#162706 (Prefer exact derive imports over trait fallbacks)
 - rust-lang/rust#162732 (Fix unsound dealloc of reborrows from custom allocators)
 - rust-lang/rust#154113 (std::net: clamp multicast ttl value to u8 max.)
 - rust-lang/rust#161178 (lint ineffective #[unstable] annotations on re-exports)
 - rust-lang/rust#162717 (prevent ICE from `derive` on `repr(packed)` enum)
 - rust-lang/rust#162734 (Constify more Iterator and DoubleEndedIterator functions required for Range)
2026-09-14 04:16:18 +00:00
Jacob Pratt
803c237415 Rollup merge of #162734 - Randl:const-for-prereq, r=clarfonthey
Constify more Iterator and DoubleEndedIterator functions required for Range

Extracted from https://github.com/rust-lang/rust/pull/156216
Consitfies functions required for `const impl Iterator for Range`.
r? clarfonthey
2026-09-13 21:03:52 -04:00
Jacob Pratt
ace2f200c6 Rollup merge of #162717 - cyrgani:one-ice-less-derived, r=folkertdev
prevent ICE from `derive` on `repr(packed)` enum

Fixes https://github.com/rust-lang/rust/issues/133025 by not generating the broken impl anymore.
2026-09-13 21:03:51 -04:00
Jacob Pratt
a69f8f9a09 Rollup merge of #161178 - amirHdev:unstable-reexport, r=mejrs
lint ineffective #[unstable] annotations on re-exports

Refs rust-lang/rust#161153

https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/stability.20attributes.20on.20imports.20.26.20cargo-semver-checks/with/616818373
2026-09-13 21:03:50 -04:00
Jacob Pratt
f19b1b0832 Rollup merge of #154113 - devnexen:socket_mod_ttl_fix, r=Mark-Simulacrum
std::net: clamp multicast ttl value to u8 max.

on some platforms the underlying type is c_uchar,
values above 255 would silently truncate.
2026-09-13 21:03:50 -04:00
Jacob Pratt
4edca2f2cb Rollup merge of #162732 - maxdexh:water-leak, r=Darksonn
Fix unsound dealloc of reborrows from custom allocators

- Fixes rust-lang/rust#162719
- Fixes rust-lang/rust#162720
2026-09-13 21:03:49 -04:00
Jacob Pratt
dccd07304f Rollup merge of #162706 - chenyukang:yukang-fix-162260-hide-traits-for-derive, r=estebank
Prefer exact derive imports over trait fallbacks

Fixes rust-lang/rust#162260

r? @estebank
2026-09-13 21:03:48 -04:00
Nicholas Nethercote
44aee39707 Rename ty macro parameters
As requested by the reviewer.
2026-09-14 08:00:40 +10:00
Nicholas Nethercote
712e3221f5 Inline visit/visit_mut in impl_visitable 2026-09-14 08:00:40 +10:00
Nicholas Nethercote
cd21f63eff Use tidy-alphabetical markers on various lists
A lot of these lists are already almost in alphabetical order.
2026-09-14 08:00:40 +10:00
Nicholas Nethercote
ad22c2b1cc Don't pass in $Visitor/$lt to various macros
We can just hardwire `'a` and `Visitor`/`MutVisitor`. This simplifies
the inputs for these macros from "leading thing + repeating elements" to
just "repeating elements".
2026-09-14 08:00:40 +10:00
Nicholas Nethercote
75fd8533e0 Avoid #[macro_export]
These macros aren't needed outside the crate.
2026-09-14 08:00:40 +10:00
Nicholas Nethercote
d3b4e4cf89 Remove need for allow(unused_parens)
The AST visitor code uses `($($extra_ty)?)` which expands to `()` in
some cases and `(T)` in others, which requires `allow(unused_parens)` to
avoid warnings.

This commit splits the two `impl_visitable!` macros into two rules: one
for the "no-extra" case and one for the "with-extra" case. There's a
small amount of duplication between the two rules but there are multiple
advantages.

- The `allow(unused_parens)` is removed.

- `impl_visitable!` callers can omit the extra param if it's `()`.

- When the extra argument might or might not be present, a more standard
  `$(, $extra: $extra_ty)?` is now used.

- No weird `let ($($extra)?) = extra;` destructuring.

The `Visitable` derive also gets a tweak to avoid unnecessary parens
around extra args.
2026-09-14 08:00:40 +10:00
Nicholas Nethercote
72410d17b2 Use impl_visitable! for the generate_*_fns macros
They fit the pattern.

Also remove `#[inline]` from `impl_visitable_list` for consistency. The
visitor is generic so the methods are monomorphized into the calling
crate and probably inlined anyway.
2026-09-14 08:00:40 +10:00
Nicholas Nethercote
42b5930e69 Improve naming consistency
Use `$ty` and `$extra` and `$extra_ty` consistently in macros, rather
than `$Ty` and `$ExtraTy` and `$ParamTy`.

Also fix some spacing.
2026-09-14 08:00:40 +10:00
Nicholas Nethercote
e4f0df4747 Hoist impls out of fns
Currently various `Visitable` impls are defined within functions even
though `Visitable` is defined at the top level, which is weird and
requires `allow(non_local_definitions)`.

This commit uses `for_each_ast_visit_hook` to move them out. It also
renames a couple of the existing macros to give them simpler names.
2026-09-14 08:00:40 +10:00
Nicholas Nethercote
230a513c20 Introduce for_each_ast_visit_hook
There is currently a big list of `visit_*` methods in one macro call and
another list of `walk_*` method in another macro call. The previous
commit showed these can unintentionally get out of sync.

This commit introduces a higher-order macro that puts all the
information in a single place. This will make it impossible for the
`visit_*` and `walk_*` methods to get out of sync (as we saw in the
previous commit). It will also facilitate another cleanup in
the next commit.
2026-09-14 08:00:40 +10:00
Nicholas Nethercote
53ed560f19 Add missing walk_test_binder_constraints method
`visit_test_binder_constraints` is the only `visit_foo`
method in `impl_visitable_calling_walkable!` without a corresponding
`walk_foo` method in `define_named_walk!`.

I confirmed with the original author (khyperia) that this is an
unintentional oversight.
2026-09-14 08:00:40 +10:00
bors
4b6d04e706 Auto merge of #162418 - LorrensP-2158466:cache-cell-bench, r=petrochenkov
Remove `CacheCell` and `CacheRefCell` aliases and directly use `Lock` and `RwLock`



Some changes from rust-lang/rust#158845 for benchmarking.

decided to change Mutex to `datastructures::sync::Lock`.

r? @petrochenkov
2026-09-13 20:26:32 +00:00
Evgenii Zheltonozhskii
31922ed410 Constify more Iterator and DoubleEndedIterator methods 2026-09-13 23:21:00 +03:00
sjwang05
a6aae86a23 cleanups 2026-09-13 13:18:21 -07:00
Max Dexheimer
f0eb4b571c Remove pointless A: Allocator bounds in boxed.rs 2026-09-13 21:58:10 +02:00