Skip to content

Fix crate name validation #127581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 16, 2025
Merged

Conversation

fmease
Copy link
Member

@fmease fmease commented Jul 10, 2024

Reject macro calls inside attribute #![crate_name] like in #![crate_name = concat!("na", "me")].

Prior to #117584, the result of the expansion (here: "name") would actually be properly picked up by the compiler and used as the crate name. However since #117584 / on master, we extract the "value" (i.e., the literal string literal) of the #![crate_name] much earlier in the pipeline way before macro expansion and skip/ignore any #![crate_name]s "assigned to" a macro call. See also #122001.

T-lang has ruled to reject #![crate_name = MACRO!(...)] outright very similar to other built-in attributes whose value we need early like #![crate_type]. See accepted FCP: #122001 (comment).

Note that the check as implemented in this PR is even more "aggressive" compared to the one of #![crate_type] by running as early as possible in order to reject #![crate_name = MACRO!(...)] even in "non-normal" executions of rustc, namely on print requests (e.g., --print=crate-name and --print=file-names). If I were to move the validation step a bit further back close to the #![crate_type] one, --print=crate-name (etc.) would not exit fatally with an error in this kind of situation but happily report an incorrect crate name (i.e., the "crate name" as if #![crate_name] didn't exist / deduced from other sources like --crate-name or the file name) which would match the behavior on master. Again, see also #122001.

I'm mentioning this explicitly because I'm not sure if it was that clear in the FCP'ed issue. I argue that my current approach is the most reasonable one. I know (from reading the code and from past experiments) that various print requests are still quite broken (mostly lack of validation).

To the best of my knowledge, there's no print request whose output references/contains a crate type, so there's no "inherent need" to move #![crate_type]'s validation to happen earlier.


Fixes #122001.

relnotes Marks issues that should be documented in the release notes of the next release. : Compatibility. Breaking change.

@fmease fmease added the relnotes Marks issues that should be documented in the release notes of the next release. label Jul 10, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jul 10, 2024

r? @wesleywiser

rustbot has assigned @wesleywiser.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 10, 2024
@rust-log-analyzer

This comment has been minimized.

fmease

This comment was marked as duplicate.

@fmease fmease marked this pull request as draft July 10, 2024 17:26
@fmease fmease force-pushed the fix-crate_name-validation branch from 7b933ad to 3de58e6 Compare July 10, 2024 17:51
@fmease fmease marked this pull request as ready for review July 10, 2024 17:51
@rust-log-analyzer

This comment has been minimized.

@fmease fmease changed the title Fix crate name validation Fix crate name validation & cleanup Jul 10, 2024
@fmease fmease changed the title Fix crate name validation & cleanup Fix crate name validation & clean up Jul 10, 2024
@fmease fmease force-pushed the fix-crate_name-validation branch from 3de58e6 to e688f5e Compare July 10, 2024 20:37
@fmease
Copy link
Member Author

fmease commented Jul 18, 2024

I've finally added a proper PR description. Sorry about the delay ^^'.

@bors

This comment was marked as resolved.

Copy link
Member

@wesleywiser wesleywiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the last commit still WIP?

@fmease fmease changed the title Fix crate name validation & clean up Fix crate name validation Jul 31, 2024
@fmease fmease force-pushed the fix-crate_name-validation branch from e688f5e to d169eee Compare July 31, 2024 18:18
@fmease
Copy link
Member Author

fmease commented Jul 31, 2024

Is the last commit still WIP?

I've now dropped the WIP commit as I still need to investigate the implications of its changes. I'll submit it as a follow-up PR if everything works out.

I've adjusted the wording in the comment to no longer use the word 'currently'.

Ready for re-review. Nothing WIP left.

@bors

This comment was marked as resolved.

@fmease fmease force-pushed the fix-crate_name-validation branch from d169eee to 29a5379 Compare September 13, 2024 04:40
@bors

This comment was marked as resolved.

@fmease fmease added the rla-silenced Silences rust-log-analyzer postings to the PR it's added on. label Sep 24, 2024
@fmease fmease force-pushed the fix-crate_name-validation branch from 29a5379 to 70053f9 Compare September 24, 2024 08:46
@fmease fmease removed the rla-silenced Silences rust-log-analyzer postings to the PR it's added on. label Sep 24, 2024
@bors

This comment was marked as resolved.

pub fn get_crate_name(sess: &Session, krate_attrs: &[ast::Attribute]) -> Symbol {
// We unconditionally validate all `#![crate_name]`s even if a crate name was
// set on the command line via `--crate-name` which we prioritize over the
// crate attributes. We perform the validation here instead of later to ensure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--crate-name isn't prioritized. Rather it and #![crate_name] must match.

@bjorn3
Copy link
Member

bjorn3 commented Feb 14, 2025

r? @bjorn3

@rustbot rustbot assigned bjorn3 and unassigned wesleywiser Feb 14, 2025
Gets rid of two top-level UI tests which is always great.

Furthermore, move `need-crate-arg-ignore-tidy$x.rs`
from `command/` to `invalid-compile-flags/`.
`command/` concerns `std::process::Command` tests, not CLI tests.
@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 15, 2025
@fmease fmease force-pushed the fix-crate_name-validation branch from cff23ae to 9b6fd35 Compare February 15, 2025 15:48
@fmease
Copy link
Member Author

fmease commented Feb 15, 2025

I take the approval as an "r=me with nit addressed".
@bors r=bjorn3

@bors
Copy link
Collaborator

bors commented Feb 15, 2025

📌 Commit 9b6fd35 has been approved by bjorn3

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 15, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 15, 2025
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#127581 (Fix crate name validation)
 - rust-lang#136490 (Do not allow attributes on struct field rest patterns)
 - rust-lang#136808 (Try to recover from path sep error in type parsing)
 - rust-lang#137055 (rustdoc: Properly restore search input placeholder)
 - rust-lang#137068 (fix(rustdoc): Fixed `Copy Item Path` in rust doc)
 - rust-lang#137070 (Do not generate invalid links in job summaries)
 - rust-lang#137074 (compiletest: add `{ignore,only}-rustc_abi-x86-sse2` directives)
 - rust-lang#137076 (triagebot.toml: ping me on changes to `tests/rustdoc-json`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 16, 2025
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#127581 (Fix crate name validation)
 - rust-lang#136490 (Do not allow attributes on struct field rest patterns)
 - rust-lang#136808 (Try to recover from path sep error in type parsing)
 - rust-lang#137055 (rustdoc: Properly restore search input placeholder)
 - rust-lang#137068 (fix(rustdoc): Fixed `Copy Item Path` in rust doc)
 - rust-lang#137070 (Do not generate invalid links in job summaries)
 - rust-lang#137074 (compiletest: add `{ignore,only}-rustc_abi-x86-sse2` directives)
 - rust-lang#137076 (triagebot.toml: ping me on changes to `tests/rustdoc-json`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 522c8f7 into rust-lang:master Feb 16, 2025
6 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Feb 16, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 16, 2025
Rollup merge of rust-lang#127581 - fmease:fix-crate_name-validation, r=bjorn3

Fix crate name validation

Reject macro calls inside attribute `#![crate_name]` like in `#![crate_name = concat!("na", "me")]`.

Prior to rust-lang#117584, the result of the expansion (here: `"name"`) would actually be properly picked up by the compiler and used as the crate name. However since rust-lang#117584 / on master, we extract the "value" (i.e., the *literal* string literal) of the `#![crate_name]` much earlier in the pipeline way before macro expansion and **skip**/**ignore** any `#![crate_name]`s "assigned to" a macro call. See also rust-lang#122001.

T-lang has ruled to reject `#![crate_name = MACRO!(...)]` outright very similar to other built-in attributes whose value we need early like `#![crate_type]`. See accepted FCP: rust-lang#122001 (comment).

Note that the check as implemented in this PR is even more "aggressive" compared to the one of `#![crate_type]` by running as early as possible in order to reject `#![crate_name = MACRO!(...)]` even in "non-normal" executions of `rustc`, namely on *print requests* (e.g., `--print=crate-name` and `--print=file-names`). If I were to move the validation step a bit further back close to the `#![crate_type]` one, `--print=crate-name` (etc.) would *not* exit fatally with an error in this kind of situation but happily report an incorrect crate name (i.e., the "crate name" as if `#![crate_name]` didn't exist / deduced from other sources like `--crate-name` or the file name) which would match the behavior on master. Again, see also rust-lang#122001.

I'm mentioning this explicitly because I'm not sure if it was that clear in the FCP'ed issue. I argue that my current approach is the most reasonable one. I know (from reading the code and from past experiments) that various print requests are still quite broken (mostly lack of validation).

To the best of my knowledge, there's no print request whose output references/contains a crate *type*, so there's no "inherent need" to move `#![crate_type]`'s validation to happen earlier.

---

Fixes rust-lang#122001.

https://github.com/rust-lang/rust/labels/relnotes: Compatibility. Breaking change.
@fmease fmease deleted the fix-crate_name-validation branch February 16, 2025 09:52
@cuviper cuviper modified the milestones: 1.86.0, 1.87.0 Feb 16, 2025
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request May 19, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [rust](https://github.com/rust-lang/rust) | minor | `1.86.0` -> `1.87.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>rust-lang/rust (rust)</summary>

### [`v1.87.0`](https://github.com/rust-lang/rust/blob/HEAD/RELEASES.md#Version-1870-2025-05-15)

[Compare Source](rust-lang/rust@1.86.0...1.87.0)

\==========================

<a id="1.87.0-Language"></a>

## Language

-   [Stabilize `asm_goto` feature](rust-lang/rust#133870)
-   [Allow parsing open beginning ranges (`..EXPR`) after unary operators `!`, `-`, and `*`](rust-lang/rust#134900).
-   [Don't require method impls for methods with `Self: Sized` bounds in `impl`s for unsized types](rust-lang/rust#135480)
-   [Stabilize `feature(precise_capturing_in_traits)` allowing `use<...>` bounds on return position `impl Trait` in `trait`s](rust-lang/rust#138128)

<a id="1.87.0-Compiler"></a>

## Compiler

-   [x86: make SSE2 required for i686 targets and use it to pass SIMD types](rust-lang/rust#135408)

<a id="1.87.0-Platform-Support"></a>

## Platform Support

-   [Remove `i586-pc-windows-msvc` target](rust-lang/rust#137957)

Refer to Rust's [platform support page][platform-support-doc]
for more information on Rust's tiered platform support.

[platform-support-doc]: https://doc.rust-lang.org/rustc/platform-support.html

<a id="1.87.0-Libraries"></a>

## Libraries

-   [Stabilize the anonymous pipe API](rust-lang/rust#127154)
-   [Add support for unbounded left/right shift operations](rust-lang/rust#129375)
-   [Print pointer metadata in `Debug` impl of raw pointers](rust-lang/rust#135080)
-   [`Vec::with_capacity` guarantees it allocates with the amount requested, even if `Vec::capacity` returns a different number.](rust-lang/rust#135933)
-   Most `std::arch` intrinsics which don't take pointer arguments can now be called from safe code if the caller has the appropriate target features already enabled (rust-lang/stdarch#1714, rust-lang/stdarch#1716, rust-lang/stdarch#1717)
-   [Undeprecate `env::home_dir`](rust-lang/rust#137327)
-   [Denote `ControlFlow` as `#[must_use]`](rust-lang/rust#137449)
-   [Macros such as `assert_eq!` and `vec!` now support `const {...}` expressions](rust-lang/rust#138162)

<a id="1.87.0-Stabilized-APIs"></a>

## Stabilized APIs

-   [`Vec::extract_if`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.extract_if)
-   [`vec::ExtractIf`](https://doc.rust-lang.org/stable/std/vec/struct.ExtractIf.html)
-   [`LinkedList::extract_if`](https://doc.rust-lang.org/stable/std/collections/struct.LinkedList.html#method.extract_if)
-   [`linked_list::ExtractIf`](https://doc.rust-lang.org/stable/std/collections/linked_list/struct.ExtractIf.html)
-   [`<[T]>::split_off`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_off)
-   [`<[T]>::split_off_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_off_mut)
-   [`<[T]>::split_off_first`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_off_first)
-   [`<[T]>::split_off_first_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_off_first_mut)
-   [`<[T]>::split_off_last`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_off_last)
-   [`<[T]>::split_off_last_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_off_last_mut)
-   [`String::extend_from_within`](https://doc.rust-lang.org/stable/alloc/string/struct.String.html#method.extend_from_within)
-   [`os_str::Display`](https://doc.rust-lang.org/stable/std/ffi/os_str/struct.Display.html)
-   [`OsString::display`](https://doc.rust-lang.org/stable/std/ffi/struct.OsString.html#method.display)
-   [`OsStr::display`](https://doc.rust-lang.org/stable/std/ffi/struct.OsStr.html#method.display)
-   [`io::pipe`](https://doc.rust-lang.org/stable/std/io/fn.pipe.html)
-   [`io::PipeReader`](https://doc.rust-lang.org/stable/std/io/struct.PipeReader.html)
-   [`io::PipeWriter`](https://doc.rust-lang.org/stable/std/io/struct.PipeWriter.html)
-   [`impl From<PipeReader> for OwnedHandle`](https://doc.rust-lang.org/stable/std/os/windows/io/struct.OwnedHandle.html#impl-From%3CPipeReader%3E-for-OwnedHandle)
-   [`impl From<PipeWriter> for OwnedHandle`](https://doc.rust-lang.org/stable/std/os/windows/io/struct.OwnedHandle.html#impl-From%3CPipeWriter%3E-for-OwnedHandle)
-   [`impl From<PipeReader> for Stdio`](https://doc.rust-lang.org/stable/std/process/struct.Stdio.html)
-   [`impl From<PipeWriter> for Stdio`](https://doc.rust-lang.org/stable/std/process/struct.Stdio.html#impl-From%3CPipeWriter%3E-for-Stdio)
-   [`impl From<PipeReader> for OwnedFd`](https://doc.rust-lang.org/stable/std/os/fd/struct.OwnedFd.html#impl-From%3CPipeReader%3E-for-OwnedFd)
-   [`impl From<PipeWriter> for OwnedFd`](https://doc.rust-lang.org/stable/std/os/fd/struct.OwnedFd.html#impl-From%3CPipeWriter%3E-for-OwnedFd)
-   [`Box<MaybeUninit<T>>::write`](https://doc.rust-lang.org/stable/std/boxed/struct.Box.html#method.write)
-   [`impl TryFrom<Vec<u8>> for String`](https://doc.rust-lang.org/stable/std/string/struct.String.html#impl-TryFrom%3CVec%3Cu8%3E%3E-for-String)
-   [`<*const T>::offset_from_unsigned`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.offset_from_unsigned)
-   [`<*const T>::byte_offset_from_unsigned`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.byte_offset_from_unsigned)
-   [`<*mut T>::offset_from_unsigned`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.offset_from_unsigned-1)
-   [`<*mut T>::byte_offset_from_unsigned`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.byte_offset_from_unsigned-1)
-   [`NonNull::offset_from_unsigned`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.offset_from_unsigned)
-   [`NonNull::byte_offset_from_unsigned`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.byte_offset_from_unsigned)
-   [`<uN>::cast_signed`](https://doc.rust-lang.org/stable/std/primitive.usize.html#method.cast_signed)
-   [`NonZero::<uN>::cast_signed`](https://doc.rust-lang.org/stable/std/num/struct.NonZero.html#method.cast_signed-5).
-   [`<iN>::cast_unsigned`](https://doc.rust-lang.org/stable/std/primitive.isize.html#method.cast_unsigned).
-   [`NonZero::<iN>::cast_unsigned`](https://doc.rust-lang.org/stable/std/num/struct.NonZero.html#method.cast_unsigned-5).
-   [`<uN>::is_multiple_of`](https://doc.rust-lang.org/stable/std/primitive.usize.html#method.is_multiple_of)
-   [`<uN>::unbounded_shl`](https://doc.rust-lang.org/stable/std/primitive.usize.html#method.unbounded_shl)
-   [`<uN>::unbounded_shr`](https://doc.rust-lang.org/stable/std/primitive.usize.html#method.unbounded_shr)
-   [`<iN>::unbounded_shl`](https://doc.rust-lang.org/stable/std/primitive.isize.html#method.unbounded_shl)
-   [`<iN>::unbounded_shr`](https://doc.rust-lang.org/stable/std/primitive.isize.html#method.unbounded_shr)
-   [`<iN>::midpoint`](https://doc.rust-lang.org/stable/std/primitive.isize.html#method.midpoint)
-   [`<str>::from_utf8`](https://doc.rust-lang.org/stable/std/primitive.str.html#method.from_utf8)
-   [`<str>::from_utf8_mut`](https://doc.rust-lang.org/stable/std/primitive.str.html#method.from_utf8\_mut)
-   [`<str>::from_utf8_unchecked`](https://doc.rust-lang.org/stable/std/primitive.str.html#method.from_utf8\_unchecked)
-   [`<str>::from_utf8_unchecked_mut`](https://doc.rust-lang.org/stable/std/primitive.str.html#method.from_utf8\_unchecked_mut)

These previously stable APIs are now stable in const contexts:

-   [`core::str::from_utf8_mut`](https://doc.rust-lang.org/stable/std/str/fn.from_utf8\_mut.html)
-   [`<[T]>::copy_from_slice`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.copy_from_slice)
-   [`SocketAddr::set_ip`](https://doc.rust-lang.org/stable/std/net/enum.SocketAddr.html#method.set_ip)
-   [`SocketAddr::set_port`](https://doc.rust-lang.org/stable/std/net/enum.SocketAddr.html#method.set_port),
-   [`SocketAddrV4::set_ip`](https://doc.rust-lang.org/stable/std/net/struct.SocketAddrV4.html#method.set_ip)
-   [`SocketAddrV4::set_port`](https://doc.rust-lang.org/stable/std/net/struct.SocketAddrV4.html#method.set_port),
-   [`SocketAddrV6::set_ip`](https://doc.rust-lang.org/stable/std/net/struct.SocketAddrV6.html#method.set_ip)
-   [`SocketAddrV6::set_port`](https://doc.rust-lang.org/stable/std/net/struct.SocketAddrV6.html#method.set_port)
-   [`SocketAddrV6::set_flowinfo`](https://doc.rust-lang.org/stable/std/net/struct.SocketAddrV6.html#method.set_flowinfo)
-   [`SocketAddrV6::set_scope_id`](https://doc.rust-lang.org/stable/std/net/struct.SocketAddrV6.html#method.set_scope_id)
-   [`char::is_digit`](https://doc.rust-lang.org/stable/std/primitive.char.html#method.is_digit)
-   [`char::is_whitespace`](https://doc.rust-lang.org/stable/std/primitive.char.html#method.is_whitespace)
-   [`<[[T; N]]>::as_flattened`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_flattened)
-   [`<[[T; N]]>::as_flattened_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_flattened_mut)
-   [`String::into_bytes`](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.into_bytes)
-   [`String::as_str`](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.as_str)
-   [`String::capacity`](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.capacity)
-   [`String::as_bytes`](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.as_bytes)
-   [`String::len`](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.len)
-   [`String::is_empty`](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.is_empty)
-   [`String::as_mut_str`](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.as_mut_str)
-   [`String::as_mut_vec`](https://doc.rust-lang.org/stable/std/string/struct.String.html#method.as_mut_vec)
-   [`Vec::as_ptr`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.as_ptr)
-   [`Vec::as_slice`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.as_slice)
-   [`Vec::capacity`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.capacity)
-   [`Vec::len`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.len)
-   [`Vec::is_empty`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.is_empty)
-   [`Vec::as_mut_slice`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.as_mut_slice)
-   [`Vec::as_mut_ptr`](https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.as_mut_ptr)

<a id="1.87.0-Cargo"></a>

## Cargo

-   [Add terminal integration via ANSI OSC 9;4 sequences](rust-lang/cargo#14615)
-   [chore: bump openssl to v3](rust-lang/cargo#15232)
-   [feat(package): add --exclude-lockfile flag](rust-lang/cargo#15234)

<a id="1.87.0-Compatibility-Notes"></a>

## Compatibility Notes

-   [Rust now raises an error for macro invocations inside the `#![crate_name]` attribute](rust-lang/rust#127581)
-   [Unstable fields are now always considered to be inhabited](rust-lang/rust#133889)
-   [Macro arguments of unary operators followed by open beginning ranges may now be matched differently](rust-lang/rust#134900)
-   [Make `Debug` impl of raw pointers print metadata if present](rust-lang/rust#135080)
-   [Warn against function pointers using unsupported ABI strings in dependencies](rust-lang/rust#135767)
-   [Associated types on `dyn` types are no longer deduplicated](rust-lang/rust#136458)
-   [Forbid attributes on `..` inside of struct patterns (`let Struct { #[attribute] .. }) =`](rust-lang/rust#136490)
-   [Make `ptr_cast_add_auto_to_object` lint into hard error](rust-lang/rust#136764)
-   Many `std::arch` intrinsics are now safe to call in some contexts, there may now be new `unused_unsafe` warnings in existing codebases.
-   [Limit `width` and `precision` formatting options to 16 bits on all targets](rust-lang/rust#136932)
-   [Turn order dependent trait objects future incompat warning into a hard error](rust-lang/rust#136968)
-   [Denote `ControlFlow` as `#[must_use]`](rust-lang/rust#137449)
-   [Windows: The standard library no longer links `advapi32`, except on win7.](rust-lang/rust#138233) Code such as C libraries that were relying on this assumption may need to explicitly link advapi32.
-   [Proc macros can no longer observe expanded `cfg(true)` attributes.](rust-lang/rust#138844)
-   [Start changing the internal representation of pasted tokens](rust-lang/rust#124141). Certain invalid declarative macros that were previously accepted in obscure circumstances are now correctly rejected by the compiler. Use of a `tt` fragment specifier can often fix these macros.
-   [Don't allow flattened format_args in const.](rust-lang/rust#139624)

<a id="1.87.0-Internal-Changes"></a>

## Internal Changes

These changes do not affect any public interfaces of Rust, but they represent
significant improvements to the performance or internals of rustc and related
tools.

-   [Update to LLVM 20](rust-lang/rust#135763)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC4xMS4xOSIsInVwZGF0ZWRJblZlciI6IjQwLjExLjE5IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
wip-sync pushed a commit to NetBSD/pkgsrc-wip that referenced this pull request May 20, 2025
Pkgsrc changes:
 * patches adjustments to adapt to upstream changes & new versions
   of included crates
 * associated checksums++

Upstream changes relative to 1.86.0:

Version 1.87.0 (2025-05-15)
==========================

Language
--------
- [Stabilize `asm_goto` feature]
  (rust-lang/rust#133870)
- [Allow parsing open beginning ranges (`..EXPR`) after unary
  operators `!`, `~`, `-`, and `*`}]
  (rust-lang/rust#134900).
- [Don't require method impls for methods with `Self: Sized` bounds
  in `impl`s for unsized types]
  (rust-lang/rust#135480)
- [Stabilize `feature(precise_capturing_in_traits)` allowing
  `use<...>` bounds on return position `impl Trait` in `trait`s]
  (rust-lang/rust#138128)

Compiler
--------
- [x86: make SSE2 required for i686 targets and use it to pass SIMD types]
  (rust-lang/rust#135408)

Platform Support
----------------
- [Remove `i586-pc-windows-msvc` target]
  (rust-lang/rust#137957)

Refer to Rust's [platform support page][platform-support-doc]
for more information on Rust's tiered platform support.

[platform-support-doc]: https://doc.rust-lang.org/rustc/platform-support.html

Libraries
---------
- [Stabilize the anonymous pipe API]
  (rust-lang/rust#127154)
- [Add support for unbounded left/right shift operations]
  (rust-lang/rust#129375)
- [Print pointer metadata in `Debug` impl of raw pointers]
  (rust-lang/rust#135080)
- [`Vec::with_capacity` guarantees it allocates with the amount
  requested, even if `Vec::capacity` returns a different number.]
  (rust-lang/rust#135933)
- Most `std::arch` intrinsics which don't take pointer arguments
  can now be called from safe code if the caller has the appropriate
  target features already enabled
  (rust-lang/stdarch#1714,
  rust-lang/stdarch#1716,
  rust-lang/stdarch#1717)
- [Undeprecate `env::home_dir`]
  (rust-lang/rust#137327)
- [Denote `ControlFlow` as `#[must_use]`]
  (rust-lang/rust#137449)
- [Macros such as `assert_eq!` and `vec!` now support `const {...}` expressions]
  (rust-lang/rust#138162)

Stabilized APIs
---------------

- [`Vec::extract_if`]
  (https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.extract_if)
- [`vec::ExtractIf`]
  (https://doc.rust-lang.org/stable/std/vec/struct.ExtractIf.html)
- [`LinkedList::extract_if`]
  (https://doc.rust-lang.org/stable/std/collections/struct.LinkedList.html#method.extract_if)
- [`linked_list::ExtractIf`]
  (https://doc.rust-lang.org/stable/std/collections/linked_list/struct.ExtractIf.html)
- [`<[T]>::split_off`]
  (https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_off)
- [`<[T]>::split_off_mut`]
  (https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_off_mut)
- [`<[T]>::split_off_first`]
  (https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_off_first)
- [`<[T]>::split_off_first_mut`]
  (https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_off_first_mut)
- [`<[T]>::split_off_last`]
  (https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_off_last)
- [`<[T]>::split_off_last_mut`]
  (https://doc.rust-lang.org/stable/std/primitive.slice.html#method.split_off_last_mut)
- [`String::extend_from_within`]
  (https://doc.rust-lang.org/stable/alloc/string/struct.String.html#method.extend_from_within)
- [`os_str::Display`]
  (https://doc.rust-lang.org/stable/std/ffi/os_str/struct.Display.html)
- [`OsString::display`]
  (https://doc.rust-lang.org/stable/std/ffi/struct.OsString.html#method.display)
- [`OsStr::display`]
  (https://doc.rust-lang.org/stable/std/ffi/struct.OsStr.html#method.display)
- [`io::pipe`]
  (https://doc.rust-lang.org/stable/std/io/fn.pipe.html)
- [`io::PipeReader`]
  (https://doc.rust-lang.org/stable/std/io/struct.PipeReader.html)
- [`io::PipeWriter`]
  (https://doc.rust-lang.org/stable/std/io/struct.PipeWriter.html)
- [`impl From<PipeReader> for OwnedHandle`]
  (https://doc.rust-lang.org/stable/std/os/windows/io/struct.OwnedHandle.html#impl-From%3CPipeReader%3E-for-OwnedHandle)
- [`impl From<PipeWriter> for OwnedHandle`]
  (https://doc.rust-lang.org/stable/std/os/windows/io/struct.OwnedHandle.html#impl-From%3CPipeWriter%3E-for-OwnedHandle)
- [`impl From<PipeReader> for Stdio`]
  (https://doc.rust-lang.org/stable/std/process/struct.Stdio.html)
- [`impl From<PipeWriter> for Stdio`]
  (https://doc.rust-lang.org/stable/std/process/struct.Stdio.html#impl-From%3CPipeWriter%3E-for-Stdio)
- [`impl From<PipeReader> for OwnedFd`]
  (https://doc.rust-lang.org/stable/std/os/fd/struct.OwnedFd.html#impl-From%3CPipeReader%3E-for-OwnedFd)
- [`impl From<PipeWriter> for OwnedFd`]
  (https://doc.rust-lang.org/stable/std/os/fd/struct.OwnedFd.html#impl-From%3CPipeWriter%3E-for-OwnedFd)
- [`Box<MaybeUninit<T>>::write`]
  (https://doc.rust-lang.org/stable/std/boxed/struct.Box.html#method.write)
- [`impl TryFrom<Vec<u8>> for String`]
  (https://doc.rust-lang.org/stable/std/string/struct.String.html#impl-TryFrom%3CVec%3Cu8%3E%3E-for-String)
- [`<*const T>::offset_from_unsigned`]
  (https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.offset_from_unsigned)
- [`<*const T>::byte_offset_from_unsigned`]
  (https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.byte_offset_from_unsigned)
- [`<*mut T>::offset_from_unsigned`]
  (https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.offset_from_unsigned-1)
- [`<*mut T>::byte_offset_from_unsigned`]
  (https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.byte_offset_from_unsigned-1)
- [`NonNull::offset_from_unsigned`]
  (https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.offset_from_unsigned)
- [`NonNull::byte_offset_from_unsigned`]
  (https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.byte_offset_from_unsigned)
- [`<uN>::cast_signed`]
  (https://doc.rust-lang.org/stable/std/primitive.usize.html#method.cast_signed)
- [`NonZero::<uN>::cast_signed`]
  (https://doc.rust-lang.org/stable/std/num/struct.NonZero.html#method.cast_signed-5).
- [`<iN>::cast_unsigned`]
  (https://doc.rust-lang.org/stable/std/primitive.isize.html#method.cast_unsigned).
- [`NonZero::<iN>::cast_unsigned`]
  (https://doc.rust-lang.org/stable/std/num/struct.NonZero.html#method.cast_unsigned-5).
- [`<uN>::is_multiple_of`]
  (https://doc.rust-lang.org/stable/std/primitive.usize.html#method.is_multiple_of)
- [`<uN>::unbounded_shl`]
  (https://doc.rust-lang.org/stable/std/primitive.usize.html#method.unbounded_shl)
- [`<uN>::unbounded_shr`]
  (https://doc.rust-lang.org/stable/std/primitive.usize.html#method.unbounded_shr)
- [`<iN>::unbounded_shl`]
  (https://doc.rust-lang.org/stable/std/primitive.isize.html#method.unbounded_shl)
- [`<iN>::unbounded_shr`]
  (https://doc.rust-lang.org/stable/std/primitive.isize.html#method.unbounded_shr)
- [`<iN>::midpoint`]
  (https://doc.rust-lang.org/stable/std/primitive.isize.html#method.midpoint)
- [`<str>::from_utf8`]
  (https://doc.rust-lang.org/stable/std/primitive.str.html#method.from_utf8)
- [`<str>::from_utf8_mut`]
  (https://doc.rust-lang.org/stable/std/primitive.str.html#method.from_utf8_mut)
- [`<str>::from_utf8_unchecked`]
  (https://doc.rust-lang.org/stable/std/primitive.str.html#method.from_utf8_unchecked)
- [`<str>::from_utf8_unchecked_mut`]
  (https://doc.rust-lang.org/stable/std/primitive.str.html#method.from_utf8_unchecked_mut)

These previously stable APIs are now stable in const contexts:

- [`core::str::from_utf8_mut`]
  (https://doc.rust-lang.org/stable/std/str/fn.from_utf8_mut.html)
- [`<[T]>::copy_from_slice`]
  (https://doc.rust-lang.org/stable/std/primitive.slice.html#method.copy_from_slice)
- [`SocketAddr::set_ip`]
  (https://doc.rust-lang.org/stable/std/net/enum.SocketAddr.html#method.set_ip)
- [`SocketAddr::set_port`]
  (https://doc.rust-lang.org/stable/std/net/enum.SocketAddr.html#method.set_port),
- [`SocketAddrV4::set_ip`]
  (https://doc.rust-lang.org/stable/std/net/struct.SocketAddrV4.html#method.set_ip)
- [`SocketAddrV4::set_port`]
  (https://doc.rust-lang.org/stable/std/net/struct.SocketAddrV4.html#method.set_port),
- [`SocketAddrV6::set_ip`]
  (https://doc.rust-lang.org/stable/std/net/struct.SocketAddrV6.html#method.set_ip)
- [`SocketAddrV6::set_port`]
  (https://doc.rust-lang.org/stable/std/net/struct.SocketAddrV6.html#method.set_port)
- [`SocketAddrV6::set_flowinfo`]
  (https://doc.rust-lang.org/stable/std/net/struct.SocketAddrV6.html#method.set_flowinfo)
- [`SocketAddrV6::set_scope_id`]
  (https://doc.rust-lang.org/stable/std/net/struct.SocketAddrV6.html#method.set_scope_id)
- [`char::is_digit`]
  (https://doc.rust-lang.org/stable/std/primitive.char.html#method.is_digit)
- [`char::is_whitespace`]
  (https://doc.rust-lang.org/stable/std/primitive.char.html#method.is_whitespace)
- [`<[[T; N]]>::as_flattened`]
  (https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_flattened)
- [`<[[T; N]]>::as_flattened_mut`]
  (https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_flattened_mut)
- [`String::into_bytes`]
  (https://doc.rust-lang.org/stable/std/string/struct.String.html#method.into_bytes)
- [`String::as_str`]
  (https://doc.rust-lang.org/stable/std/string/struct.String.html#method.as_str)
- [`String::capacity`]
  (https://doc.rust-lang.org/stable/std/string/struct.String.html#method.capacity)
- [`String::as_bytes`]
  (https://doc.rust-lang.org/stable/std/string/struct.String.html#method.as_bytes)
- [`String::len`]
  (https://doc.rust-lang.org/stable/std/string/struct.String.html#method.len)
- [`String::is_empty`]
  (https://doc.rust-lang.org/stable/std/string/struct.String.html#method.is_empty)
- [`String::as_mut_str`]
  (https://doc.rust-lang.org/stable/std/string/struct.String.html#method.as_mut_str)
- [`String::as_mut_vec`]
  (https://doc.rust-lang.org/stable/std/string/struct.String.html#method.as_mut_vec)
- [`Vec::as_ptr`]
  (https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.as_ptr)
- [`Vec::as_slice`]
  (https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.as_slice)
- [`Vec::capacity`]
  (https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.capacity)
- [`Vec::len`]
  (https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.len)
- [`Vec::is_empty`]
  (https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.is_empty)
- [`Vec::as_mut_slice`]
  (https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.as_mut_slice)
- [`Vec::as_mut_ptr`]
  (https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.as_mut_ptr)

Cargo
-----
- [Add terminal integration via ANSI OSC 9;4 sequences]
  (rust-lang/cargo#14615)
- [chore: bump openssl to v3]
  (rust-lang/cargo#15232)
- [feat(package): add --exclude-lockfile flag]
  (rust-lang/cargo#15234)

Compatibility Notes
-------------------
- [Rust now raises an error for macro invocations inside the
  `#![crate_name]` attribute]
  (rust-lang/rust#127581)
- [Unstable fields are now always considered to be inhabited]
  (rust-lang/rust#133889)
- [Macro arguments of unary operators followed by open beginning
  ranges may now be matched differently]
  (rust-lang/rust#134900)
- [Make `Debug` impl of raw pointers print metadata if present]
  (rust-lang/rust#135080)
- [Warn against function pointers using unsupported ABI strings in dependencies]
  (rust-lang/rust#135767)
- [Associated types on `dyn` types are no longer deduplicated]
  (rust-lang/rust#136458)
- [Forbid attributes on `..` inside of struct patterns (`let Struct
  { #[attribute] .. }) =`]
  (rust-lang/rust#136490)
- [Make `ptr_cast_add_auto_to_object` lint into hard error]
  (rust-lang/rust#136764)
- Many `std::arch` intrinsics are now safe to call in some contexts,
  there may now be new `unused_unsafe` warnings in existing codebases.
- [Limit `width` and `precision` formatting options to 16 bits on all targets]
  (rust-lang/rust#136932)
- [Turn order dependent trait objects future incompat warning into a hard error]
  (rust-lang/rust#136968)
- [Denote `ControlFlow` as `#[must_use]`]
  (rust-lang/rust#137449)
- [Windows: The standard library no longer links `advapi32`, except
  on win7.] (rust-lang/rust#138233)
  Code such as C libraries that were relying on this assumption
  may need to explicitly link advapi32.
- [Proc macros can no longer observe expanded `cfg
  (true)` attributes.](rust-lang/rust#138844)
- [Start changing the internal representation of pasted tokens]
  (rust-lang/rust#124141). Certain invalid
  declarative macros that were previously accepted in obscure
  circumstances are now correctly rejected by the compiler. Use of
  a `tt` fragment specifier can often fix these macros.
- [Don't allow flattened format_args in const.]
  (rust-lang/rust#139624)

Internal Changes
----------------

These changes do not affect any public interfaces of Rust, but they
represent significant improvements to the performance or internals
of rustc and related tools.

- [Update to LLVM 20]
  (rust-lang/rust#135763)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

#![crate_name = EXPR] semantically allows EXPR to be a macro call but otherwise mostly ignores it
7 participants