Commit Graph

21219 Commits

Author SHA1 Message Date
Stuart Cook
5e781d05f6 Rollup merge of #143764 - dianne:primary-binding-drop-order, r=Nadrieril,traviscross
lower pattern bindings in the order they're written and base drop order on primary bindings' order

To fix rust-lang/rust#142163, this PR does two things:
- Makes match arms base their drop order on the first sub-branch instead of the last sub-branch. Together with the second change, this makes bindings' drop order correspond to the relative order of when each binding first appears (i.e. the order of the "primary" bindings).
- Lowers pattern bindings in the order they're written (still treating the right-hand side of a ``@`` as coming before the binding on the left). In each sub-branch of a match arm, this is the order that would be obtained if the or-alternatives chosen in that sub-branch were inlined into the arm's pattern. This both affects drop order (making bindings in or-patterns not be dropped first) and fixes the issue in [this test](2a023bf80a/tests/ui/pattern/bindings-after-at/bind-by-copy-or-pat.rs) from rust-lang/rust#121716.

My approach to the second point is admittedly a bit trickier than may be necessary. To avoid passing around a counter when building `FlatPat`s, I've instead added just enough information to recover the original structure of the pattern's bindings from a `MatchTreeSubBranch`'s path through the `Candidate` tree. Some alternatives:
- We could use a counter, then sort bindings by their ordinals when making `MatchTreeSubBranch`es.
- I'd like to experiment with always merging sub-candidates and removing `test_remaining_match_pairs_after_or`; that would require lowering bindings and guards in a different way. That makes it a bigger change too, though, so I figure it might be simplest to start here.
- For a very big change, we could track which or-alternatives succeed at runtime to base drop order on the binding order in the particular alternatives matched.

This is a breaking change. It will need a crater run, language team sign-off, and likely updates to the Reference.

This will conflict with rust-lang/rust#143376 and probably also rust-lang/rust#143028, so they shouldn't be merged at the same time.

r? `@matthewjasper` or `@Nadrieril`
2025-08-07 20:49:39 +10:00
Stuart Cook
4529dd9192 Rollup merge of #143028 - dianne:let-else-storage, r=oli-obk,traviscross
emit `StorageLive` and schedule `StorageDead` for `let`-`else`'s bindings after matching

This PR removes special handling of `let`-`else`, so that `StorageLive`s are emitted and `StorageDead`s are scheduled only after pattern-matching has succeeded. This means `StorageDead`s will no longer appear for all of its bindings on the `else` branch (because they're not live yet) and its drops&`StorageDead`s will happen together like they do elsewhere, rather than having all drops first, then all `StorageDead`s.

This fixes rust-lang/rust#142056, and is therefore a breaking change. I believe it'll need a crater run and a T-lang nomination/fcp thereafter. Specifically, this makes drop-checking slightly more restrictive for `let`-`else` to match the behavior of other variable binding forms. An alternative approach could be to change the relative order of drops and `StorageDead`s for other binding forms to make drop-checking more permissive, but making that consistent would be a significantly more involved change.

r? mir
cc `````@dingxiangfei2009`````

`````@rustbot````` label +T-lang +needs-crater
2025-08-07 20:49:38 +10:00
Stuart Cook
1cd368a744 Rollup merge of #138689 - jedbrown:jed/nvptx-target-feature, r=ZuseZ4
add nvptx_target_feature

Tracking issue: #141468 (nvptx), which is part of #44839 (catch-all arches)
The feature gate is `#![feature(nvptx_target_feature)]`

This exposes the target features `sm_20` through `sm_120a` [as defined](https://github.com/llvm/llvm-project/blob/llvmorg-20.1.1/llvm/lib/Target/NVPTX/NVPTX.td#L59-L85) by LLVM.

Cc: ``````@gonzalobg``````
``````@rustbot`````` label +O-NVPTX +A-target-feature
2025-08-07 20:49:36 +10:00
Stuart Cook
bcd50fd45f Rollup merge of #137831 - estebank:auto-trait-err, r=compiler-errors
Tweak auto trait errors

Make suggestions to remove params and super traits verbose and make spans more accurate.

```
error[E0567]: auto traits cannot have generic parameters
  --> $DIR/auto-trait-validation.rs:6:19
   |
LL | auto trait Generic<T> {}
   |            -------^^^
   |            |
   |            auto trait cannot have generic parameters

error[E0568]: auto traits cannot have super traits or lifetime bounds
  --> $DIR/auto-trait-validation.rs:8:20
   |
LL | auto trait Bound : Copy {}
   |            -----   ^^^^
   |            |
   |            auto traits cannot have super traits or lifetime bounds
```

```
error[E0380]: auto traits cannot have associated items
  --> $DIR/issue-23080.rs:5:8
   |
LL | unsafe auto trait Trait {
   |                   ----- auto traits cannot have associated items
LL |     fn method(&self) {
   |        ^^^^^^
```
2025-08-07 20:49:36 +10:00
bors
9b1a30e5e6 Auto merge of #145014 - bjorn3:revert_preserve_debug_gdb_scripts, r=lqd
Revert "Preserve the .debug_gdb_scripts section"

https://github.com/rust-lang/rust/pull/143679 introduces a significant build time perf regression for ripgrep. Let's revert it such that we can investigate it without pressure.
2025-08-07 07:47:18 +00:00
Nicholas Nethercote
8074e672f0 Reimplement print_region in type_name.rs.
Broken by #144776; this is reachable after all.

Fixes #144994.

The commit also adds a lot more cases to the `type-name-basic.rs`,
because it's currently very anaemic. This includes some cases where
region omission does very badly; these are marked with FIXME.
2025-08-07 12:46:33 +10:00
bors
61cb1e97fc Auto merge of #115746 - tgross35:unnamed-threads-panic-message, r=cuviper
Print thread ID in panic message

`panic!` does not print any identifying information for threads that are
unnamed. However, in many cases, the thread ID can be determined.

This changes the panic message from something like this:

    thread '<unnamed>' panicked at src/main.rs:3:5:
    explicit panic

To something like this:

    thread '<unnamed>' (12345) panicked at src/main.rs:3:5:
    explicit panic

Stack overflow messages are updated as well.

This change applies to both named and unnamed threads. The ID printed is
the OS integer thread ID rather than the Rust thread ID, which should
also be what debuggers print.

try-job: aarch64-apple
try-job: aarch64-gnu
try-job: dist-apple-various
try-job: dist-various-*
try-job: dist-x86_64-freebsd
try-job: dist-x86_64-illumos
try-job: dist-x86_64-netbsd
try-job: dist-x86_64-solaris
try-job: test-various
try-job: x86_64-gnu
try-job: x86_64-mingw-1
try-job: x86_64-msvc-1
2025-08-07 02:32:55 +00:00
ash
916fb6a464 explicit tail call tests with indirect operands in LLVM, small test for indexing into a function table as described by RFC 3407 2025-08-06 18:13:56 -06:00
Trevor Gross
289fe36d37 Print thread ID in panic message if thread name is unknown
`panic!` does not print any identifying information for threads that are
unnamed. However, in many cases, the thread ID can be determined.

This changes the panic message from something like this:

    thread '<unnamed>' panicked at src/main.rs:3:5:
    explicit panic

To something like this:

    thread '<unnamed>' (0xff9bf) panicked at src/main.rs:3:5:
    explicit panic

Stack overflow messages are updated as well.

This change applies to both named and unnamed threads. The ID printed is
the OS integer thread ID rather than the Rust thread ID, which should
also be what debuggers print.
2025-08-06 23:59:47 +00:00
Esteban Küber
025fbe8f69 Add support for shortening Instance and use it
Replace ad-hoc type path shortening logic for recursive mono instantiation errors to use `tcx.short_string()` instead.
2025-08-06 22:21:49 +00:00
Jonathan Brouwer
4281e05a20 Changes to the tests for the #[should_panic] port
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-06 21:38:00 +02:00
Guillaume Gomez
d369a1fe5e Rollup merge of #145008 - GuillaumeGomez:fix-rustdoc-scrape-examples-crash, r=fmease
Fix rustdoc scrape examples crash

Fixes rust-lang/rust#144752.

The regression was introduced in https://github.com/rust-lang/rust/pull/144600. Although I don't understand why it is an issue currently, this allows to bypass the failure for now until we can figure out what's wrong as it's currently blocking new `bevy`'s release.

cc `@alice-i-cecile`
r? `@fmease`
2025-08-06 21:29:35 +02:00
Guillaume Gomez
12d1b173fb Rollup merge of #144977 - fmease:fortify-param-default-checks, r=compiler-errors
Fortify generic param default checks

* Hard-reject instead of lint-reject type param defaults in generic assoc consts (GACs) (feature: `generic_const_items`).
  * In https://github.com/rust-lang/rust/pull/113522, I explicitly handled the free const item case and forgot about the assoc const one.
  * This led rustc to assume the default of emitting the deny-by-default lint `invalid_type_param_default`.
  * GCIs are unstable, thus we're not bound by backward compat
* Hard-reject instead of lint-reject type param defaults in foreign items.
  * We already hard-reject generic params on foreign items, so this isn't a breaking change.
  * There's no reason why we need to lint-reject.
* Refactor the way we determine where generic param defaults are allowed:
  * Don't default to emitting lint `invalid_type_param_defaults` for nodes that aren't explicitly handled but instead panic.
  * This would've caught my GAC oversight from above much earlier via fuzzing
  * Prevents us from accidentally stabilizing more invalid type param defaults in the future
* Streamline the phrasing of the diagnostic
2025-08-06 21:29:32 +02:00
Guillaume Gomez
de6c639228 Rollup merge of #144970 - lolbinarycat:rustdoc-macro-wrong-link-144965, r=GuillaumeGomez
rustdoc: fix caching of intra-doc links on reexports

previously two reexports of the same item would share a set of intra-doc links, which would cause problems if they had two different links with the same text.  this was fixed by using the reexport defid as the key, if it is available.

fixes https://github.com/rust-lang/rust/issues/144965
2025-08-06 21:29:31 +02:00
Guillaume Gomez
48d57564cf Rollup merge of #144956 - fmease:gate-const-trait-syntax, r=BoxyUwU
Gate const trait syntax

Missed this during my review of rust-lang/rust#143879, huge apologies!
Fixes [after beta backport] https://github.com/rust-lang/rust/issues/144958.

cc ``@fee1-dead``
r? ``@BoxyUwU`` or anyone
2025-08-06 21:29:30 +02:00
Guillaume Gomez
65479f7353 Rollup merge of #144917 - compiler-errors:tail-call-linked-lifetimes, r=lcnr
Enforce tail call type is related to body return type in borrowck

Like all call terminators, tail call terminators instantiate the binder of the callee signature with region variables and equate the arg operand types with that signature's args to ensure that the call is valid.

However, unlike normal call terminators, we were forgetting to also relate the return type of the call terminator to anything. In the case of tail call terminators, the correct thing is to relate it to the return type of the caller function (or in other words, the return local `_0`).

This meant that if the caller's return type had some lifetime constraint, then that constraint wouldn't flow through the signature and affect the args.

This is what's happening in the example test I committed:

```rust
fn link(x: &str) -> &'static str {
    become passthrough(x);
}

fn passthrough<T>(t: T) -> T { t }

fn main() {
    let x = String::from("hello, world");
    let s = link(&x);
    drop(x);
    println!("{s}");
}
```

Specifically, the type `x` is `'?0 str`, where `'?0` is some *universal* arg. The type of `passthrough` is `fn(&'?1 str) -> &'?1 str`. Equating the args sets `'?0 = '?1`. However, we need to also equate the return type `&'?1 str` to `&'static str` so that we eventually require that `'?0 = 'static`, which is a borrowck error!

-----

Look at the first commit for the functional change, and the second commit is just a refactor because we don't need to pass `Option<BasicBlock>` to `check_call_dest`, but just whether or not the terminator is expected to be diverging (i.e. if the return type is `!`).

Fixes rust-lang/rust#144916
2025-08-06 21:29:29 +02:00
Guillaume Gomez
940a003985 Rollup merge of #144835 - compiler-errors:tail-call-sig-binder, r=WaffleLapkin
Anonymize binders in tail call sig

See the comment for explanation

Fixes rust-lang/rust#144826

r? WaffleLapkin
2025-08-06 21:29:27 +02:00
Guillaume Gomez
96a41c5aba Rollup merge of #144794 - scrabsha:push-noqrrttovmwy, r=jdonszelmann
Port `#[coroutine]` to the new attribute system

Related to https://github.com/rust-lang/rust/issues/131229#issue-2565886367.

r? `````@jdonszelmann`````
2025-08-06 21:29:27 +02:00
Guillaume Gomez
d180873be8 Rollup merge of #144195 - Kivooeo:bad-attr, r=fmease,compiler-errors
Parser: Recover from attributes applied to types and generic args

r? compiler

Add clearer error messages for invalid attribute usage in types or generic types

fixes rust-lang/rust#135017
fixes rust-lang/rust#144132
2025-08-06 21:29:26 +02:00
dianne
b7de539805 lower bindings in the order they're written 2025-08-06 12:13:40 -07:00
dianne
ea1eca5e3b base drop order on the first sub-branch 2025-08-06 12:13:12 -07:00
Paul Murphy
0bba9bd55c Explicitly disable vector feature on s390x baseline of bad-reg test
If the baseline s390x cpu is changed to a newer variant, such as z13,
the vector feature may be enabled by default. When rust is packaged
on fedora 38 and newer, it is set to z13.

Explicitly disable vector support on the baseline test for consistent
results across s390x cpus.
2025-08-06 14:12:38 -05:00
bjorn3
e02cc40ec9 Revert "Preserve the .debug_gdb_scripts section"
This reverts commit 868bdde25b.
2025-08-06 18:01:07 +00:00
bjorn3
270c1a4d24 Revert "Embed GDB pretty printers in rlibs and dylibs"
This reverts commit b4d923cea0.
2025-08-06 18:00:58 +00:00
Sasha Pourcelot
1e271d6ed1 Allow function argument mismatch suggestion to be multiline 2025-08-06 19:17:36 +02:00
bors
29cdc6a109 Auto merge of #145003 - Kobzol:rollup-kgb216b, r=Kobzol
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#144552 (Rehome 33 `tests/ui/issues/` tests to other subdirectories under `tests/ui/`)
 - rust-lang/rust#144676 (Add documentation for unstable_feature_bound)
 - rust-lang/rust#144836 (Change visibility of Args new function)
 - rust-lang/rust#144910 (Add regression tests for seemingly fixed issues)
 - rust-lang/rust#144913 ([rustdoc] Fix wrong `i` tooltip icon)
 - rust-lang/rust#144924 (compiletest: add hint for when a ui test produces no errors)
 - rust-lang/rust#144926 (Correct the use of `must_use` on btree::IterMut)
 - rust-lang/rust#144928 (Drop `rust-version` from `rustc_thread_pool`)
 - rust-lang/rust#144945 (Autolabel PRs that change explicit tail call tests as `F-explicit_tail_calls`)
 - rust-lang/rust#144954 (run-make: Allow blessing snapshot files that don't exist yet)
 - rust-lang/rust#144971 (num: Rename `isolate_most_least_significant_one` functions)
 - rust-lang/rust#144978 (Fix some doc links for intrinsics)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-08-06 16:17:02 +00:00
Scott McMurray
c396521fd3 [codegen] assume the tag, not the relative discriminant 2025-08-06 09:11:35 -07:00
Boxy
7bc34622f0 tidy 2025-08-06 16:55:50 +01:00
Guillaume Gomez
a2b1714fb2 Add regression test for rustdoc scrape-examples feature crash (#144752) 2025-08-06 17:26:08 +02:00
Jakub Beránek
4b6971e254 Rollup merge of #144913 - GuillaumeGomez:fix-wrong-i-icon, r=fmease
[rustdoc] Fix wrong `i` tooltip icon

Current wrong display:

<img width="334" height="37" alt="Screenshot From 2025-08-04 17-42-38" src="https://github.com/user-attachments/assets/57046475-6162-487f-998f-ebb2434c111d" />

With the fix:

<img width="334" height="37" alt="image" src="https://github.com/user-attachments/assets/e761a103-dc39-4e30-8c8e-cfc7fab52fde" />

r? ``@fmease``
2025-08-06 15:55:45 +02:00
Jakub Beránek
07007135f2 Rollup merge of #144910 - ShoyuVanilla:add-regression-tests, r=fee1-dead
Add regression tests for seemingly fixed issues

Closes rust-lang/rust#104314
Closes rust-lang/rust#125866
2025-08-06 15:55:44 +02:00
Jakub Beránek
e89ae47b97 Rollup merge of #144552 - Oneirical:uncountable-integer-3, r=jieyouxu
Rehome 33 `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-06 15:55:42 +02:00
Zalathar
81ed042c8c coverage: Remove all unstable support for MC/DC instrumentation 2025-08-06 22:38:52 +10:00
Sebastian Poeplau
b4d923cea0 Embed GDB pretty printers in rlibs and dylibs
Instead of collecting pretty printers transitively when building
executables/staticlibs/cdylibs, let the debugger find each crate's
pretty printers via its .debug_gdb_scripts section. This covers the case
where libraries defining custom pretty printers are loaded dynamically.
2025-08-06 13:24:43 +02:00
León Orell Valerian Liehr
02ea38cfff Fortify generic param default checks 2025-08-06 01:26:26 +02:00
binarycat
34b358d52a rustdoc: fix caching of intra-doc links on reexports 2025-08-05 15:34:51 -05:00
Jens Reidel
070425e54d Add aarch64_be-unknown-none-softfloat target
Signed-off-by: Jens Reidel <adrian@travitia.xyz>
2025-08-05 21:18:18 +02:00
Kivooeo
b6e13e3591 comments 2025-08-05 19:34:46 +05:00
Kivooeo
62c92f30cf moved 35 tests to organized locations 2025-08-05 19:02:23 +05:00
Shoyu Vanilla
3e764d030a Add regression tests for seemingly fixed issues 2025-08-05 22:29:49 +09:00
León Orell Valerian Liehr
092c6f3a18 Gate const trait syntax 2025-08-05 14:52:02 +02:00
Vadim Petrochenkov
33cb4190a2 Mark all deprecation lints in name resolution as deny-by-default and report-in-deps 2025-08-05 15:28:49 +03:00
Sebastian Poeplau
868bdde25b Preserve the .debug_gdb_scripts section
Make sure that compiler and linker don't optimize the section's contents
away by adding the global holding the data to "llvm.used". The volatile
load in the main shim is retained because "llvm.used", which translates
to SHF_GNU_RETAIN on ELF targets, requires a reasonably recent linker;
emitting the volatile load ensures compatibility with older linkers, at
least when libstd is used.

Pretty printers in dylib dependencies are now emitted by the main crate
instead of the dylib; apart from matching how rlibs are handled, this
approach has the advantage that `omit_gdb_pretty_printer_section` keeps
working with dylib dependencies.
2025-08-05 10:55:07 +02:00
Sasha Pourcelot
bdaabc17b6 Add test for "missing function argument" on multiline call 2025-08-05 09:28:59 +02:00
Scott McMurray
4e81ecaf3a Let RemoveUnneededDrops also remove drop_in_place 2025-08-04 23:54:39 -07:00
Kivooeo
d09cf616f7 Added checks for attribute in type case 2025-08-05 07:10:31 +05:00
Camille GILLOT
6b7f8fbcc5 Promote crash test. 2025-08-05 01:55:20 +00:00
Samuel Tardieu
5c11681820 Rollup merge of #144920 - compiler-errors:span-arg, r=lqd
Dont print arg span in MIR dump for tail call

r? WaffleLapkin

This makes the MIR dump for tail call terminators consistent w/ regular calls.
2025-08-05 03:51:42 +02:00
Samuel Tardieu
bc601e9cf9 Rollup merge of #144894 - jieyouxu:chop-thread-cnt, r=ChrisDenton
Delete `tests/ui/threads-sendsync/tcp-stress.rs`

This stress test was originally introduced in 65cca4bd3f to detect a UAF in `libuv` (see rust-lang/rust#12823), but we no longer use `libuv`, so remove this test as it no longer serves its original purpose, and is causing flaky timeout failures.

Closes rust-lang/rust#144878 (by removing the test).

r? libs
2025-08-05 03:51:41 +02:00
Samuel Tardieu
7ad5281f3b Rollup merge of #144877 - Zalathar:coverage-various, r=lcnr
coverage: Various small cleanups

This PR is a collection of small coverage-related changes that I accumulated while working towards other coverage improvements.

Each change should hopefully be fairly straightforward.
2025-08-05 03:51:39 +02:00