294792 Commits

Author SHA1 Message Date
Jubilee
bb3a2732ca
Rollup merge of #142585 - rustbot:docs-update, r=ehuss
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)
2025-06-17 00:28:18 -07:00
Jubilee
b27b74f80e
Rollup merge of #142584 - Urgau:span-borrowck-139049, r=fmease
Handle same-crate macro for borrowck semicolon suggestion

Handles https://github.com/rust-lang/rust/pull/142543#discussion_r2149545623

cc ``@m-ou-se``
r? ``@fmease``
2025-06-17 00:28:17 -07:00
Jubilee
d4f23cdc91
Rollup merge of #142570 - jieyouxu:disunion, r=estebank
Reject union default field values

Fixes rust-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
2025-06-17 00:28:17 -07:00
Jubilee
f2e9e2afac
Rollup merge of #142563 - jieyouxu:no-more-i686-mingw, r=mati865
Refine run-make test ignores due to unpredictable `i686-pc-windows-gnu` unwind mechanism

Closes rust-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
2025-06-17 00:28:16 -07:00
Jubilee
725d8291ab
Rollup merge of #142542 - cjgillot:invalidate-simplify-cfg, r=SparrowLii
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.
2025-06-17 00:28:16 -07:00
Jubilee
a2a767a5c7
Rollup merge of #142216 - nealsid:refcell-logging, r=tgross35
Miscellaneous RefCell cleanups

- Clarify `RefCell` error messages when borrow rules are broken
- Remove `Debug` impl for `BorrowError`/`BorrowMutError` since `#derive(Debug)` provides identical functionality
- Rename `BorrowFlag` to `BorrowCounter`
2025-06-17 00:28:15 -07:00
Jubilee
94ce4b5aa1
Rollup merge of #141946 - xizheyin:141933, r=jhpratt
std: refactor explanation of `NonNull`

Fixes rust-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`
2025-06-17 00:28:14 -07:00
Jubilee
346adcef4f
Rollup merge of #138538 - hkBst:patch-4, r=tgross35
Make performance description of String::{insert,insert_str,remove} more precise
2025-06-17 00:28:13 -07:00
Marijn Schouten
0348a4a717 Make performance of String::insert_str more precise 2025-06-17 06:04:04 +00:00
Jieyou Xu
aa8c6f83b6
Don't match on platform-specific directory not found message 2025-06-17 10:53:11 +08:00
Jieyou Xu
1dbedaf405
Refine run-make test ignores due to unpredictable i686-pc-windows-gnu unwind mechanism 2025-06-17 10:49:28 +08:00
Jieyou Xu
2dd9cc1130
Reject union default field values 2025-06-17 07:27:58 +08:00
bors
55d436467c Auto merge of #142447 - dianqk:llvm-20.1.7, r=nikic
Update to LLVM 20.1.7

Closes rust-lang/rust#141306, closes rust-lang/rust#140686, closes rust-lang/rust#141737, closes rust-lang/rust#140933.
2025-06-16 22:33:38 +00:00
bors
45acf54eea Auto merge of #142589 - Kobzol:rollup-j90fk2j, r=Kobzol
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
2025-06-16 18:20:05 +00:00
Urgau
994794a50b Handle same-crate macro for borrowck semicolon suggestion 2025-06-16 19:58:01 +02:00
Jakub Beránek
b1ba2cdf41
Rollup merge of #142573 - lcnr:search_graph-3, r=lqd
`fn candidate_is_applicable` to method

r? `@BoxyUwU`
2025-06-16 19:54:37 +02:00
Jakub Beránek
a53c1d7c99
Rollup merge of #142565 - bjorn3:wasm32_unknown_naked_asm_test, r=RalfJung
Test naked asm for wasm32-unknown-unknown

cc https://github.com/rust-lang/rust/pull/133952#discussion_r2148924872
2025-06-16 19:54:36 +02:00
Jakub Beránek
15751b4589
Rollup merge of #142562 - tgross35:update-backtrace, r=workingjubilee
Update the `backtrace` submodule

Pick up the following pull requests:

* ci: remove binary size check (not relevant in rust-lang/rust) <https://github.com/rust-lang/backtrace-rs/pull/710>
* Upgrade `ruzstd`, `object`, and `addr2line` to the latest versions <https://github.com/rust-lang/backtrace-rs/pull/718>
2025-06-16 19:54:36 +02:00
Jakub Beránek
d1ed469d26
Rollup merge of #142554 - nnethercote:fix-PathSource-lifetimes, r=petrochenkov
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`
2025-06-16 19:54:35 +02:00
Jakub Beránek
1e950ef1b2
Rollup merge of #142498 - GrigorenkoPV:as-ptr-refactor, r=jdonszelmann
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.
2025-06-16 19:54:34 +02:00
Jakub Beránek
e83ca067f5
Rollup merge of #142414 - folkertdev:ignore-nostd-tests, r=jieyouxu
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>
2025-06-16 19:54:34 +02:00
Jakub Beránek
d68432a1a9
Rollup merge of #142341 - xizheyin:142311, r=fee1-dead
Don't suggest converting `///` to `//` when expecting `,`

Fixes rust-lang/rust#142311
2025-06-16 19:54:33 +02:00
Jakub Beránek
4479d42d60
Rollup merge of #139340 - beetrees:riscv-float-struct-abi, r=workingjubilee
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`
2025-06-16 19:54:32 +02:00
rustbot
7cfc51bd50 Update books 2025-06-16 19:00:49 +02:00
Neal
2fca05a378 Rename BorrowFlag type to BorrowCounter
It's actually used as a counter so update the name to reflect that.
2025-06-16 11:24:38 -04:00
Neal
718df66f4f Two changes: Have BorrowError & BorrowMutError derive Debug and add
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.
2025-06-16 11:24:38 -04:00
Pavel Grigorenko
da8d6bbd50 Port #[rustc_as_ptr] to the new attribute system 2025-06-16 18:13:27 +03:00
xizheyin
c63665cd73 Dont suggest converting /// to regular comment when it appears after missing , in list
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-16 23:07:11 +08:00
bors
3bc767e1a2 Auto merge of #142574 - Kobzol:rollup-ldj386u, r=Kobzol
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#141639 (Expose discriminant values in stable_mir)
 - rust-lang/rust#142082 (Refactor `rustc_attr_data_structures` documentation)
 - rust-lang/rust#142125 (Stabilize "file_lock" feature)
 - rust-lang/rust#142236 (Add documentation for `PathBuf`'s `FromIterator` and `Extend` impls)
 - rust-lang/rust#142373 (Fix Debug for Location)
 - rust-lang/rust#142416 (Assorted bootstrap cleanups (step 2))
 - rust-lang/rust#142431 (Add initial version of snapshot tests to bootstrap)
 - rust-lang/rust#142450 (Add documentation on top of `rustc_middle/src/query/mod.rs`)
 - rust-lang/rust#142528 (clarify `rustc_do_not_const_check` comment)
 - rust-lang/rust#142530 (use `if let` guards where possible)
 - rust-lang/rust#142561 (Remove an `njn:` comment accidentaly left behind.)
 - rust-lang/rust#142566 (Fix `-nopt` CI jobs)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-16 14:25:08 +00:00
Camille GILLOT
a2d96875a5 Add comment. 2025-06-16 12:31:36 +00:00
Jakub Beránek
78d12b7e56
Rollup merge of #142566 - Kobzol:ci-nopt-fix, r=jieyouxu
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`
2025-06-16 14:31:15 +02:00
Jakub Beránek
f1dd5fb56e
Rollup merge of #142561 - nnethercote:fix-njn-comment, r=chenyukang
Remove an `njn:` comment accidentaly left behind.

r? `@chenyukang`
2025-06-16 14:31:14 +02:00
Jakub Beránek
1a56184460
Rollup merge of #142530 - fee1-dead-contrib:push-klusvwusyqvq, r=compiler-errors
use `if let` guards where possible

these crates already enable the feature
2025-06-16 14:31:14 +02:00
Jakub Beránek
dc16682824
Rollup merge of #142528 - fee1-dead-contrib:push-rlxklunqkwmv, r=RalfJung
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```
2025-06-16 14:31:13 +02:00
Jakub Beránek
2c4abc0f45
Rollup merge of #142450 - xizheyin:rustc-query-doc, r=SparrowLii
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.
2025-06-16 14:31:12 +02:00
Jakub Beránek
e036a564e4
Rollup merge of #142431 - Kobzol:bootstrap-snapshot-tests, r=jieyouxu
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``
2025-06-16 14:31:12 +02:00
Jakub Beránek
ac8a48dad2
Rollup merge of #142416 - Kobzol:bootstrap-cleanup-2, 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``
2025-06-16 14:31:11 +02:00
Jakub Beránek
d9c83bb033
Rollup merge of #142373 - m-ou-se:debug-for-location, r=tgross35
Fix Debug for Location

Fixes https://github.com/rust-lang/rust/issues/142279
2025-06-16 14:31:11 +02:00
Jakub Beránek
6092c1a074
Rollup merge of #142236 - yotamofek:pr/std/pathbuf-extend-docs, r=tgross35
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 :)
2025-06-16 14:31:10 +02:00
Jakub Beránek
c4e11743b2
Rollup merge of #142125 - cberner:file_lock_stable, r=ChrisDenton
Stabilize "file_lock" feature

Closes https://github.com/rust-lang/rust/issues/130994

r? ```@joshtriplett```
2025-06-16 14:31:10 +02:00
Jakub Beránek
3795658357
Rollup merge of #142082 - xizheyin:rustc_attr_data_structures, r=jdonszelmann
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```
2025-06-16 14:31:09 +02:00
Jakub Beránek
34160872f2
Rollup merge of #141639 - NotLebedev:stable-mir-93, r=oli-obk
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`
2025-06-16 14:31:08 +02:00
lcnr
7fb9284fb3 candidate_is_applicable to method 2025-06-16 14:01:01 +02:00
bors
d9ca9bd014 Auto merge of #142556 - RalfJung:miri-sync, r=RalfJung
Miri subtree update

r? `@ghost`
2025-06-16 11:25:56 +00:00
Jieyou Xu
32c0cb0f5a
Add union with default field values case test
In particular, there should be no additional errors (default field
values for `union` fields are currently erroneously accepted).
2025-06-16 17:54:13 +08:00
beetrees
5723c9997c
Fix RISC-V C function ABI when passing/returning structs containing floats 2025-06-16 10:14:07 +01:00
Jakub Beránek
743c2a4c71
Fix -nopt CI jobs
They were using `--config` instead of `--set`, which overrides too much stuff.
2025-06-16 10:28:55 +02:00
bjorn3
d28fabeb6c Test naked asm for wasm32-unknown-unknown 2025-06-16 08:26:17 +00:00
NotLebedev
9505b6e914
Fix test description 2025-06-16 10:51:59 +03:00
NotLebedev
4fc768e097
Add test for AdtDef::discriminant_for_variant polymorphic over parameter 2025-06-16 10:51:59 +03:00