325084 Commits

Author SHA1 Message Date
bors
4933094f25 Auto merge of #155851 - jhpratt:rollup-Jst4hhC, r=jhpratt
Some checks failed
Post merge analysis / analysis (push) Has been cancelled
GHCR image mirroring / DockerHub mirror (push) Has been cancelled
Bump dependencies in Cargo.lock / skip if S-waiting-on-bors (push) Has been cancelled
Bump dependencies in Cargo.lock / update dependencies (push) Has been cancelled
Bump dependencies in Cargo.lock / amend PR (push) Has been cancelled
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#149624 (Fix requires_lto targets needing lto set in cargo)
 - rust-lang/rust#155317 (`std::io::Take`: Clarify & optimize `BorrowedBuf::set_init` usage.)
 - rust-lang/rust#155579 (Make Rcs and Arcs use pointer comparison for unsized types)
 - rust-lang/rust#155588 (Implement more traits for FRTs)
 - rust-lang/rust#155708 (Fix heap overflow in slice::join caused by misbehaving Borrow)
 - rust-lang/rust#155778 (Avoid Vec allocation in TyCtxt::mk_place_elem)
 - rust-lang/rust#151014 (std: sys: process: uefi: Add program searching)
 - rust-lang/rust#155682 (Add boxing suggestions for `impl Trait` return type mismatches)
 - rust-lang/rust#155770 (Avoid misleading closure return type note)
 - rust-lang/rust#155818 (Convert attribute `FinalizeFn` to fn pointer)
 - rust-lang/rust#155829 (rustc_attr_parsing: use a `try {}` in `or_malformed`)
 - rust-lang/rust#155835 (couple of `crate_name` cleanups)
2026-04-27 02:32:52 +00: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
e3a6fa5082 Rollup merge of #151014 - Ayush1325:uefi-cmd-path, r=jhpratt,nicholasbishop
std: sys: process: uefi: Add program searching

- Follow UEFI Shell search flow to search for programs while launching.
- Tested using OVMF on QEMU.

@rustbot label +O-UEFI
2026-04-26 21:56:42 -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
f4043f8c09 Rollup merge of #155708 - Manishearth:borrow-fix, r=Mark-Simulacrum
Fix heap overflow in slice::join caused by misbehaving Borrow

This code allocates a buffer using lengths calculated by calling `.borrow()` on some slices, and then copies them over after again calling `.borrow()`. There is no safety-reliable guarantee that these will return the same slices.

While this code calls `.borrow()` three times, only one of them is problematic: the others already use checked indexing.

I made the test a normal library test, but let me know if it should go elsewhere.

Bug discovered by Rust Foundation Security using AI. I'm just helping with the patch as a member of wg-security-response. We do not believe this bug needs embargo, it is a soundness fix for hard-to-trigger unsoundness.
2026-04-26 21:56:41 -04:00
Jacob Pratt
7695b849d4 Rollup merge of #155588 - BennoLossin:frt-traits, r=Mark-Simulacrum
Implement more traits for FRTs

From https://github.com/rust-lang/rust/pull/154927#discussion_r3068460955.

FRTs now implement the following traits: `Sized + Freeze + RefUnwindSafe + Send + Sync + Unpin + UnsafeUnpin + UnwindSafe + Copy + Debug + Default + Eq + Hash + Ord`.

Let me know if there is any trait missing.

I also removed the explicit  `Send` and `Sync` impls, since commit cb37ee2c87 ("make field representing types invariant over the base type") made the auto-trait impl work even if `T: !Send` or `T: !Sync`. Very happy to see unsafe impls get dropped :)

Note that I used the reflection feature (cc @oli-obk) to print the actual field names in the debug implementation. I think this is a cool way to use it, but if it isn't ready for that, I'm happy to change it to the alternative implementation I gave in the note comment (it's essentially Mark's suggestion but printing `T`'s name instead of `Self`'s).

Since this is a library change, I'll give this to Mark; feel free to also take a look/leave comments, Oli :)

r? @Mark-Simulacrum
2026-04-26 21:56:41 -04:00
Jacob Pratt
72cd5fba78 Rollup merge of #155579 - Gaming32:fix-154998, r=Mark-Simulacrum
Make Rcs and Arcs use pointer comparison for unsized types

`Rc` and `Arc`s have an `Eq` implementation that first attempt to compare the pointers as an optimization. This, however, was not extended to DSTs, which is what this PR fixes.

Fixes rust-lang/rust#154998.
2026-04-26 21:56:40 -04:00
Jacob Pratt
12a843a020 Rollup merge of #155317 - briansmith:b/take-opt, r=Mark-Simulacrum
`std::io::Take`: Clarify & optimize `BorrowedBuf::set_init` usage.

Don't initialize `buf` if it was already initialized. Clarify safety comments.

Move the `buf.advance()` call to make the initialization more like
calling `buf.ensure_init()`, then clarify how the code here is an
optimized variant of `ensure_init`.
2026-04-26 21:56:39 -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
Manish Goregaokar
da545d0856 Fix heap overflow in slice::join caused by misbehaving Borrow
* Fix heap overflow in slice join via inconsistent Borrow
* Update library/alloc/src/str.rs

Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
2026-04-26 23:20:32 +00: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
27aa1c5222 Rollup merge of #155707 - Manishearth:cstring-vuln, r=Mark-Simulacrum
Fix minor panic-unsoundness in CString::clone_into

`CString` must always contain a null byte, calling `mem::take` on its inner allocation puts it in an invalid state (causing UB if e.g. it hits `CString::drop`) that can be observed if the allocator panics.

Unfortunately, this solution allocates an intermediate 1-element `Box`. I'm not sure of a clean way to avoid that additional allocation; we could directly `realloc` if we want but it's tricky. Might be something we can do with `ManuallyDrop`.

I do have a gnarly miri test for this that uses a panicky allocator, but I'm not sure where it would go. Happy to push it up if someone has a suggestion.

Bug discovered by Rust Foundation Security using AI. I'm just helping with the patch as a member of wg-security-response. We do not believe this bug needs embargo, it is a soundness fix for hard-to-trigger unsoundness.
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
a722bc89a0 Rollup merge of #155823 - RalfJung:miri, r=RalfJung
miri subtree update

Subtree update of `miri` to f3f6dca488.

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

r? @ghost
2026-04-26 19:06:26 +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`](63ae74b78a/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
Jonathan Brouwer
9170ff7733 Rollup merge of #155574 - bushrat011899:core_io_raw_os_error, r=Mark-Simulacrum
Move `std::io::RawOsError` to `core::io`

ACP: https://github.com/rust-lang/libs-team/issues/755
Tracking issue: https://github.com/rust-lang/rust/issues/154046
Related: https://github.com/rust-lang/rust/pull/154654

## Description

As a part of moving components of `std::io` into `alloc::io` and `core::io`, there will need to be a new home for the type `RawOsError`. In this PR, I propose moving it to `core::io`, and removing it from `std::sys`. I suspect this will be quite controversial as it is a platform dependent type, but this is not the only instance of a type being conditioned on `target_os` in `core` (e.g., `core::os` and `core::ffi`).

Since `RawOsError` is currently unstable, I think it's reasonable to make this move now, and worry about making it platform independent if/when it is stabilized (e.g., replacing it with a wrapper around `isize` on all platforms).

---

## Notes

* No AI tooling of any kind was used during the creation of this PR.
2026-04-26 19:06:25 +02:00
Jonathan Brouwer
eb779a151b Rollup merge of #155250 - ChrisDenton:pipe-fs, r=Mark-Simulacrum
Windows: Cache the pipe filesystem handle

Updates the anonymous pipe handling based on feedback from @lhecker  (see https://github.com/rust-lang/rust/pull/142517#discussion_r3065864262). This does two things:

1. Cache the handle to the pipe filesystem so we don't have to reopen it each time.
2. Use the `\Device\NamedPipe\` directly instead of the symlink to it.
2026-04-26 19:06:24 +02:00
Jonathan Brouwer
691ab1b396 Rollup merge of #153457 - dianne:no-coercing-in-pin-macro, r=Mark-Simulacrum,jackh726
prevent deref coercions in `pin!`

Mitigates rust-lang/rust#153438 using a (hopefully temporary!) typed macro idiom to ensure that when `pin!` produces a `Pin<&mut T>`, its argument is of type `T`. See https://github.com/rust-lang/rust/issues/153438#issuecomment-4006727101 for my ideas on how this could be changed in the future.
2026-04-26 19:06:24 +02:00
Jonathan Brouwer
7c71f48c5d Rollup merge of #152995 - asder8215:windows_permissions_ext, r=Mark-Simulacrum
ACP Implementation of PermissionsExt for Windows

This PR implements the `PermissionsExt` for Windows ACP and adds file attribute methods in `FilePermissions` struct (to be decided whether we use them or not). See this [tracking issue](https://github.com/rust-lang/rust/issues/152956#event-22976637690) for further detail and links.

I also added some comments in the code for clarifications about the ACP (e.g. whether we should have a `set_file_attributes()` + `from_file_attributes()` method to mirror what unix's `PermissionsExt` is doing).

Also, some relevant links on this:
* [File Attribute Constants](https://learn.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants)
* [`attrib` command](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/attrib)
* [SetFileAttributesA](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-setfileattributesa)
* [GetFileAttributesA](https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfileattributesa)
* [Window's File Attributes Column Values](https://superuser.com/questions/44812/windows-explorers-file-attribute-column-values)
* [What is the 'M' attribute in Windows file system for?](https://superuser.com/questions/1621649/what-is-the-m-attribute-in-windows-file-system-for)

Note: Apologies for the multiple forced push. I haven't set up my Windows VM up yet to compile and check the code, so I've been using the CI to help me with that.

r? @ChrisDenton
2026-04-26 19:06:23 +02: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
Zalathar
f107bb85a2 Regression test for improper spans in inclusive-range suggestions 2026-04-26 21:36:51 +10:00
Ralf Jung
9ae47c9b53 Merge pull request #4812 from enthropy7/master
Support fstat on non-file-backed FDs
2026-04-26 11:23:07 +00:00
Jonathan Brouwer
163aedc873 Convert attribute FinalizeFn to fn pointer 2026-04-26 13:09:50 +02:00
Ralf Jung
c91a363db1 merge fstat and metadata functions 2026-04-26 12:59:02 +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
bors
c7fe5e9d1e Auto merge of #155813 - JonathanBrouwer:rollup-M9eCmdI, r=JonathanBrouwer
Rollup of 2 pull requests

Successful merges:

 - rust-lang/rust#155774 (std: maintain `CStringArray` null-termination even if `Vec::push` panics)
 - rust-lang/rust#155810 (Expand the initialism UCRT in rustc book)
2026-04-26 09:03:36 +00:00
Jonathan Brouwer
ea0a790fa5 Rollup merge of #155810 - miikkas:expand-acronym-ucrt, r=Noratrieb
Expand the initialism UCRT in rustc book

This PR adds a commit expanding the initialism UCRT on first use in the rusct book chapter on the [*-windows-gnullvm platform support](https://doc.rust-lang.org/nightly/rustc/platform-support/windows-gnullvm.html), making the chapter easier to understand. Microsoft, the originator of this technology (and thus, the canonical source for the acronym) in Windows, expands it to _Universal C Runtime_[^1][^2][^3]. The same expansion is added to the chapter.

[^1]: https://learn.microsoft.com/en-us/cpp/porting/upgrade-your-code-to-the-universal-crt
[^2]: https://learn.microsoft.com/en-us/cpp/windows/universal-crt-deployment
[^3]: https://devblogs.microsoft.com/cppblog/introducing-the-universal-crt/
2026-04-26 11:02:50 +02:00
Jonathan Brouwer
e9607db8ac Rollup merge of #155774 - joboet:cstring_array_null, r=jhpratt
std: maintain `CStringArray` null-termination even if `Vec::push` panics

Fixes rust-lang/rust#155748 by performing the `push` of the new null terminator before overwriting the previous one.
2026-04-26 11:02:49 +02:00
Miikka Salminen
33c1e869d7 Expand the initialism UCRT in rustc book
This commit expands the initialism UCRT on first use in the rusct book
chapter on the *-windows-gnullvm platform support, making the chapter
easier to understand. Microsoft, the originator of this technology in
Windows, expands it to Universal C Runtime[1]. The same expansion is
added to the chapter.

[1] https://learn.microsoft.com/en-us/cpp/porting/upgrade-your-code-to-the-universal-crt
2026-04-26 09:05:37 +03:00
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