Commit Graph

300570 Commits

Author SHA1 Message Date
Samuel Tardieu
790ce4bf39 Rollup merge of #143935 - ada4a:walk-docstring, r=compiler-errors
rustc_type_ir/walk: move docstring to `TypeWalker` itself

having it on the impl block is a bit weird imo
2025-07-15 12:52:43 +02:00
Samuel Tardieu
cc26852148 Rollup merge of #143927 - oli-obk:const-dyn-trait-hir-ty, r=fmease
Preserve constness in trait objects up to hir ty lowering

r? ``@compiler-errors``

While we don't support `dyn const Trait`, we can at least also inform the user that `const Trait` is only legal for `#[const_trait] trait Trait {}`
2025-07-15 12:52:43 +02:00
Samuel Tardieu
2e37e24179 Rollup merge of #143910 - ChrisDenton:no-symbolization, r=tgross35
Add experimental `backtrace-trace-only` std feature

This experimentally allows building std with backtrace but without symbolisation. It does not affect stable and requires build-std to use. This doesn't change the backtrace crate itself so relies on the optimizer to remove the unused parts.

Example usage:

```toml
# .cargo/config.toml
[unstable]
build-std = ["core", "alloc", "panic_unwind", "std"]
build-std-features = ["backtrace", "backtrace-trace-only", "panic-unwind"]
```

```toml
# Cargo.toml
[profile.release]
opt-level = 3
lto = "thin"
codegen-units = 1
```

Ideally we should split the backtrace feature into `backtrace-trace` and `backtrace-symbolize` (with the latter dependent on the former) because Cargo features tend to work better when they're positive rather than negative. But I'm keen for this experiment not to break existing users.

cc ``@joshtriplett``
2025-07-15 12:52:42 +02:00
Samuel Tardieu
460a627b83 Rollup merge of #143907 - Kijewski:pr-inline-split_at_unchecked, r=Mark-Simulacrum
core: make `str::split_at_unchecked()` inline

This PR adds `#[inline]` to the method `str::split_at_unchecked()`. This is done for two reasons:

1. The method is tiny, e.g. on AMD-64 (<https://godbolt.org/z/ba68fdfxn>):

   ```asm
   movq    %rdi, %rax
   subq    %rcx, %rdx
   movq    %rsi, (%rdi)
   addq    %rcx, %rsi
   movq    %rcx, 8(%rdi)
   movq    %rsi, 16(%rdi)
   movq    %rdx, 24(%rdi)
   retq
   ```

2. More importantly, inlining the method enables further automatic optimizations. E.g. if you split at index 3, then in the compiler (rustc, llvm or both) knows that this code cannot fail, and the panicking path is omitted in the generated code:

   ```rust
   pub fn punctuation(i: &str) -> Result<(), ()> {
       const THREE_CHARS: &[[u8; 3]] = &[*b"<<=", *b">>=", *b"...", *b"..="];

       if let Some((head, _)) = i.split_at_checked(3)
           && THREE_CHARS.contains(&head.as_bytes().try_into().unwrap())
       {
           Ok(())
       } else {
           Err(())
       }
   }
   ```

   <details>
   <summary>Without PR</summary>

   <https://play.rust-lang.org/?version=stable&mode=release&edition=2024&gist=0234de8158f467eebd73286f20d6e27a>

   ```asm
   playground::punctuation:
           subq    $40, %rsp
           movq    %rsi, %rdx
           movq    %rdi, %rsi
           movb    $1, %al
           cmpq    $3, %rdx
           ja      .LBB2_2
           je      .LBB2_3
   .LBB2_11:
           addq    $40, %rsp
           retq
   .LBB2_2:
           cmpb    $-64, 3(%rsi)
           jl      .LBB2_11
   .LBB2_3:
           leaq    8(%rsp), %rdi
           movl    $3, %ecx
           callq   *core::str::<impl str>::split_at_unchecked@GOTPCREL(%rip)
           movq    8(%rsp), %rcx
           movb    $1, %al
           testq   %rcx, %rcx
           je      .LBB2_11
           cmpq    $3, 16(%rsp)
           jne     .LBB2_12
           movzwl  (%rcx), %edx
           movzbl  2(%rcx), %ecx
           shll    $16, %ecx
           orl     %edx, %ecx
           cmpl    $4013115, %ecx
           jg      .LBB2_8
           cmpl    $3026478, %ecx
           je      .LBB2_10
           cmpl    $4009518, %ecx
           je      .LBB2_10
           jmp     .LBB2_11
   .LBB2_8:
           cmpl    $4013630, %ecx
           je      .LBB2_10
           cmpl    $4013116, %ecx
           jne     .LBB2_11
   .LBB2_10:
           xorl    %eax, %eax
           addq    $40, %rsp
           retq
   .LBB2_12:
           leaq    .Lanon.d98a7fbb86d10a97c24516e267466134.2(%rip), %rdi
           leaq    .Lanon.d98a7fbb86d10a97c24516e267466134.1(%rip), %rcx
           leaq    .Lanon.d98a7fbb86d10a97c24516e267466134.6(%rip), %r8
           leaq    7(%rsp), %rdx
           movl    $43, %esi
           callq   *core::result::unwrap_failed@GOTPCREL(%rip)
   ```
   </details>

   <details>
   <summary>With PR</summary>

   <https://play.rust-lang.org/?version=stable&mode=release&edition=2024&gist=5d4058c79ce0f6cb1a434190427d2055>

   ```asm
   playground::punctuation:
           movb    $1, %al
           cmpq    $3, %rsi
           ja      .LBB0_2
           je      .LBB0_3
   .LBB0_9:
           retq
   .LBB0_2:
           cmpb    $-64, 3(%rdi)
           jl      .LBB0_9
   .LBB0_3:
           movzwl  (%rdi), %eax
           movzbl  2(%rdi), %ecx
           shll    $16, %ecx
           orl     %eax, %ecx
           movb    $1, %al
           cmpl    $4013115, %ecx
           jg      .LBB0_6
           cmpl    $3026478, %ecx
           je      .LBB0_8
           cmpl    $4009518, %ecx
           je      .LBB0_8
           jmp     .LBB0_9
   .LBB0_6:
           cmpl    $4013630, %ecx
           je      .LBB0_8
           cmpl    $4013116, %ecx
           jne     .LBB0_9
   .LBB0_8:
           xorl    %eax, %eax
           retq
   ```
   </details>
2025-07-15 12:52:41 +02:00
Samuel Tardieu
281990eb16 Rollup merge of #143905 - xizheyin:143828, r=compiler-errors
Recover and suggest to use `;` to construct array type

Fixes rust-lang/rust#143828

r? compiler
2025-07-15 12:52:40 +02:00
Samuel Tardieu
743e18364b Rollup merge of #143878 - JonathanBrouwer:pointee_parser, r=jdonszelmann
Port `#[pointee]` to the new attribute parsing infrastructure

Ports `#[pointee]` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971351163

r? ``@jdonszelmann``
2025-07-15 12:52:40 +02:00
Samuel Tardieu
b89c63de0e Rollup merge of #143837 - jieyouxu:symbol-apis, r=ChrisDenton
Adjust `run_make_support::symbols` helpers

Massage the `symbols` helpers to fill out {match all, match any} x {substring match, exact match}:

|           | Substring match                        | Exact match                   |
|-----------|----------------------------------------|-------------------------------|
| Match any | `object_contains_any_symbol_substring` | `object_contains_any_symbol`  |
| Match all | `object_contains_all_symbol_substring` | `object_contains_all_symbols` |

As I'd like to use `object_contains_all_symbols` for rust-lang/rust#143669.

As part of this:

- Rename `any_symbol_contains` to `object_contains_any_symbol_substring` for accuracy, as `any_symbol_contains` is actually "contains any matching substring".
- Remove `with_symbol_iter`.

Noticed while working on https://github.com/rust-lang/rust/pull/143669.

r? ``@ChrisDenton`` (or compiler)
2025-07-15 12:52:39 +02:00
Samuel Tardieu
6b6c8be19d Rollup merge of #143752 - pmur:murp/no-panic-detect-wasi-cc, r=Kobzol
Don't panic if WASI_SDK_PATH not set when detecting compiler

The fedora packaging builds the wasm sysroot outside of the rust build system. Fedora applies a couple of patches related to wasm which I think make this possible. Not panicking seems consistent with the detection logic of other targets when they cannot find cc.
2025-07-15 12:52:38 +02:00
Samuel Tardieu
e66f26fb74 Rollup merge of #143736 - oli-obk:uninspectable-type-id, r=RalfJung
Give all bytes of TypeId provenance

This makes all bytes of TypeId uninspectable at compile-time.

For context see https://github.com/rust-lang/rust/issues/77125#issuecomment-3057049217

r? ``@RalfJung``
2025-07-15 12:52:38 +02:00
Samuel Tardieu
f03a56f706 Rollup merge of #143630 - jieyouxu:drop-suggest, r=Mark-Simulacrum
Drop `./x suggest`

This PR removes the current `./x suggest` implementation (rust-lang/rust#109933, rust-lang/rust#106249) and associated docs for several reasons:

1. Primarily, `./x suggest` is another "flow" in bootstrap that incurs extra complexity and more invariants that bootstrap has to maintain. This causes more friction when trying to investigate and fix staging problems. As far as I know, this flow has not been actively maintained in quite a while, and I'm not aware of interest in maintaining it. Bootstrap really could use less implementation complexity with a very limited maintenance bandwidth.
2. The current `./x suggest` implementation "bypasses" the usual stage defaults for the various check/build/test/etc. flows, and it's not really possible to have a stage default because `./x suggest --run` produces a *sequence* of suggestions like [`./x check`, `./x test library/std`, ..] and then tries to run all of them in sequence, based on which files are modified.
3. We've not seen a lot of interest both in using it or extending static/dynamic test suggestions. Last extensions were rust-lang/rust#117961 and rust-lang/rust#120763. I'm not convinced the extra implementation complexity is worth it. This was discussed in:
    - [#t-infra/bootstrap > Dropping the current &#96;./x suggest&#96; flow implementation](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Dropping.20the.20current.20.60.2E.2Fx.20suggest.60.20flow.20implementation/with/527456699)
    - [#t-compiler > Dropping current &#96;./x suggest&#96; implementation](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Dropping.20current.20.60.2E.2Fx.20suggest.60.20implementation/with/527528696)

Closes rust-lang/rust#109933 (the current implementation is being removed).
Closes rust-lang/rust#143569 (by removing `./x suggest` altogether).
2025-07-15 12:52:37 +02:00
Samuel Tardieu
4e72ed79d4 Rollup merge of #142301 - Gelbpunkt:duplicated-path-in-error-musl, r=workingjubilee,fmease,jieyouxu
tests: Fix duplicated-path-in-error fail with musl

musl's dlopen returns a different error than glibc, which contains the name of the file. This would cause the test to fail, since the filename would appear twice in the output (once in the error from rustc, once in the error message from musl). Split the expected test outputs for the different libc implementations.

Fixes rust-lang/rust#128474
2025-07-15 12:52:36 +02:00
Samuel Tardieu
cbaaf153a5 tidy: check for invalid file names 2025-07-15 11:53:55 +02:00
许杰友 Jieyou Xu (Joe)
8ec7e6fdee Merge pull request #2504 from lolbinarycat/lolbinarycat-patch-2 2025-07-15 17:25:30 +08:00
Patrick-6
e1d35c551f Add std::hint::spin_loop() 2025-07-15 10:49:58 +02:00
bors
a9fb6103b0 Auto merge of #143460 - JonathanBrouwer:cfg_parser, r=jdonszelmann
Port `#[cfg]` to the new attribute parsing infrastructure

Ports `#[cfg]` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197

I've split this PR into commits for reviewability, and left some comments to clarify things
2025-07-15 08:38:13 +00:00
Oli Scherer
2b4ede7e3d constify Index trait and its slice impls 2025-07-15 08:27:15 +00:00
Oli Scherer
cb7d52f643 constify some methods using SliceIndex 2025-07-15 07:58:29 +00:00
Oli Scherer
b5230e5360 constify SliceIndex trait 2025-07-15 07:44:32 +00:00
Jonathan Brouwer
7a7c74ad89 New example for E0536 2025-07-15 09:21:27 +02:00
Jonathan Brouwer
c7f5ddc098 Changes to diagnostics 2025-07-15 09:21:27 +02:00
Jonathan Brouwer
6133c676d7 Define attribute parser & config evaluator 2025-07-15 09:21:26 +02:00
xizheyin
a74a28493a Add tests for UB check in set_len, from_raw_parts_in, from_parts_in
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-15 15:12:24 +08:00
Jonathan Brouwer
30f4a9cd53 Move cfg -> cfg_old 2025-07-15 09:01:03 +02:00
Jonathan Brouwer
38dd6f5206 Allow Early stage to emit errors 2025-07-15 09:01:03 +02:00
Jonathan Brouwer
a14baf1e56 Define datastructures for #[cfg] attribute, move StrippedCfgItem 2025-07-15 09:01:00 +02:00
Ralf Jung
5453326ae0 Merge pull request #4468 from rust-lang/rustup-2025-07-15
Automatic Rustup
2025-07-15 06:08:44 +00:00
The Miri Cronjob Bot
f7da0212af Merge from rustc 2025-07-15 05:07:09 +00:00
The Miri Cronjob Bot
a9a5b33c2d Preparing for merge from rustc 2025-07-15 04:59:27 +00:00
xizheyin
ed88af2163 Recover and suggest use ; to construct array type
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-15 12:00:46 +08:00
bors
7f2065a4ba Auto merge of #142885 - a1phyr:borrowed_cursor_to_buf, r=Mark-Simulacrum
core: Add `BorrowedCursor::with_unfilled_buf`

Implementation of https://github.com/rust-lang/libs-team/issues/367.

This mainly adds `BorrowedCursor::with_unfilled_buf`, with enables using the unfilled part of a cursor as a `BorrowedBuf`.

Note that unlike the ACP, `BorrowedCursor::unfilled_buf` was moved to a `From` conversion. This is more consistent with other ways of creating a `BorrowedBuf` and hides a bit this conversion that requires unsafe code to be used correctly.

Cc rust-lang/rust#78485 rust-lang/rust#117693
2025-07-14 23:45:18 +00:00
Eric Huss
02dc14b25c Update mdbook to 0.4.52
Changelog: https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-0452

This primarily picks up a few fixes.
2025-07-14 16:28:32 -07:00
Manuel Drehwald
39f269c305 Merge pull request #2497 from rust-lang/tshepang-git-clone
tweak some git clone commands
2025-07-14 15:53:33 -07:00
Chayim Refael Friedman
1d3ea1fd6e Infer lifetimes for GATs in expression/pattern position
We should not only in type position.
2025-07-15 01:15:33 +03:00
Jonathan Brouwer
f0d0afab8e Port #[pointee] to the new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-14 23:16:31 +02:00
Folkert de Vries
d0153f5872 update cfg_select! documentation
and make internal terminology consistent

Co-authored-by: Travis Cross <tc@traviscross.com>
2025-07-14 22:29:28 +02:00
Paul Murphy
9bdd3b0ee6 Don't always panic if WASI_SDK_PATH is not set when detecting compilers
They are not always needed when building std, as is the case when
packaging on Fedora. Panic if building from CI, but warn otherwise.
2025-07-14 15:05:59 -05:00
bors
a001497644 Auto merge of #143745 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? `@Manishearth`

Cargo.lock update due to `ui_test` bump and restructure.
2025-07-14 19:53:18 +00:00
rustbot
1669ba055c Update books 2025-07-14 19:01:40 +02:00
Jieyou Xu
0a899e0e8a Update triagebot autolabel 2025-07-15 00:46:34 +08:00
Jieyou Xu
186afbb911 Remove mentions of ./x suggest and suggest-tests in rustc-dev-guide 2025-07-15 00:46:34 +08:00
Jieyou Xu
647c051fec Regenerate completions after removing ./x suggest 2025-07-15 00:46:34 +08:00
Jieyou Xu
91d064b442 Remove current implementation of ./x suggest
This is quite a bit of implementation complexity, yet it is quite
broken, and we don't have the maintenance bandwidth to address.

Remove the current implementation if only to reduce bootstrap's
implementation complexity; the `suggest` flow comes with its own set of
hacks.
2025-07-15 00:46:33 +08:00
Jieyou Xu
904273c58e Register change tracker warning for removal of ./x suggest 2025-07-15 00:46:31 +08:00
bors
aa51a9b094 Auto merge of #143934 - samueltardieu:rollup-w3iw614, r=samueltardieu
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#141809 (Don't call WSACleanup on process exit)
 - rust-lang/rust#143710 (Updates to random number generation APIs)
 - rust-lang/rust#143848 (Rename `stable_mir` and `rustc_smir`)
 - rust-lang/rust#143855 (Port `#[omit_gdb_pretty_printer_section]` to the new attribute parsing)
 - rust-lang/rust#143868 (warn on align on fields to avoid breaking changes)
 - rust-lang/rust#143870 ([COMPILETEST-UNTANGLE 6/N] Use `TestSuite` enum instead of stringly-typed test suites)
 - rust-lang/rust#143901 (Region constraint nits)
 - rust-lang/rust#143903 (Fix typos in documentation files)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-14 16:44:05 +00:00
Jens Reidel
ae1b1b4f8a tests: Fix duplicated-path-in-error fail with musl
musl's dlopen returns a different error than glibc, which contains the
name of the file. This would cause the test to fail, since the filename
would appear twice in the output (once in the error from rustc, once in
the error message from musl). Split the expected test outputs for the
different libc implementations.

Signed-off-by: Jens Reidel <adrian@travitia.xyz>
2025-07-14 18:37:49 +02:00
Ada Alakbarova
1b8d65ed29 rustc_type_ir/walk: move docstring to TypeWalker itself
having it on the impl block is a bit weird imo
2025-07-14 18:14:02 +02:00
Samuel Tardieu
9b260f6ccf Rollup merge of #143903 - vtjl10:master, r=jieyouxu
Fix typos in documentation files

## Summary
Fix minor typos in documentation files to improve readability.

## Changes
- **tests/mir-opt/pre-codegen/README.md**: Fix typo `condiguration` → `configuration`
- **tests/ui/SUMMARY.md**: Fix typo in RFC link URL (`namepsace ` → `namespace`)

## Type of Change
- [x] Documentation update
- [x] Bug fix (typo correction)
2025-07-14 18:05:47 +02:00
Samuel Tardieu
8fcef5674a Rollup merge of #143901 - compiler-errors:region-constraint-nits, r=lcnr
Region constraint nits

Couple miscellaneous region constraints that have a bit to do with rust-lang/rust#143545 but stand on their own.
2025-07-14 18:05:47 +02:00
Samuel Tardieu
084bd581b7 Rollup merge of #143870 - jieyouxu:compiletest-maintenance-6, r=Kobzol
[COMPILETEST-UNTANGLE 6/N] Use `TestSuite` enum instead of stringly-typed test suites

This is part of a patch series to untangle `compiletest` to hopefully nudge it towards being more maintainable.

This PR should contain no functional changes.
2025-07-14 18:05:46 +02:00
Samuel Tardieu
16b3f47658 Rollup merge of #143868 - jdonszelmann:fix-align-on-fields, r=workingjubilee
warn on align on fields to avoid breaking changes

r? `@workingjubilee`
2025-07-14 18:05:45 +02:00