56109 Commits

Author SHA1 Message Date
Rust timing bot 19b70ac34d Unrolled build for #155772
Rollup merge of #155772 - oli-obk:const-closures-everywhere, r=fee1-dead

Check closure's constness validity in the constness query

fixes rust-lang/rust#155584

instead of checking during ast lowering, where it's not easily possible to obtain all the right information in time. While lowering an assoc item we don't know if the parent was a const trait or a const impl. Tracing this information is quite annoying, and complicates a lot of code, which checking here after the fact is trivial.
2026-04-27 13:12:48 +02:00
Oli Scherer 8e1c34f5cc Check closure's constness validity in the constness query
instead of during ast lowering, where it's not easily possible to obtain all the right information in time
2026-04-27 07:44:19 +02:00
Jacob Pratt bd2d1a8443 Rollup merge of #155835 - jyn514:jyn/verify-ich-diagnostics, r=wesleywiser
couple of `crate_name` cleanups

Split out from https://github.com/rust-lang/rust/pull/153924; these changes should be uncontroversial.
2026-04-26 21:56:46 -04:00
Jacob Pratt c0e4189058 Rollup merge of #155829 - scrabsha:push-kwlqypwmnpul, r=mejrs
rustc_attr_parsing: use a `try {}` in `or_malformed`
2026-04-26 21:56:45 -04:00
Jacob Pratt 3502ed31ec Rollup merge of #155818 - JonathanBrouwer:finalize-fn-ptr, r=mejrs
Convert attribute `FinalizeFn` to fn pointer
2026-04-26 21:56:44 -04:00
Jacob Pratt 78569d8d6a Rollup merge of #155770 - chenyukang:yukang-fix-155670-closure-return-note, r=wesleywiser
Avoid misleading closure return type note

Fixes rust-lang/rust#155670
2026-04-26 21:56:44 -04:00
Jacob Pratt 9562f3da2d Rollup merge of #155682 - Unique-Usman:ua/box-impl, r=mejrs
Add boxing suggestions for `impl Trait` return type mismatches

A sort of a follow up pr to this -> https://github.com/rust-lang/rust/pull/155546
2026-04-26 21:56:43 -04:00
Jacob Pratt c20a92efd9 Rollup merge of #155778 - kevinheavey:perf-mk-place-elem-avoid-vec-alloc, r=cjgillot,JohnTitor
Avoid Vec allocation in TyCtxt::mk_place_elem

`mk_place_elem` appends a single `PlaceElem` to an existing (interned) projection. The current implementation copies the projection into a fresh `Vec`, pushes the new element, and re-interns the slice, which allocates on every call.

Feed the elements through `mk_place_elems_from_iter` so that `CollectAndApply`'s hand-unrolled stack fast path (up to 9 elements, in `rustc_type_ir::interner`) kicks in for the common case of short projections and the `Vec` allocation is skipped entirely. The behavior is identical for longer projections (the fast path falls back to a `Vec` internally).
2026-04-26 21:56:42 -04:00
Jacob Pratt f8e3af446e Rollup merge of #149624 - Flakebi:fix-lto, r=bjorn3
Fix requires_lto targets needing lto set in cargo

Targets that set `requires_lto = true` were not actually using lto when compiling with cargo by default. They needed an extra `lto = true` in `Cargo.toml` to work.

Fix this by letting lto take precedence over the `embed_bitcode` flag when lto is required by a target.

If both these flags would be supplied by the user, an error is generated. However, this did not happen when lto was requested by the target instead of the user.

Fixes rust-lang/rust#148514
Tracking issue: rust-lang/rust#135024
2026-04-26 21:56:39 -04:00
bors ca9a134e09 Auto merge of #155837 - JonathanBrouwer:rollup-aPhy30j, r=JonathanBrouwer
Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#152995 (ACP Implementation of PermissionsExt for Windows )
 - rust-lang/rust#153457 (prevent deref coercions in `pin!`)
 - rust-lang/rust#155250 (Windows: Cache the pipe filesystem handle)
 - rust-lang/rust#155574 (Move `std::io::RawOsError` to `core::io`)
 - rust-lang/rust#155757 (macro_metavar_expr_concat: explain why idents are invalid)
 - rust-lang/rust#155823 (miri subtree update)
 - rust-lang/rust#155693 (Suggest enclosing format string with `""` under special cases)
 - rust-lang/rust#155707 (Fix minor panic-unsoundness in CString::clone_into)
 - rust-lang/rust#155719 (Suggest `.iter()` for shared projections)
 - rust-lang/rust#155779 (ssa_range_prop: use `if let` guards)
 - rust-lang/rust#155789 (Cleanups to `AttributeExt`)
 - rust-lang/rust#155805 (Mention `DEPRECATED_LLVM_INTRINSIC` lint for internal use)
 - rust-lang/rust#155806 (Remove the incomplete marker from `impl` restrictions)
 - rust-lang/rust#155820 (Avoid improper spans when `...` or `..=` is recovered from non-ASCII)
 - rust-lang/rust#155822 (Add default field values to diagnostic FormatArgs)
2026-04-26 20:31:33 +00:00
Jonathan Brouwer 139bcba8f6 Rollup merge of #155822 - mejrs:default_fmt_args, r=JonathanBrouwer
Add default field values to diagnostic FormatArgs

This type has a decent amount of unused fields (and I am planning to add more).
2026-04-26 19:06:32 +02:00
Jonathan Brouwer ae7751677e Rollup merge of #155820 - Zalathar:range, r=Kivooeo
Avoid improper spans when `...` or `..=` is recovered from non-ASCII

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

Adjusting span endpoints by `BytePos(1)` is almost always bad news.

In this case, the code assumed that it was skipping over a single ASCII character. But in the presence of parser recovery from other non-ASCII characters this resulted in an ICE due to bad string indexing when emitting suggestions.
2026-04-26 19:06:31 +02:00
Jonathan Brouwer b227d459be Rollup merge of #155806 - CoCo-Japan-pan:impl-restriction-mark-unstable, r=jhpratt,Urgau
Remove the incomplete marker from `impl` restrictions

Following the discussion on Zulip ([#gsoc > Idea: Implementing impl and mut restrictions @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Idea.3A.20Implementing.20impl.20and.20mut.20restrictions/near/590562763)),this PR removes the incomplete marker from `#[feature(impl_restriction)]`.
Tracking issue for restrictions: rust-lang/rust#105077.

r? @Urgau
cc @jhpratt
2026-04-26 19:06:31 +02:00
Jonathan Brouwer c96f7d2e53 Rollup merge of #155805 - shian15810:patch-1, r=mejrs
Mention `DEPRECATED_LLVM_INTRINSIC` lint for internal use

Since `link_llvm_intrinsics` is an internal feature, having `deprecated_llvm_intrinsic` lint appearing in https://doc.rust-lang.org/nightly/rustc/lints/listing/allowed-by-default.html#deprecated-llvm-intrinsic without mentioning its internal nature is quite confusing to the end users.

This PR improves the documentation of recently merged PR https://github.com/rust-lang/rust/pull/140763 that implemented `deprecated_llvm_intrinsic` lint by mentioning the internal nature of `deprecated_llvm_intrinsic` lint and `link_llvm_intrinsics` feature.

Tracking issue of unstable `link_llvm_intrinsics` feature: https://github.com/rust-lang/rust/issues/29602
2026-04-26 19:06:30 +02:00
Jonathan Brouwer 37b53a9461 Rollup merge of #155789 - JonathanBrouwer:attribute-ext, r=mejrs
Cleanups to `AttributeExt`

r? @mejrs

- Makes some functions take `ast::Attribute` instead of `impl AttributeExt`
- Remove `deprecation_note` from `AttributeExt`, since the two implementations are basically seperate
2026-04-26 19:06:29 +02:00
Jonathan Brouwer ecdcd0e588 Rollup merge of #155779 - Human9000-bit:ssa-range-prop-ref, r=Kivooeo
ssa_range_prop: use `if let` guards

It is a bit cleaner this way

r? @dianqk
2026-04-26 19:06:29 +02:00
Jonathan Brouwer 59ca5ae02c Rollup merge of #155719 - qaijuang:suggest-iter-for-shared-projections-issue-155365, r=ShoyuVanilla
Suggest `.iter()` for shared projections

Fixes rust-lang/rust#155365.
2026-04-26 19:06:28 +02:00
Jonathan Brouwer fa16f8102e Rollup merge of #155693 - cclfmht:fix/issue-155508, r=ShoyuVanilla
Suggest enclosing format string with `""` under special cases

This commit adds suggestions on enclosing format string with `""` when it falls into the following 3 cases: `{}`, `{:?}`, `{:#?}` as mentioned in rust-lang/rust#155508.

Currently, this commit only recognizes the above 3 cases. I wonder if we should generalize this to more cases, for example, appying this suggestion to `Block`s with only 0 or 1 `Stmt`, such as `{:#x}`, `{:^10}`, `{abc}`.
2026-04-26 19:06:27 +02:00
Jonathan Brouwer 382ec81061 Rollup merge of #155757 - mejrs:ident_help, r=Kivooeo
macro_metavar_expr_concat: explain why idents are invalid

Recently I've been playing around with `macro_metavar_expr_concat` and in the process wasted more time than I'd have liked on debugging my dodgy idents. This should make that experience much nicer going forward.
2026-04-26 19:06:26 +02:00
bors d4f7856569 Auto merge of #155473 - scottmcm:tweak_niche_assignment, r=chenyukang,mati865
Prefer `-1` for `None`



Currently we pick "weird" numbers like `1114112` for `None::<char>`.  While that's not *wrong*, it's kinda *unnatural* -- a human wouldn't make that choice.

This PR instead picks `-1` for thinge like `None::<char>` -- like [clang's `WEOF`](https://github.com/llvm/llvm-project/blob/63ae74b78a11f6c61136dbc445652929389eb9ab/libc/include/llvm-libc-macros/wchar-macros.h#L15) -- and `None::<bool>` and such.

Any enums with more than one niched value (so not `Result` nor `Option`) remain as they were before.  Also we continue to use `0` when that's possible -- `-1` is only preferred when zero *isn't* possible.

---

Inspired when someone in discord posted an example like this <https://rust.godbolt.org/z/W94s9qdYW> and I thought it was odd that we're currently picking `-9223372036854775808` to be the value to store to mark an `Option<Vec<_>>` as `None`.  (Especially since that needs an 8-byte immediate on x64, and writing `-1` is only a 4-byte immediate.)
2026-04-26 17:06:25 +00:00
jyn 7151184b46 Add some debugging to rustc_session filename handling 2026-04-26 16:19:11 +00:00
jyn d9e227e98a Fix broken logic in incremental_verify_ich_failed 2026-04-26 16:18:45 +00:00
Sasha Pourcelot a7330f4897 rustc_attr_parsing: use a try {} in or_malformed 2026-04-26 15:15:25 +00:00
Qai Juang 28c079ae40 Suggest .iter() for shared projections
* Suggest `.iter()` for shared projections
* address few nits
* a few improvements
2026-04-26 14:30:46 +00:00
mejrs 48fe89f994 add default field values to diagnostic FormatArgs 2026-04-26 14:23:53 +02:00
Usman Akinyemi a677828c48 Add boxing suggestions for return expressions in impl Trait functions
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
2026-04-26 17:43:40 +05:30
Zalathar 9ceed255b5 Avoid improper spans when ... or ..= is recovered from non-ASCII
This avoids an ICE due to indexing into the middle of a multi-byte character.
2026-04-26 21:41:46 +10:00
Jonathan Brouwer 163aedc873 Convert attribute FinalizeFn to fn pointer 2026-04-26 13:09:50 +02:00
cclfmht 2c16f9edf5 Suggest enclosing format string with "" under special cases
* Suggest enclosing format string under special cases

This commit add suggestions about enclosing format string when it falls
into the following cases: `{}`, `{:?}`, `{:#?}`.
* Add HELP annotations in the UI test
2026-04-26 10:50:05 +00:00
Usman Akinyemi 4fc64f4180 Add boxing suggestions for impl Trait return type mismatches
Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
2026-04-26 14:58:49 +05:30
CoCo-Japan-pan 79e10fd5ef Remove the incomplete marker from impl restrictions 2026-04-26 13:07:09 +09:00
Cheeshian Chuah efaf460224 Mention DEPRECATED_LLVM_INTRINSIC lint for internal use 2026-04-26 11:05:05 +08:00
Scott McMurray ba1a33e105 Prefer -1 for None
Currently we pick "weird" numbers like `1114112` for `None::<char>`.  While that's not *wrong*, it's kinda *unnatural* -- a human wouldn't make that choice.

This PR instead picks `-1` for thinge like `None::<char>` -- like clang's `WEOF` -- and `None::<bool>` and such.

Any enums with more than one niched value (so not `Result` nor `Option`) remain as they were before.
2026-04-25 14:57:23 -07:00
Jonathan Brouwer 3b59d9d58e Rollup merge of #155783 - qaijuang:issue-150566-cfg-trace-suggestions, r=JonathanBrouwer
Do not suggest internal cfg trace attributes

Fixes rust-lang/rust#150566.
2026-04-25 23:07:53 +02:00
Jonathan Brouwer 97dd613234 Rollup merge of #155696 - scrabsha:push-kxqstpltlwzn, r=JonathanBrouwer
Add a higher-level API for parsing attributes
2026-04-25 23:07:52 +02:00
Jonathan Brouwer 2c639cc7fe Rollup merge of #155676 - oli-obk:const-drop-non-const-destruct, r=fee1-dead
Reject implementing const Drop for types that are not const `Destruct` already

fixes rust-lang/rust#155618

While there is no soundness or otherwise issue currently, this PR ensures that people get what they expect. It seems wrong to allow implementing `const Drop`, but then the type still can't be dropped at compile-time.

r? @fee1-dead
2026-04-25 23:07:51 +02:00
Jonathan Brouwer 1fe66ee46e Rollup merge of #155065 - folkertdev:macho-section-specifier, r=JonathanBrouwer
Error on invalid macho section specifier

The macho section specifier used by `#[link_section = "..."]` is more strict than e.g. the one for elf. LLVM will error when you get it wrong, which is easy to do if you're used to elf. So, provide some guidance for the simplest mistakes, based on the LLVM validation.

Currently compilation fails with an LLVM error, see https://godbolt.org/z/WoE8EdK1K.

The LLVM validation logic is at

https://github.com/llvm/llvm-project/blob/a0f0d6342e0cd75b7f41e0e6aae0944393b68a62/llvm/lib/MC/MCSectionMachO.cpp#L199-L203

LLVM validates the other components of the section specifier too, but it feels a bit fragile to duplicate those checks. If you get that far, hopefully the LLVM errors will be sufficient to get unstuck.

---

sidequest from https://github.com/rust-lang/rust/pull/147811

r? JonathanBrouwer

specifically, is this the right place for this sort of validation? `rustc_attr_parsing` also does some validation.
2026-04-25 23:07:50 +02:00
Jonathan Brouwer 76a365523f Rollup merge of #154803 - chenyukang:yukang-fix-154801-cfg-attr-span, r=JonathanBrouwer
Fix ICE from cfg_attr_trace

Fixes rust-lang/rust#154801
Fixes https://github.com/rust-lang/rust/issues/143094

r? @JonathanBrouwer

The root cause is we recovery from parsing attribute error here:
https://github.com/rust-lang/rust/blob/ed6f9af7d47f5a5eda2a4a1925d1e250b51a37f2/compiler/rustc_attr_parsing/src/parser.rs#L550
while the later suggestion code from type checking try to inspect the attr span of the `expr` in the second error, keep the span seems reasonable.
2026-04-25 23:07:49 +02:00
Jonathan Brouwer dde4886801 Rollup merge of #146181 - Flakebi:dynamic-shared-memory, r=ZuseZ4,Sa4dus,workingjubilee,RalfJung,nikic,kjetilkjeka,kulst
Add intrinsic for launch-sized workgroup memory on GPUs

Workgroup memory is a memory region that is shared between all
threads in a workgroup on GPUs. Workgroup memory can be allocated
statically or after compilation, when launching a gpu-kernel.
The intrinsic added here returns the pointer to the memory that is
allocated at launch-time.

# Interface

With this change, workgroup memory can be accessed in Rust by
calling the new `gpu_launch_sized_workgroup_mem<T>() -> *mut T`
intrinsic.

It returns the pointer to workgroup memory guaranteeing that it is
aligned to at least the alignment of `T`.
The pointer is dereferencable for the size specified when launching the
current gpu-kernel (which may be the size of `T` but can also be larger
or smaller or zero).

All calls to this intrinsic return a pointer to the same address.

See the intrinsic documentation for more details.

## Alternative Interfaces

It was also considered to expose dynamic workgroup memory as extern
static variables in Rust, like they are represented in LLVM IR.
However, due to the pointer not being guaranteed to be dereferencable
(that depends on the allocated size at runtime), such a global must be
zero-sized, which makes global variables a bad fit.

# Implementation Details

Workgroup memory in amdgpu and nvptx lives in address space 3.
Workgroup memory from a launch is implemented by creating an
external global variable in address space 3. The global is declared with
size 0, as the actual size is only known at runtime. It is defined
behavior in LLVM to access an external global outside the defined size.

There is no similar way to get the allocated size of launch-sized
workgroup memory on amdgpu an nvptx, so users have to pass this
out-of-band or rely on target specific ways for now.

Tracking issue: rust-lang/rust#135516
2026-04-25 23:07:48 +02:00
Jonathan Brouwer e3b0e9db08 Remove deprecation_note from AttributeExt 2026-04-25 21:26:00 +02:00
Jonathan Brouwer f113540cec Remove unnecessary uses of AttributeExt 2026-04-25 21:25:43 +02:00
Oli Scherer 7dcedafff2 Reject implementing const Drop for types that are not const Destruct already 2026-04-25 20:56:32 +02:00
Folkert de Vries a4f5c6e971 error on invalid macho section specifier 2026-04-25 20:06:30 +02:00
mejrs b6c6dd1fa0 macro_metavar_expr_concat: explain why idents are invalid 2026-04-25 19:56:05 +02:00
bors 9838411cb7 Auto merge of #155257 - petrochenkov:visatleast, r=adwinwhite
privacy: Assert that compared visibilities are (usually) ordered



And make "greater than" (`>`) the new primary operation for comparing visibilities instead of "is at least" (`>=`).
2026-04-25 16:15:55 +00:00
Qai Juang b17822575c Do not suggest internal cfg trace attributes 2026-04-25 11:47:34 -04:00
human9000 29d58f8b4c Utilize if let guards where aproppriate 2026-04-25 19:42:57 +05:00
Kevin Heavey 5cd9d929a9 Avoid Vec allocation in TyCtxt::mk_place_elem
`mk_place_elem` appends a single `PlaceElem` to an existing (interned)
projection. The current implementation copies the projection into a
fresh `Vec`, pushes the new element, and re-interns the slice, which
allocates on the heap on every call.

Feed the elements through `mk_place_elems_from_iter` so that
`CollectAndApply`'s hand-unrolled stack fast path (up to 9 elements,
in `rustc_type_ir::interner`) kicks in for the common case of short
projections and the `Vec` allocation is skipped entirely. The behavior
is identical for longer projections (the fast path falls back to a
`Vec` internally).
2026-04-25 15:05:59 +01:00
bors fb76025f2f Auto merge of #155460 - cjgillot:unmut-resolver-ast, r=oli-obk
Do not modify resolver outputs during lowering



Split from https://github.com/rust-lang/rust/pull/142830

I believe this achieves the same thing as https://github.com/rust-lang/rust/pull/153656 but in a much simpler way. 

This PR forces AST->HIR lowering to stop mutating resolver outputs. Instead, it manages a few override maps that only live during lowering and are dropped afterwards.

r? @petrochenkov 
cc @aerooneqq
2026-04-25 10:01:32 +00:00
yukang 5e00484c38 Avoid misleading closure return type note 2026-04-25 16:27:05 +08:00