Commit graph

302053 commits

Author SHA1 Message Date
Samuel Tardieu
eee8d775fe
Rollup merge of #144817 - WaffleLapkin:reject-referety, r=Urgau
Properly reject tail calls to `&FnPtr` or `&FnDef`

Fixes rust-lang/rust#144795
2025-08-05 03:51:36 +02:00
Samuel Tardieu
ebd865efc4
Rollup merge of #144813 - jieyouxu:no-top-level-tests, r=Kobzol
Add a tidy check to prevent adding UI tests directly under `tests/ui/`

This PR implements https://github.com/rust-lang/compiler-team/issues/902.

Only the last commit (adding the new check) is functional; earlier commits are just small drive-by changes to make the other ui/ui-fulldeps checks more logically contained.

r? ```@Kobzol``` (or compiler)
2025-08-05 03:51:35 +02:00
Samuel Tardieu
3ec8b67672
Rollup merge of #144779 - Kobzol:bootstrap-dot, r=jieyouxu
Implement debugging output of the bootstrap Step graph into a DOT file

There are already a bunch of ways how we can debug bootstrap, so why not add one more =D (ideally I'd like to consolidate these approaches somewhat, ```@Shourya742``` is looking into that, but I think that this specific debugging tool is orthogonal to the rest of them, and is quite useful).

This PR adds the option to render the bootstrap step graph into the DOT format, in order to understand what steps were executed, along with their fields (`Debug` output).

Here you can see an example of the generated DOT files for the `BOOTSTRAP_TRACING=1 ./x build compiler --stage 2 --dry-run` command on x64 Linux. One is with cached deps (what this PR does), the other one without.

[bootstrap-dot.zip](https://github.com/user-attachments/files/21548679/bootstrap-dot.zip)

Visual example:
<img width="1899" height="445" alt="image" src="https://github.com/user-attachments/assets/ae40e6d2-0ea8-48bb-b77e-6b21700b95ee" />

r? ```@jieyouxu```
2025-08-05 03:51:35 +02:00
Samuel Tardieu
a1e41a0227
Rollup merge of #144776 - nnethercote:Printer-cleanups, r=cjgillot
`Printer` cleanups

The trait `Printer` is implemented by six types, and the sub-trait `PrettyPrinter` is implemented by three of those types. The traits and the impls are complex and a bit of a mess. This PR starts to clean them up.

r? ``@davidtwco``
2025-08-05 03:51:34 +02:00
Samuel Tardieu
4cb0ebd24f
Rollup merge of #144741 - ShoyuVanilla:tilde-const-in-block, r=fee1-dead
fix: Error on illegal `[const]`s inside blocks within legal positions

Fixes rust-lang/rust#132067

I initially considered moving `[const]` validations to `rustc_ast_lowering`, but that approach would require adding constness information to `AssocCtxt`, which introduces significant changes - especially within `rustc_expand` - just to support a single use case here:

3fb1b53a9d/compiler/rustc_ast_passes/src/ast_validation.rs (L1596-L1610)

Instead, I believe it's sufficient to simply "reset" `[const]` allowness whenever we enter a new block.
2025-08-05 03:51:34 +02:00
Samuel Tardieu
58b00b088e
Rollup merge of #144548 - Oneirical:uncountable-integer-2, r=jieyouxu
Rehome 21 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`

rust-lang/rust#143902 divided into smaller, easier to review chunks.

Part of rust-lang/rust#133895

Methodology:

1. Refer to the previously written `tests/ui/SUMMARY.md`
2. Find an appropriate category for the test, using the original issue thread and the test contents.
3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers)
4. Rename the tests to make their purpose clearer

Inspired by the methodology that ``@Kivooeo`` was using.

r? ``@jieyouxu``
2025-08-05 03:51:33 +02:00
Samuel Tardieu
2e97165e92
Rollup merge of #144467 - hydro-project:users/mingwes/rustdoc-fix-cors, r=GuillaumeGomez
rustdoc template font links only emit `crossorigin` when needed

The `crossorigin` attribute may cause issues when the href is not actually cross-origin. Specifically, the tag causes the browser to send a preflight OPTIONS request to the server even if it is same-origin. Some temperamental servers may reject all CORS preflight requests even if they're actually same-origin, which causes a CORS error and prevents the fonts from loading, even later on.

This commit fixes that problem by not emitting `crossorigin` if the url appears to be relative to the same origin.
2025-08-05 03:51:32 +02:00
bors
0060d5a2a8 Auto merge of #144893 - GuillaumeGomez:subtree-update_cg_gcc_2025-08-04, r=GuillaumeGomez
GCC backend subtree update

cc `@antoyo`
2025-08-04 17:25:02 +00:00
Guillaume Gomez
21bd67796e Merge commit '482e8540a1' into subtree-update_cg_gcc_2025-08-04 2025-08-04 10:49:43 +02:00
Waffle Lapkin
8b65f3d0e8
properly reject tail calls to &FnPtr or &FnDef 2025-08-04 09:09:49 +02:00
Waffle Lapkin
4f94bbf13d
drive-by cleanup: fix outdated documentation 2025-08-04 09:06:02 +02:00
Jakub Beránek
2f4b40fe4e
Do not render both cached and uncached edge between two steps 2025-08-04 08:29:18 +02:00
Jakub Beránek
450040f2d3
Implement debugging output of the bootstrap Step graph into a DOT file 2025-08-04 08:29:18 +02:00
bors
e1b9081e69 Auto merge of #144882 - Zalathar:rollup-i5q32em, r=Zalathar
Rollup of 2 pull requests

Successful merges:

 - rust-lang/rust#144694 (Distinguish prepending and replacing self ty in predicates)
 - rust-lang/rust#144875 (Add some pre-codegen MIR tests for debug mode)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-08-04 05:04:16 +00:00
Stuart Cook
fe644eb01c
Rollup merge of #144875 - scottmcm:more-mir-tests, r=cjgillot
Add some pre-codegen MIR tests for debug mode

No functional changes; just some tests.

I made these for rust-lang/rust#144483, but that's going in a different direction, so I wanted to propose we just add them to help see the impact of other related changes in the future.

r? mir
2025-08-04 14:58:09 +10:00
Stuart Cook
7307dc0ca1
Rollup merge of #144694 - compiler-errors:with-self-ty, r=SparrowLii
Distinguish prepending and replacing self ty in predicates

There are two kinds of functions called `with_self_ty`:
1. Prepends the `Self` type onto an `ExistentialPredicate` which lacks it in its internal representation.
2. Replaces the `Self` type of an existing predicate, either for diagnostics purposes or in the new trait solver when normalizing that self type.

This PR distinguishes these two because I often want to only grep for one of them. Namely, let's call it `with_replaced_self_ty` when all we're doing is replacing the self type.
2025-08-04 14:58:09 +10:00
bors
07b7dc90ee Auto merge of #144876 - Zalathar:rollup-jhv9rir, r=Zalathar
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#142205 (Mark `slice::swap_with_slice` unstably const)
 - rust-lang/rust#144188 (`available_parallelism`: Add documentation for why we don't look at `ulimit`)
 - rust-lang/rust#144322 (Add lint against dangling pointers from local variables)
 - rust-lang/rust#144497 (tests: Add test for basic line-by-line stepping in a debugger)
 - rust-lang/rust#144559 (Enable extract-insert-dyn.rs test on RISC-V (riscv64))
 - rust-lang/rust#144667 (`AlignmentEnum` should just be `repr(usize)` now)
 - rust-lang/rust#144706 (Do not give function allocations alignment in consteval and Miri.)
 - rust-lang/rust#144746 (resolve: Cleanups and micro-optimizations to extern prelude)
 - rust-lang/rust#144785 (Regression test for LLVM error with unsupported expression in static initializer for const pointer in array on macOS.)
 - rust-lang/rust#144811 (Stylize `*-lynxos178-*` target maintainer handle to make it easier to copy/paste)
 - rust-lang/rust#144848 (For "stage 1" ui-fulldeps, use the stage 1 compiler to query target info)
 - rust-lang/rust#144853 (Remove unnecessary `rust_` prefixes)

Failed merges:

 - rust-lang/rust#144794 (Port `#[coroutine]` to the new attribute system)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-08-04 01:31:11 +00:00
Stuart Cook
7fbb303147
Rollup merge of #144853 - Kivooeo:rust_-cleanup, r=Mark-Simulacrum
Remove unnecessary `rust_` prefixes

part of https://github.com/rust-lang/rust/issues/116005

Honestly, not sure if this can affect linking somehow, also I didn't touched things like `__rust_panic_cleanup` and `__rust_start_panic` which very likely will break something, so just small cleanup here

also didn't changed `rust_panic_without_hook` because it was renamed here https://github.com/rust-lang/rust/pull/144852

r? libs
2025-08-04 11:24:42 +10:00
Stuart Cook
22653b8c1e
Rollup merge of #144848 - Zalathar:ui-fulldeps, r=clubby789
For "stage 1" ui-fulldeps, use the stage 1 compiler to query target info

Testing ui-fulldeps in "stage 1" actually uses the stage 0 compiler, so that test programs can link against stage 1 rustc crates.

Unfortunately, using the stage 0 compiler causes problems when compiletest tries to obtain target information from the compiler, but the output format has changed since the last bootstrap beta bump.

We can work around this by also providing compiletest with a stage 1 compiler, and having it use that compiler to query for target information.

---

This fixes the stage 1 ui-fulldeps failure seen at https://github.com/rust-lang/rust/pull/144443#issuecomment-3146992771.
2025-08-04 11:24:41 +10:00
Stuart Cook
79e7e0359e
Rollup merge of #144811 - jieyouxu:target-maintainer-docs, r=Noratrieb
Stylize `*-lynxos178-*` target maintainer handle to make it easier to copy/paste

Apparently I forgot to submit this branch I had lying around.

Noticed while reviewing Tier 3 target platform support pages. In the same style as rust-lang/rust#139028.
2025-08-04 11:24:41 +10:00
Stuart Cook
6c7ffefcbd
Rollup merge of #144785 - lucarlig:master, r=lqd
Regression test for LLVM error with unsupported expression in static initializer for const pointer in array on macOS.

Regression test for rust-lang/rust#89225, I have shortened the original example as much as i could, while still generating the error.

here is my output on MacOs:
```
rustup run 1.60 cargo build --release
   Compiling rug_int v0.1.0 (/Users/luca/dev/rug_int)
LLVM ERROR: Unsupported expression in static initializer: zext (i64 ptrtoint (<{ [4 x i8] }>* `@anon.fad58de7366495db4650cfefac2fcd61.0` to i64) to i128)
error: could not compile `rug_int`

rustup run 1.61 cargo build --release
   Compiling rug_int v0.1.0 (/Users/luca/dev/rug_int)
    Finished release [optimized] target(s) in 0.60s
```
2025-08-04 11:24:40 +10:00
Stuart Cook
2105044784
Rollup merge of #144746 - petrochenkov:extpreltidy, r=b-naber
resolve: Cleanups and micro-optimizations to extern prelude

This is what can be done without changing the structure of `ExternPreludeEntry`, like in https://github.com/rust-lang/rust/pull/144737.

See individual commits for details.
2025-08-04 11:24:39 +10:00
Stuart Cook
0225f8b09c
Rollup merge of #144706 - zachs18:fix-144661, r=RalfJung
Do not give function allocations alignment in consteval and Miri.

We do not yet have a (clear and T-lang approved) design for how `#[align(N)]` on functions should affect function pointers' addresses on various platforms, so for now do not give function pointers alignment in consteval and Miri.

----

Old summary:

Not a full solution to <https://github.com/rust-lang/rust/issues/144661>, but fixes the immediate issue by making function allocations all have alignment 1 in consteval, ignoring `#[rustc_align(N)]`, so the compiler doesn't know if any offset other than 0 is non-null.

A more "principlied" solution would probably be to make function pointers to `#[instruction_set(arm::t32)]` functions be at offset 1 of an align-`max(2, align attribute)` allocation instead of at offset 0 of their allocation during consteval, and on wasm to either disallow `#[align(N)]` where N > 1, or to pad the function table such that the function pointer of a `#[align(N)]` function is a multiple of `N` at runtime.
2025-08-04 11:24:39 +10:00
Stuart Cook
f6b4e45be7
Rollup merge of #144667 - scottmcm:alignment-is-usize, r=tgross35
`AlignmentEnum` should just be `repr(usize)` now

These used to use specific sizes because they were compiled on all widths.  But now that the types themselves are `#[cfg]`'d, we can save some conversions by having it always be `repr(usize)`.
2025-08-04 11:24:38 +10:00
Stuart Cook
70587ebf0d
Rollup merge of #144559 - CaiWeiran:extract-insert-dyn_test, r=Mark-Simulacrum
Enable extract-insert-dyn.rs test on RISC-V (riscv64)

This PR adds support for running the `tests/codegen-llvm/simd/extract-insert-dyn.rs` test on the RISC-V (riscv64) architecture.

Previously, this test would fail on RISC-V targets due to architecture-specific code generation issues. This patch modifies the test to ensure compatibility while preserving its intent.

The change has been tested locally using `./x test` on a riscv64 target, and the test now passes as expected.

### Notes:
- This change is scoped specifically to improve RISC-V compatibility.
- It does not affect behavior or test results on other architectures.
2025-08-04 11:24:37 +10:00
Stuart Cook
cc7c63b907
Rollup merge of #144497 - Enselic:basic-stepping, r=Mark-Simulacrum
tests: Add test for basic line-by-line stepping in a debugger

Let's wait with lldb testing until the test works properly with gdb.

This is a regression test to prevent further regressions of https://github.com/rust-lang/rust/issues/33013 which unfortunately regressed in **nightly-2023-04-24**. See https://github.com/rust-lang/rust/issues/33013#issuecomment-3121579216.
2025-08-04 11:24:37 +10:00
Stuart Cook
2a947a0efa
Rollup merge of #144322 - Urgau:dangling-ptr-from-locals, r=oli-obk
Add lint against dangling pointers from local variables

## `dangling_pointers_from_locals`

*warn-by-default*

The `dangling_pointers_from_locals` lint detects getting a pointer to data of a local that will be dropped at the end of the function.

### Example

```rust
fn f() -> *const u8 {
    let x = 0;
    &x // returns a dangling ptr to `x`
}
```

```text
warning: a dangling pointer will be produced because the local variable `x` will be dropped
  --> $DIR/dangling-pointers-from-locals.rs:10:5
   |
LL | fn simple() -> *const u8 {
   |                --------- return type of the function is `*const u8`
LL |     let x = 0;
   |         - `x` is defined inside the function and will be drop at the end of the function
LL |     &x
   |     ^^
   |
   = note: pointers do not have a lifetime; after returning, the `u8` will be deallocated at the end of the function because nothing is referencing it as far as the type system is concerned
   = note: `#[warn(dangling_pointers_from_locals)]` on by default
```

### Explanation

Returning a pointer from a local value will not prolong its lifetime, which means that the value can be dropped and the allocation freed while the pointer still exists, making the pointer dangling.

If you need stronger guarantees, consider using references instead, as they are statically verified by the borrow-checker to never dangle.

------

This is related to GitHub codeql [CWE-825](https://github.com/github/codeql/blob/main/rust/ql/src/queries/security/CWE-825/AccessAfterLifetimeBad.rs) which shows examples of such simple miss-use.

It should be noted that C compilers warns against such patterns even without `-Wall`, https://godbolt.org/z/P7z98arrc.

------

`@rustbot` labels +I-lang-nominated +T-lang
cc `@traviscross`
r? compiler
2025-08-04 11:24:36 +10:00
Stuart Cook
e65201ccb8
Rollup merge of #144188 - joshtriplett:available-parallelism, r=Mark-Simulacrum
`available_parallelism`: Add documentation for why we don't look at `ulimit`
2025-08-04 11:24:36 +10:00
Stuart Cook
625b180035
Rollup merge of #142205 - paolobarbolini:const_swap_with_slice-impl, r=Mark-Simulacrum
Mark `slice::swap_with_slice` unstably const

Tracking issue rust-lang/rust#142204
2025-08-04 11:24:35 +10:00
Scott McMurray
e1a38ec2ab Add a debug-mode MIR pre-codegen test for ?-on-Option 2025-08-03 17:30:40 -07:00
Scott McMurray
c441640f0e Add a mir-opt test for *debug* MIR from derive(PartialOrd, Ord)
Because the follow-up commits will affect it, and the goal is to show how.
2025-08-03 17:30:40 -07:00
antoyo
482e8540a1
Merge pull request #746 from rust-lang/sync_from_rust_2025_08_03
Sync from rust 2025/08/03
2025-08-03 20:18:03 -04:00
Antoni Boucher
dac1f34518 Fix stdarch patch 2025-08-03 19:57:04 -04:00
Antoni Boucher
24f1751552 Add new failing test 2025-08-03 19:30:57 -04:00
Antoni Boucher
6b363ae114 Update to nightly-2025-08-03 2025-08-03 18:58:23 -04:00
Antoni Boucher
3f48eed565 Merge branch 'master' into sync_from_rust_2025_08_03 2025-08-03 18:56:24 -04:00
Nicholas Nethercote
cc62d55298 Avoid some code duplication.
`print_binder` can call `wrap_binder`.
2025-08-04 08:18:28 +10:00
antoyo
36a516d810
Merge pull request #740 from rust-lang/sync_from_rust_2025_07_21
Sync from rust 2025/07/21
2025-08-03 16:53:19 -04:00
Antoni Boucher
566c9aeb66 Fix simd_funnel_shift 2025-08-03 16:21:58 -04:00
bors
383b9c447b Auto merge of #144869 - samueltardieu:rollup-3ba3m47, r=samueltardieu
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#142678 (Misc cleanups of `generic_arg_infer` related HIR logic)
 - rust-lang/rust#144070 (Implement `hash_map` macro )
 - rust-lang/rust#144738 (Remove the omit_gdb_pretty_printer_section attribute)
 - rust-lang/rust#144790 (Multiple bounds checking elision failures)
 - rust-lang/rust#144805 (compiletest: Preliminary cleanup of `ProcRes` printing/unwinding)
 - rust-lang/rust#144808 (`Interner` arg to `EarlyBinder` does not affect auto traits)
 - rust-lang/rust#144816 (Update E0562 to account for the new impl trait positions)
 - rust-lang/rust#144822 (Return a struct with named fields from `hash_owner_nodes`)
 - rust-lang/rust#144824 (Updated test links in compiler)
 - rust-lang/rust#144829 (Use full flag name in strip command for Darwin)
 - rust-lang/rust#144843 (Weekly `cargo update`)
 - rust-lang/rust#144851 (Forbid tail calling intrinsics)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-08-03 19:59:50 +00:00
Samuel Tardieu
018c172b22
Rollup merge of #144851 - WaffleLapkin:instrinsic-deny, r=compiler-errors,scottmcm
Forbid tail calling intrinsics

There is only one intrinsic that can be called on stable, as far as I can find, (`transmute`). And in general tail calling intrinsics doesn't make much sense.

Alternative to rust-lang/rust#144815 (and thus closes rust-lang/rust#144815)
Fixes https://github.com/rust-lang/rust/issues/144806

r? ``@scottmcm``
2025-08-03 21:57:02 +02:00
Samuel Tardieu
d0d648d764
Rollup merge of #144843 - rust-lang:cargo_update, r=clubby789
Weekly `cargo update`

Automation to keep dependencies in `Cargo.lock` current.
r? dep-bumps

The following is the output from `cargo update`:

```txt

compiler & tools dependencies:
     Locking 14 packages to latest compatible versions
    Updating clap v4.5.41 -> v4.5.42
    Updating clap_builder v4.5.41 -> v4.5.42
    Updating jsonpath-rust v1.0.3 -> v1.0.4
    Updating libredox v0.1.6 -> v0.1.9
    Updating object v0.37.1 -> v0.37.2
    Updating redox_syscall v0.5.16 -> v0.5.17
    Updating redox_users v0.5.0 -> v0.5.2
    Updating rustc-demangle v0.1.25 -> v0.1.26
    Updating serde_json v1.0.141 -> v1.0.142
    Updating wasm-encoder v0.235.0 -> v0.236.0
    Updating wasmparser v0.235.0 -> v0.236.0
    Updating wast v235.0.0 -> v236.0.0
    Updating wat v1.235.0 -> v1.236.0
    Updating windows-targets v0.53.2 -> v0.53.3
note: pass `--verbose` to see 36 unchanged dependencies behind latest

library dependencies:
     Locking 3 packages to latest compatible versions
    Updating object v0.37.1 -> v0.37.2
    Updating rustc-demangle v0.1.25 -> v0.1.26
    Updating unwinding v0.2.7 -> v0.2.8
note: pass `--verbose` to see 2 unchanged dependencies behind latest

rustbook dependencies:
     Locking 6 packages to latest compatible versions
    Updating cc v1.2.30 -> v1.2.31
    Updating clap v4.5.41 -> v4.5.42
    Updating clap_builder v4.5.41 -> v4.5.42
    Updating redox_syscall v0.5.16 -> v0.5.17
    Updating serde_json v1.0.141 -> v1.0.142
    Updating windows-targets v0.53.2 -> v0.53.3
```
2025-08-03 21:57:01 +02:00
Samuel Tardieu
621a8326db
Rollup merge of #144829 - Kivooeo:strip-flag, r=WaffleLapkin
Use full flag name in strip command for Darwin

Darwin always uses `rust-objcopy` which supports long-form flags

Solaris unchanged due to not having support for `--discard-all` and only `-x`

fixes https://github.com/rust-lang/rust/issues/135038

r? ````@WaffleLapkin```` (since bot will ping you anyway, feel free to reroll)
2025-08-03 21:57:00 +02:00
Samuel Tardieu
c7f248186b
Rollup merge of #144824 - Kivooeo:update-links, r=Noratrieb
Updated test links in compiler

Updated test links since a bunch of tests got moved around from the top level recently

r? compiler
2025-08-03 21:57:00 +02:00
Samuel Tardieu
5b751d75b4
Rollup merge of #144822 - Zalathar:hash-owner-nodes, r=compiler-errors
Return a struct with named fields from `hash_owner_nodes`

While looking through this code for other reasons, I noticed a nice opportunity to return a struct with named fields instead of a tuple. The first patch also introduces an early-return to flatten the rest of `hash_owner_nodes`.

There are further changes that could potentially be made here (renaming things, `Option<Hashes>` instead of optional fields), but I'm not deeply familiar with this code so I didn't want to disturb the calling code too much.
2025-08-03 21:56:59 +02:00
Samuel Tardieu
7100b2deec
Rollup merge of #144816 - Noratrieb:e0562-impl-trait, r=WaffleLapkin
Update E0562 to account for the new impl trait positions

fixes rust-lang/rust#142683
2025-08-03 21:56:58 +02:00
Samuel Tardieu
f3297d8fd3
Rollup merge of #144808 - Veykril:push-uttkuyswqnzt, r=compiler-errors
`Interner` arg to `EarlyBinder` does not affect auto traits

Conceptually `EarlyBinder` does not contain an `Interner` so it shouldn't tell Rust it does via `PhantomData`. This is necessary for rust-analyzer as it stores `EarlyBinder`s in query results which require `Sync`, placing restrictions on our interner setup.

r? compiler-errors
2025-08-03 21:56:58 +02:00
Samuel Tardieu
84b6025411
Rollup merge of #144805 - Zalathar:proc-res, r=jieyouxu
compiletest: Preliminary cleanup of `ProcRes` printing/unwinding

While experimenting with changes to how compiletest handles output capture, error reporting, and unwinding, I repeatedly ran in to difficulties with this core code for reporting test failures caused by a subprocess.

There should be no change in compiletest output.

r? jieyouxu
2025-08-03 21:56:57 +02:00
Samuel Tardieu
c6d3a55914
Rollup merge of #144790 - lucarlig:pr-bounds-elision, r=compiler-errors
Multiple bounds checking elision failures

regression test for rust-lang/rust#120433
2025-08-03 21:56:56 +02:00
Samuel Tardieu
3823f0bc07
Rollup merge of #144738 - bjorn3:remove_omit_gdb_pretty_printer_section, r=jieyouxu
Remove the omit_gdb_pretty_printer_section attribute

Disabling loading of pretty printers in the debugger itself is more reliable. Before this commit the .gdb_debug_scripts section couldn't be included in dylibs or rlibs as otherwise there is no way to disable the section anymore without recompiling the entire standard library.
2025-08-03 21:56:56 +02:00