Update books
## rust-lang/book
1 commits in 634724ea85ebb08a542970bf8871ac8b0f77fd15..4433c9f0cad8460bee05ede040587f8a1fa3f1de
2025-06-03 16:34:00 UTC to 2025-06-03 16:34:00 UTC
- Chapter 11 from tech review (rust-lang/book#4391)
## rust-lang/reference
10 commits in 8e0f593a30f3b56ddb0908fb7ab9249974e08738..d4c66b346f4b72d29e70390a3fa3ea7d4e064db1
2025-06-13 17:05:11 UTC to 2025-06-03 21:28:42 UTC
- Align pattern destructuring with rest of patterns documentation (rust-lang/reference#1853)
- Use extern "system" instead of "stdcall" in example (rust-lang/reference#1854)
- Mention that `thiscall` is a 32-bit calling convention (rust-lang/reference#1855)
- Add doc for keylocker target features (rust-lang/reference#1829)
- Add doc for `sha512`, `sm3` and `sm4` target features (rust-lang/reference#1830)
- Fix(typo): 'though' should be 'through' (rust-lang/reference#1850)
- intro note: make text more simple (rust-lang/reference#1844)
- nit: add missing period (rust-lang/reference#1843)
- add a warning about using `safe` on extern c-variadic functions (rust-lang/reference#1839)
- remove the `safe` keyword from a c-variadic foreign function. (rust-lang/reference#1838)
## rust-lang/rust-by-example
3 commits in 21f4e32b8b40d36453fae16ec07ad4b857c445b6..9baa9e863116cb9524a177d5a5c475baac18928a
2025-06-11 13:00:27 UTC to 2025-06-10 12:43:14 UTC
- introduce new ``@media`` query to set a higher content width on ultra wide screens (rust-lang/rust-by-example#1937)
- Fix syntax highligting (rust-lang/rust-by-example#1935)
- fix(rust-lang/rust#1656): update doc tests to use `playground` as the crate name (rust-lang/rust-by-example#1934)
Reject union default field values
Fixesrust-lang/rust#142555.
The [`default_field_values` RFC][rfc] does not specify that default field values may be used on `union`s, and it's not clear how default field values may be used with `union`s without an design extension to the RFC. So, for now, reject trying to use default field values with `union`s.
### Review notes
- The first commit adds the `union` with default field values test case to `tests/ui/structs/default-field-values/failures.rs`, where `union`s with default field values are currently accepted.
- The second commit rejects trying to supply default field values to `union` definitions.
- When `default_field_values` feature gate is disabled, we show the feature gate error when the user tries to write `union`s with default field values. When the feature gate is enabled, we reject this usage with
> unions cannot have default field values
``@rustbot`` label: +F-default_field_values
[rfc]: https://rust-lang.github.io/rfcs/3681-default-field-values.html
Refine run-make test ignores due to unpredictable `i686-pc-windows-gnu` unwind mechanism
Closesrust-lang/rust#128911. This PR *re-enables* the `dump-ice-to-disk` test and the unstable feature usage metrics tests for {x86_64,i686} Windows MSVC hosts and x86_64 Windows GNU host. I'll keep an eye out for these tests, and will broaden the ignores if this test is still flaky on not just `i686-pc-windows-gnu`.
r? mati865
try-job: x86_64-msvc-1
try-job: i686-msvc-1
try-job: x86_64-mingw-1
Manually invalidate caches in SimplifyCfg.
The current `SimplifyCfg` pass unconditionally invalidates CFG caches. This is unfortunate if there are no modifications that require this invalidation.
std: refactor explanation of `NonNull`
Fixesrust-lang/rust#141933
I cut out the excessive explanation and used an example to explain how to maintain invariance, but I think what is quoted in the *rust reference* in the document needs to be added with a more layman's explanation and example.
(I'm not sure if I deleted too much)
r? `@workingjubilee`
Rollup of 8 pull requests
Successful merges:
- rust-lang/rust#139340 (Fix RISC-V C function ABI when passing/returning structs containing floats)
- rust-lang/rust#142341 (Don't suggest converting `///` to `//` when expecting `,`)
- rust-lang/rust#142414 (ignore `run-make` tests that need `std` on targets without `std`)
- rust-lang/rust#142498 (Port `#[rustc_as_ptr]` to the new attribute system)
- rust-lang/rust#142554 (Fix `PathSource` lifetimes.)
- rust-lang/rust#142562 (Update the `backtrace` submodule)
- rust-lang/rust#142565 (Test naked asm for wasm32-unknown-unknown)
- rust-lang/rust#142573 (`fn candidate_is_applicable` to method)
r? `@ghost`
`@rustbot` modify labels: rollup
Fix `PathSource` lifetimes.
It currently has two, which don't accurately capture what's happening -- the `TupleStruct` spans are allocated in `ResolverArenas`, which is different to where the `Expr` is allocated -- and require some "outlives" constraints to be used.
This commit adds another lifetime, renames the existing ones, and removes the "outlives" constraints.
r? `@petrochenkov`
Port `#[rustc_as_ptr]` to the new attribute system
It might make sense to introduce some new parser analogous to `Single`, but even more simple: for parsing attributes that take no arguments and may appear only once (such as `#[rustc_as_ptr]` or `#[rustc_const_stable_indirect]`). Not sure if this should be a single `impl` parsing all such attributes, or one impl per attribute. Or how it will play along with the upcoming rework of attribute validation. Or how these argumentless attributes should be called (I've loosely referred to them as `markers` in the name of the new module in this PR, but not sure how good it is).
This is a part of rust-lang/rust#131229, so
r? `@jdonszelmann`
---
For reference, the `#[rustc_as_ptr]` attribute was created back in rust-lang/rust#132732 as a followup to rust-lang/rust#128985.
ignore `run-make` tests that need `std` on targets without `std`
In particular, anything that includes `none` in the target triple, and `nvptx64-nvidia-cuda`. Right now we don't cross-compile the `run-make` tests, but we want to in the future.
This uses `//@ needs-target-std` introduced in https://github.com/rust-lang/rust/pull/142297.
Useful for https://github.com/rust-lang/rust/pull/139244 and https://github.com/rust-lang/rust/pull/141856.
The modified files are based on running https://github.com/rust-lang/rust/pull/141856 locally. It might be that https://github.com/rust-lang/rust/pull/139244 uncovers some additional files, but that PR needs to be rebased (though actually I'd advice to rebase the non-test changes onto this PR, probably faster that way).
r? ``@jieyouxu``
<details>
<summary>vim notes for future me</summary>
Make a file with lines like this
```
/home/folkertdev/rust/rust/tests/run-make/export/disambiguator/rmake.rs:1:1
/home/folkertdev/rust/rust/tests/run-make/invalid-so/rmake.rs:1:1
/home/folkertdev/rust/rust/tests/run-make/no-builtins-attribute/rmake.rs:1:1
/home/folkertdev/rust/rust/tests/run-make/export/extern-opt/rmake.rs:1:1
/home/folkertdev/rust/rust/tests/run-make/link-dedup/rmake.rs:1:1
```
then
```
:set errorformat=%f:%l:%c
:cfile /tmp/files-to-fix.txt
```
```
:copen
:cnext
:cprev
```
are your friends
</details>
Fix RISC-V C function ABI when passing/returning structs containing floats
RISC-V passes structs containing only one or two floats (or a float and integer pair) in registers, as long as the individual floats/integers fit in a single corresponding register (see [the ABI specification](https://github.com/riscv-non-isa/riscv-elf-psabi-doc/releases/download/v1.0/riscv-abi.pdf) for details). Before this PR, Rust would not check what offset the second float/integer was at, instead assuming that it was at the standard offset for its default alignment. However, as the offset can be affected by `#[repr(align(N))]` and `#[repr(packed)]`, this caused miscompilations (see #115609). To fix this, this PR introduces a `rest_offset` field to `CastTarget` that can be used to explicitly specify at what offset the `rest` part of the cast is located at.
While fixing this, I discovered another bug: the size of the cast target was being used as the size of the MIR return place (when the function was using a `PassMode::Cast` return type). However, the cast target is allowed to be smaller than the size of the actual type, causing a miscompilation. This PR fixes this issue by using the largest of the size of the type and the size of the cast target as the size of the MIR return place, ensuring all reads/writes will be inbounds.
Fixes the RISC-V part of #115609.
cc target maintainers of `riscv64gc-unknown-linux-gnu`: `@kito-cheng` `@michaelmaitland` `@robin-randhawa-sifive` `@topperc`
r? `@workingjubilee`
more information to Display implementation for BorrowError/BorrowMutError
- The BorrowError/BorrowMutError Debug implementations do not print
anything differently from what the derived implementation does, so we
don't need it.
- This change also adds the location field of
BorrowError/BorrowMutError to the the Display output when it is
present, rewords the error message, and uses the Display trait for
outputting the error message instead of Debug.
Fix `-nopt` CI jobs
They were using `--config` instead of `--set`, which overrides too much stuff after recent changes to config merging.
Should hopefully unblock https://github.com/rust-lang/rust/pull/142447.
r? `@jieyouxu`
clarify `rustc_do_not_const_check` comment
~~Given that we have used this attribute for other reasons before it seems appropriate to make this a "usually".~~
Add function name as a pointer
cc ```@rust-lang/wg-const-eval```
Add documentation on top of `rustc_middle/src/query/mod.rs`
The `rustc-dev-guide` gives a high-level intro, but many details—especially about how the code works and modifiers in `query xxx(){...}`—are only in code comments or the macro implementation. This doc makes it easier for contributors and code readers to understand the workflow and available modifiers without jumping between files and docs.
This PR adds a comprehensive module-level doc comment to `rustc_middle::query::mod.rs` that:
1. Provides an overview of the query system and macro-based query definitions for reading code more easily
2. Centralizes documentation for all query modifiers (previously scattered or only in `rustc_macro` code), closely following the authoritative list in QueryModifiers.
Add initial version of snapshot tests to bootstrap
When making any changes to bootstrap (steps), it is very difficult to realize how does it affect various common bootstrap commands, and if everything still works as we expect it to. We are far away from having actual end-to-end tests, but what we could at least do is have a way of testing what steps does bootstrap execute in dry run mode. Now, we already have something like this in `src/bootstrap/src/core/builder/tests.rs`, however that is quite limited, because it only checks executed steps for a specific impl of `Step` and it does not consider step order.
Recently, when working on what I thought was one of the simplest possible step untanglings in bootstrap (https://github.com/rust-lang/rust/pull/142357), I ran into errors in tests that were quite hard to debug. Partly also because the current staging test diffs are multiline and use `Debug` output, so it's quite difficult for me to make sense of them.
In this PR, I introduce `insta`, which allows writing snapshot tests in a very simple way. With it, I want to allow writing tests that will clearly show us what is going on during bootstrap execution, and then write golden tests for `build/check/test` stage `0/1/2` for compiler/std/tools etc., to make sure that we don't regress something, and also to help with [#t-infra/bootstrap > Proposal to cleanup stages and steps after the redesign](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Proposal.20to.20cleanup.20stages.20and.20steps.20after.20the.20redesign/with/523488806), to help avoid a situation where we would (again) have to make a flurry of staging changes because of unexpected consequences.
In the snapshot tests, we currently render the build of rustc, std and LLVM. Currently I render the executed steps using downcasting, which is not super pretty, but it allows us to make the test rendering localized in one place, and it's IMO enough for now.
I implemented only a single test using the new machinery. Maybe if you take a look at it, you will understand why 😆 Bootstrap currently does some peculiar things, such as running a stage 0 std step (even though stage 0 std no longer exists) and running the Rustc stage 0 -> 1 step twice, once with a single crates, once with all rustc crates. So I think that even with this single step, there will be a bunch of things to fix in the near future...
The way we currently prepare the Config test fixtures is far from ideal, this is something I think ``@Shourya742`` could work on as a part of their GSoC project (remove as much command execution from Config construction as possible, actually run bootstrap on a temporary directory instead of running it on the rustc checkout, create a Builder-like API for creating the Config test fixtures).
r? ``@jieyouxu``
Assorted bootstrap cleanups (step 2)
Very small improvements designed towards making bootstrap tests less hacky/special, and towards making it possible to run bootstrap tests in parallel.
Best reviewed commit by commit.
r? ``@jieyouxu``
Add documentation for `PathBuf`'s `FromIterator` and `Extend` impls
I think it's not very obvious that `PathBuf`'s `Extend` and `FromIterator` impls work like `PathBuf::push`, so I think these should be documented.
I'm not very happy with the wording and examples, open to suggestions :)
Refactor `rustc_attr_data_structures` documentation
I was reading through `AttributeKind` and realized that attributes like `InlineAttr` didn't appear in it, however, I found them in `rustc_codegen_ssa` and understood why (guessing).
There's almost no overall documentation for this crate, I've added the organized documentation at the top of `lib.rs`, and I've grouped the Attributes into two categories: `AttributeKind` that run all through the compiler, and the ones that are only used in `codegen_ssa`, such as `InlineAttr`, `OptimizeAttr`, `InstructionSetAttr`.
Also, I've added documentation for `AttributeKind` that further explains why attributes like `InlineAttr` don't appear in it, with examples for each variant.
r? ```@jdonszelmann```
Expose discriminant values in stable_mir
Resolves https://github.com/rust-lang/project-stable-mir/issues/93
* Added `Discr` struct to stable mir as stable version of struct with same name
* Added `discriminant_for_variant` method to `AdtDef` and `CoroutineDef`