Commit graph

288613 commits

Author SHA1 Message Date
Xinglu Chen
2107793ebe Use "accessed" instead of "initialized" in LocationState 2025-05-30 14:39:26 +02:00
Xinglu Chen
089acfaeb4 Track permissions on the byte-level
Co-authored-by: Ralf Jung <post@ralfj.de>
Co-authored-by: Johannes Hostert <jhostert@ethz.ch>
2025-05-30 14:39:26 +02:00
Ralf Jung
4b8f88b251
Merge pull request #4310 from RalfJung/addr-space-conservation
alloc_addresses: when we are running out of addresses, start reusing more aggressively
2025-05-05 13:11:48 +00:00
Ralf Jung
84b3142e27
Merge pull request #4309 from RalfJung/both-borrows-tests
move tests that are identical between SB and TB to shared files
2025-05-05 13:10:12 +00:00
Ralf Jung
5c7f1d76cb alloc_addresses: when we are running out of addresses, start reusing more aggressively 2025-05-05 14:46:45 +02:00
Ralf Jung
aec861b5ae consistent folder naming: stacked-borrows -> stacked_borrows 2025-05-05 14:44:37 +02:00
Ralf Jung
70ef2504b9
Merge pull request #4306 from yoctocell/fix-unsafecell-inside-box
Tree Borrows: Correctly handle interior mutable data in `Box`
2025-05-05 11:58:34 +00:00
Ralf Jung
3f0d24ad4c move tests that are identical between SB and TB to shared files 2025-05-05 13:49:18 +02:00
Ralf Jung
f8a8bbd4c0
Merge pull request #4307 from JoJoDeveloping/remove-unique-is-unique
Remove -Zunique-is-unique
2025-05-05 06:47:59 +00:00
Johannes Hostert
30ecac8f74
Remove -Zunique-is-unique 2025-05-04 18:48:51 +02:00
Oli Scherer
d313405db4
Merge pull request #4308 from rust-lang/rustup-2025-05-03
Automatic Rustup
2025-05-03 07:57:33 +00:00
The Miri Cronjob Bot
4d873493ad Merge from rustc 2025-05-03 05:00:21 +00:00
The Miri Cronjob Bot
8a166dc194 Preparing for merge from rustc 2025-05-03 04:53:15 +00:00
bors
2ad5f8607d Auto merge of #140442 - osiewicz:collector-walk-less-fine-grained-locking, r=wesleywiser
mono collector: Reduce # of locking while walking the graph

While profiling Zed's dev build I've noticed that while most of the time `upstream_monomorphizations` takes a lot of time in monomorpization_collector, in some cases (e.g. build of `editor` itself) the rest of monomorphization_collector_graph_walk dominates it. Most of the time is spent in collect_items_rec.

This PR aims to reduce the number of locks taking place; instead of locking output MonoItems once per children of current node, we do so once per *current node*. We also get to reuse locks for mentioned and used items. While this commit does not reduce Wall time of Zed's build, it does shave off CPU time (measured with `cargo build -j1`) from 48s to 47s. I've also tested it with parallel frontend against Zed and ripgrep and found no regressions.
2025-05-03 00:24:14 +00:00
bors
2d5ffc513f Auto merge of #140596 - matthiaskrgr:rollup-s7tzr34, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #140485 (Optimize the codegen for `Span::from_expansion`)
 - #140509 (transmutability: merge contiguous runs with a common destination)
 - #140519 (Use select in projection lookup in `report_projection_error`)
 - #140521 (interpret: better error message for out-of-bounds pointer arithmetic and accesses)
 - #140536 (Rename `*Guard::try_map` to `filter_map`.)
 - #140550 (Stabilize `select_unpredictable`)
 - #140563 (extend the list of registered dylibs on `test::prepare_cargo_test`)
 - #140572 (Add useful comments on `ExprKind::If` variants.)
 - #140574 (Add regression test for 133065)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-02 20:59:24 +00:00
Xinglu Chen
45d4bb2541 Construct test so that it would fail for old code 2025-05-02 19:56:45 +02:00
Matthias Krüger
6f7f3cec4f
Rollup merge of #140574 - reddevilmidzy:add-test, r=compiler-errors
Add regression test for 133065

closes: #133065
2025-05-02 19:38:01 +02:00
Matthias Krüger
bcf2490c64
Rollup merge of #140572 - nnethercote:comment-ExprKind-If, r=compiler-errors
Add useful comments on `ExprKind::If` variants.

Things that aren't obvious and took me a while to work out.

r? `@BoxyUwU`
2025-05-02 19:38:00 +02:00
Matthias Krüger
bfb8f73933
Rollup merge of #140563 - onur-ozkan:extend-dylib-paths, r=jieyouxu
extend the list of registered dylibs on `test::prepare_cargo_test`

self-explanatory

Fixes #140299
2025-05-02 19:37:59 +02:00
Matthias Krüger
15f21f43b3
Rollup merge of #140550 - Amanieu:stabilize_select_unpredictable, r=workingjubilee
Stabilize `select_unpredictable`

FCP completed in tracking issue #133962.
2025-05-02 19:37:59 +02:00
Matthias Krüger
06599db9c1
Rollup merge of #140536 - zachs18:mapped-guard-filter-map, r=Amanieu
Rename `*Guard::try_map` to `filter_map`.

Rename `std::sync::*Guard::try_map` to `filter_map`.

1. Analogous to `std::cell::Ref(Mut)::filter_map`.
2. Doesn't imply `Try` genericizability.

r? `@Amanieu` (or other T-libs-api)

Tracking issue for `mapped_lock_guards`: https://github.com/rust-lang/rust/issues/117108
2025-05-02 19:37:58 +02:00
Matthias Krüger
c796ef00f8
Rollup merge of #140521 - RalfJung:oob-error, r=saethlin
interpret: better error message for out-of-bounds pointer arithmetic and accesses

Fixes https://github.com/rust-lang/rust/issues/93881
r? `@saethlin`
2025-05-02 19:37:58 +02:00
Matthias Krüger
296733d5ac
Rollup merge of #140519 - compiler-errors:name-based-comparison, r=oli-obk
Use select in projection lookup in `report_projection_error`

Using `for_each_relevant_impl` doesn't actually select the correct impl; we can use `select` here to actually get the correct impl with certainty. Follow-up to https://github.com/rust-lang/rust/pull/140278.

r? oli-obk
2025-05-02 19:37:57 +02:00
Matthias Krüger
429341b445
Rollup merge of #140509 - tmiasko:merge-contiguous-ranges, r=jswrenn
transmutability: merge contiguous runs with a common destination

Based on #140380.

r? `@jswrenn` `@joshlf`
2025-05-02 19:37:56 +02:00
Matthias Krüger
a2ae171b97
Rollup merge of #140485 - Jarcho:from_expansion_opt, r=petrochenkov
Optimize the codegen for `Span::from_expansion`

See https://godbolt.org/z/bq65Y6bc4 for the difference. the new version is less than half the number of instructions.

Also tried fully writing the function by hand:
```rust
sp.ctxt_or_parent_or_marker != 0
        && (
            sp.len_with_tag_or_marker == BASE_LEN_INTERNED_MARKER
            || sp.len_with_tag_or_marker & PARENT_TAG == 0
        )
```

But that was no better than this PR's current use of `match_span_kind`.
2025-05-02 19:37:56 +02:00
bors
4824c2bb74 Auto merge of #140406 - Urgau:autorefs-perf, r=nnethercote
perf: delay checking of `#[rustc_no_implicit_autorefs]` in autoref lint

Try to address the regression seen in https://github.com/rust-lang/rust/pull/123239#issuecomment-2835418470 by delaying the checking of `#[rustc_no_implicit_autorefs]` on method call.
2025-05-02 17:35:50 +00:00
Xinglu Chen
8b3637635b Correctly handle interior mutable data in Box
Previously, the pointee type would be behind a `*const` pointer, so
`ty_is_freeze` would always be `true`, even if there was an
`UnsafeCell` in `Box`.
2025-05-02 18:30:24 +02:00
bors
7c96085b64 Auto merge of #140581 - Zalathar:rollup-ig2jb9v, r=Zalathar
Rollup of 12 pull requests

Successful merges:

 - #134034 (handle paren in macro expand for let-init-else expr)
 - #137474 (pretty-print: Print shebang at the top of the output)
 - #138872 (rustc_target: RISC-V `Zfinx` is incompatible with `{ILP32,LP64}[FD]` ABIs)
 - #139046 (Improve `Lifetime::suggestion`)
 - #139206 (std: use the address of `errno` to identify threads in `unique_thread_exit`)
 - #139608 (Clarify `async` block behaviour)
 - #139847 (Delegate to inner `vec::IntoIter` from `env::ArgsOs`)
 - #140159 (Avoid redundant WTF-8 checks in `PathBuf`)
 - #140197 (Document breaking out of a named code block)
 - #140389 (Remove `avx512dq` and `avx512vl` implication for `avx512fp16`)
 - #140430 (Improve test coverage of HIR pretty printing.)
 - #140507 (rustc_target: RISC-V: feature addition batch 3)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-02 13:54:16 +00:00
Ralf Jung
023854875c
Merge pull request #4291 from Patrick-6/miri-genmc-prep
GenMC implementation initial changes
2025-05-02 13:14:36 +00:00
Patrick-6
d940d0b758 Implement skeleton code for adding GenMC support to Miri (not yet functional).
- Add a cargo feature to enable GenMC support (off by default)
- Add support for GenMC datastructures to MiriMachine
- Adjust several functions where GenMC needs to be informed about relevant events (e.g., atomic accesses)
- Add skeleton code for parsing GenMC command line arguments
- Some cleanup
  - Finish sentences with a `.`
  - Fix some spelling errors/typos

Co-authored-by: Ralf Jung <post@ralfj.de>
2025-05-02 14:49:17 +02:00
Stuart Cook
19c9b763ba
Rollup merge of #140507 - a4lg:riscv-feature-addition-batch-3, r=Amanieu
rustc_target: RISC-V: feature addition batch 3

This is the last batch (3 of 3) for RISC-V feature enhancements intended for the version 1.88 cycle.

The author's primary criteria are:

1.  The extension is ratified and unprivileged one.
2.  The extension is in the RVA23U64 profile (to be a baseline of the application-class RISC-V software ecosystem in the near future), either mandatory or optional.
3.  Either:
    1.  To be discoverable through a `riscv_hwprobe` system call on (currently unreleased) Linux 6.15 (as of rc4) or
    2.  Helps memory/atomics-related operations more efficient and/or more robust.

This is based on the specifications:

*   [The latest ratified ISA Manuals (version 20240411)](https://lf-riscv.atlassian.net/wiki/spaces/HOME/pages/16154769/RISC-V+Technical+Specifications)
*   [RVA23/RVB23 profiles](https://github.com/riscv/riscv-profiles/releases/tag/rva23-rvb23-ratified)
*   [RISC-V BF16 extensions](https://github.com/riscv/riscv-bfloat16/releases/tag/v183a3dac863d7c18187a739eb52b0c8f0d16854d)

LLVM Definitions:

*   [`Zicbop`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L82-87)
*   [`Zicbom`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L75-L80)
*   [`Zic64b`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L71-L73)
*   [`Ziccamoa`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L97-L99)
*   [`Ziccif`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L101-L103)
*   [`Zicclsm`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L105-L107)
*   [`Ziccrse`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L109-L111)
*   [`Zfbfmin`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L320-L325)
*   [`Zvfbfmin`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L697-L702)
*   [`Zvfbfwma`](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/RISCV/RISCVFeatures.td#L704-L710)

The `Zicbop` extension (mandatory in RVA23U64) adds prefetch hints to prepare for subsequent memory operations (will be executed as no-op if the hardware does not support this extension).

The `Zicbom` extension (mandatory in RVA23U64) adds cache block-management instructions.  The author did not include this in the batch 2 (because of limited use cases compared to the `Zicboz` extension) but added because it will be discoverable from Linux (as of version 6.15-rc4).  Along with `Zicbop`, Rust now supports all CMO extensions.

The `Zic64b` extension (mandatory in RVA23U64) constraints the cache block to be naturally-aligned and exactly 64 bytes.  Along with CMO instructions, it can improve efficiency handling with memory (e.g. efficient memory zeroing using `Zicboz` + `Zic64b`).

The `Zicc*` extensions (mandatory in RVA23U64) add constraints to the main memory properties.  They are normally satisfied in the application environment with regular OSes but profiles like RVA23U64 ensures such properties are satisfied (through those *constraint* extensions).

The `Zfbf*` and `Zvfbf*` extensions (optional in RVA23U64) add instructions to handle BF16 (BFloat16) data.  Although stabilization of FP-related extensions are relatively far due to ABI-related issues, they are included in this batch because they will be discoverable from Linux (as of version 6.15-rc4).

The author also adds the extension implication: `Za64rs` → `Za128rs` (superset) which the author missed to include in #140139.
2025-05-02 22:17:03 +10:00
Stuart Cook
01adc82111
Rollup merge of #140430 - nnethercote:hir-exhaustive, r=dtolnay
Improve test coverage of HIR pretty printing.

Details in individual commits.

r? `@dtolnay`

try-job: test-various
2025-05-02 22:17:02 +10:00
Stuart Cook
27d419a6b5
Rollup merge of #140389 - sayantn:avx512fp16, r=Amanieu
Remove `avx512dq` and `avx512vl` implication for `avx512fp16`

According to Intel, `avx512fp16` requires only `avx512bw`, but LLVM also enables `avx512vl` and `avx512dq` when `avx512fp16` is active. This is relic code, and will be fixed in LLVM soon. We should remove this from Rust too asap, especially before the stabilization of AVX512

Related:
 - llvm/llvm-project#136209
 - #138940
 - rust-lang/stdarch#1781
 - #111137

``@rustbot`` label O-x86_64 O-x86_32 A-SIMD A-target-feature T-compiler -T-libs
r? ``@Amanieu``

**Update: the LLVM fix has been merged**

cc ``@rust-lang/wg-llvm`` will it be possible to update the rustc llvm version to something after llvm/llvm-project#137450
2025-05-02 22:17:02 +10:00
Stuart Cook
30e556e772
Rollup merge of #140197 - ktnlvr:master, r=workingjubilee
Document breaking out of a named code block

Closes #110758.
2025-05-02 22:17:01 +10:00
Stuart Cook
5a58c7a6ab
Rollup merge of #140159 - thaliaarchi:pathbuf-extension, r=workingjubilee
Avoid redundant WTF-8 checks in `PathBuf`

Eliminate checks for WTF-8 boundaries in `PathBuf::set_extension` and `add_extension`, where joining WTF-8 surrogate halves is impossible. Don't convert the `str` to `OsStr`, because `OsString::push` specializes to skip the joining when given strings.

To assist in this, mark the internal methods `OsString::truncate` and `extend_from_slice` as `unsafe` to communicate their safety invariants better than with module privacy.

Similar to #137777.

cc `@joboet` `@ChrisDenton`
2025-05-02 22:17:00 +10:00
Stuart Cook
6fc78d410d
Rollup merge of #139847 - thaliaarchi:args/delegate-iter, r=workingjubilee
Delegate to inner `vec::IntoIter` from `env::ArgsOs`

Delegate from `std::env::ArgsOs` to the methods of the inner platform-specific iterators, when it would be more efficient than just using the default methods of its own impl. Most platforms use `vec::IntoIter` as the inner type, so prioritize delegating to the methods it provides.

`std::env::Args` is implemented atop `std::env::ArgsOs` and performs UTF-8 validation with a panic for invalid data. This is a visible effect which users certainly rely on, so we can't skip any arguments. Any further iterator methods would skip some elements, so no change is needed for that type.

Add `#[inline]` for any methods which simply wrap the inner iterator.
2025-05-02 22:17:00 +10:00
Stuart Cook
192fbcc83a
Rollup merge of #139608 - Lynnesbian:improve-async-block-docs, r=ibraheemdev
Clarify `async` block behaviour

Adds some documentation for control flow behaviour pertaining to `return` and `?` within `async` blocks. Fixes (or at least improves) #101444.

r? rust-lang/docs
2025-05-02 22:16:59 +10:00
Stuart Cook
8ffdb00d44
Rollup merge of #139206 - joboet:unique_thread_errno, r=ibraheemdev
std: use the address of `errno` to identify threads in `unique_thread_exit`

Getting the address of `errno` should be just as cheap as `pthread_self()` and avoids having to use the expensive `Mutex` logic because it always results in a pointer.
2025-05-02 22:16:59 +10:00
Stuart Cook
c3f500ec4d
Rollup merge of #139046 - nnethercote:hir-Lifetime-better, r=lcnr
Improve `Lifetime::suggestion`

r? ``@lcnr``
2025-05-02 22:16:58 +10:00
Stuart Cook
b24288ba45
Rollup merge of #138872 - a4lg:riscv-fix-incompatible-abi-zfinx, r=workingjubilee
rustc_target: RISC-V `Zfinx` is incompatible with `{ILP32,LP64}[FD]` ABIs

Because RISC-V Calling Conventions note that:

> This means code targeting the `Zfinx` extension always uses the ILP32,  ILP32E or LP64 integer calling-convention only ABIs as there is no dedicated hardware floating-point register file.

`{ILP32,LP64}[FD]` ABIs with hardware floating-point calling conventions are incompatible with the `Zfinx` extension.

This commit adds `"zfinx"` to the incompatible feature list to those ABIs and tests whether trying to add `"zdinx"` (that is analogous to `"zfinx"` but in double-precision) on a LP64D ABI configuration results in an error (it also tests extension implication; `Zdinx` requires `Zfinx` extension).

Links: RISC-V psABI specification version 1.0
<https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/v1.0/riscv-cc.adoc#named-abis>
<https://github.com/riscv-non-isa/riscv-elf-psabi-doc/releases/tag/v1.0>
2025-05-02 22:16:58 +10:00
Stuart Cook
8619438574
Rollup merge of #137474 - VlaDexa:shebang-placement, r=wesleywiser
pretty-print: Print shebang at the top of the output

Shebang should stay at the top of the file, even after pretty-printing.

Closes #134643
2025-05-02 22:16:57 +10:00
Stuart Cook
96852e2494
Rollup merge of #134034 - bvanjoi:issue-131655, r=petrochenkov
handle paren in macro expand for let-init-else expr

Fixes #131655

This PR modifies the codegen logic of the macro expansion within `let-init-else` expression:
- Before: The expression `let xxx = (mac! {}) else {}` expands to `let xxx = (expanded_ast) else {}`.
- After: The same expression expands to `let xxx = expanded_ast else {}`.

An alternative solution to this issue could involve handling the source code directly when encountering unused parentheses in `let-init-else` expressions. However, this approach might be more cumbersome due to the absence of the necessary data structure.

r? `@petrochenkov`
2025-05-02 22:16:57 +10:00
bors
f97b3c6044 Auto merge of #139883 - matthiaskrgr:crashesapr15, r=Mark-Simulacrum
crashes: more tests

try-job: aarch64-apple
try-job: x86_64-msvc-1
try-job: x86_64-gnu
try-job: dist-i586-gnu-i586-i686-musl
try-job: test-various
2025-05-02 10:46:51 +00:00
bors
db074a06fe Auto merge of #140540 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? `@Manishearth`
2025-05-02 07:33:32 +00:00
Ralf Jung
a8da0fd22d
Merge pull request #4305 from RalfJung/squash
add ./miri squash
2025-05-02 07:02:36 +00:00
reddevilmidzy
a9cd0a9f03 Add regression test for 133065 2025-05-02 15:53:51 +09:00
Ralf Jung
e2d2c56b2e add ./miri squash 2025-05-02 08:35:56 +02:00
Nicholas Nethercote
0ea204a5ff Add useful comments on ExprKind::If variants.
Things that aren't obvious and took me a while to work out.
2025-05-02 15:53:39 +10:00
bors
cb0d6e76d0 Auto merge of #140565 - GuillaumeGomez:rollup-gv4ed14, r=GuillaumeGomez
Rollup of 12 pull requests

Successful merges:

 - #138703 (chore: remove redundant words in comment)
 - #139186 (Refactor `diy_float`)
 - #139780 (docs: Add example to `Iterator::take` with `by_ref`)
 - #139802 (Fix some grammar errors and hyperlinks in doc for `trait Allocator`)
 - #140034 (simd_select_bitmask: the 'padding' bits in the mask are just ignored)
 - #140062 (std: mention `remove_dir_all` can emit `DirectoryNotEmpty` when concurrently written into)
 - #140420 (rustdoc: Fix doctest heuristic for main fn wrapping)
 - #140460 (Fix handling of LoongArch target features not supported by LLVM 19)
 - #140538 (rustc-dev-guide subtree update)
 - #140544 (Clean up "const" situation in format_args!(). )
 - #140552 (allow `#[rustc_std_internal_symbol]` in combination with `#[naked]`)
 - #140556 (Improve error output in case `nodejs` or `npm` is not installed for rustdoc-gui test suite)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-02 04:26:54 +00:00
Lynnesbian
360012f41a
Amend language regarding the never type 2025-05-02 13:22:05 +10:00