Commit graph

19986 commits

Author SHA1 Message Date
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
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
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
Michael Goulet
878acaa795 Dont print arg span in MIR dump for tail call 2025-08-04 18:35:43 +00:00
Jieyou Xu
51f60d1139
Remove tcp-stress.rs test
This stress test was originally introduced in
65cca4bd3f to detect a UAF in libuv (see
RUST-12823), but we no longer use libuv, so remove this test as it was
causing flaky timeout failures. See RUST-144878 for discussion.
2025-08-04 20:09:21 +08:00
Waffle Lapkin
8b65f3d0e8
properly reject tail calls to &FnPtr or &FnDef 2025-08-04 09:09:49 +02: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
Zalathar
51e62a09a3 coverage: Remove -Zcoverage-options=no-mir-spans
This flag turned out to be less useful than anticipated, and interferes with
work towards expansion support.
2025-08-04 13:48:40 +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
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
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
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
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
Waffle Lapkin
c539890ae6
forbid tail calling intrinsics 2025-08-03 21:21:39 +02:00
Shoyu Vanilla
7d78968bd0 fix: Error on illegal [const]s inside blocks within legal positions 2025-08-04 01:48:28 +09:00
bors
f34ba774c7 Auto merge of #144732 - lcnr:ignore-shadowed-impls, r=compiler-errors
dont assemble shadowed impl candidates

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/109.

I've originally intended to fix this by supporting lazy reevaluation when rerunning cycles. This ended up being really difficult, see https://github.com/lcnr/search_graph for my notes used while working on this. It is also insufficient for the `rayon-hang-2.rs` test as we end up with goals which we need to rerun for all combinations of provisional results. While landing such an optimization in the future may still be desirable, it is very difficult and insufficient to fix these hangs. Also see the relevant [zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/rustc-rayon.20hang/near/527850058).

I was previously opposed to avoiding assembling shadowed impls as it may prevent future improvements in this area, cc rust-lang/rust#141226. Going to track this and the reasoning behind it in https://github.com/rust-lang/trait-system-refactor-initiative/issues/226.

r? `@BoxyUwU` `@compiler-errors`
2025-08-03 15:33:31 +00:00
Oneirical
807d3406c2 Rehome tests/ui/issues/ tests [2/?] 2025-08-02 15:29:16 -04:00
Samuel Tardieu
179b4b6691
Rollup merge of #144756 - WaffleLapkin:inf-rec-etc-ctfe, r=lqd
detect infinite recursion with tail calls in ctfe

fixes rust-lang/rust#144753
2025-08-02 11:24:26 +02:00
Samuel Tardieu
751ee2a8f6
Rollup merge of #144703 - daltenty:daltenty/extern-weak, r=Noratrieb
[test][AIX] ignore extern_weak linkage test

The AIX linkage model doesn't support ELF-style extern_weak semantics, so just skip this test, like other platforms that don't have it.
2025-08-02 11:24:25 +02:00
Samuel Tardieu
37ec45382d
Rollup merge of #144614 - cjgillot:fortify-unneeded, r=scottmcm
Fortify RemoveUnneededDrops test.

Test tweak that is useful in preparation for https://github.com/rust-lang/rust/pull/144561
2025-08-02 11:24:24 +02:00
Samuel Tardieu
cafd9fb2d3
Rollup merge of #144395 - folkertdev:fortanix-run-make-test, r=jieyouxu
update fortanix tests

Firstly, as far as I can tell, no CI job actually runs any of the fortanix tests? Maybe I'm missing the job that runs these tests though?

In any case, the `assembly` tests now use `minicore`, meaning that they will run regardless of the host architecture (specifically, they will run during a standard PR CI build).

The run-make test is actually broken, and I'd propose to make it just `cargo build` rather than `cargo run`. We can have a separate test for actually running the program, if desired.

Also this test is subject to https://github.com/rust-lang/rust/issues/128733, so I'd like to re-evaluate what parts of the C/C++ compilation are actually required or useful.

cc [``@jethrogb](https://github.com/jethrogb)`` [``@raoulstrackx](https://github.com/raoulstrackx)`` [``@aditijannu](https://github.com/aditijannu)``

r? ``@jieyouxu``
2025-08-02 11:24:23 +02:00
Samuel Tardieu
4eddebd42b
Rollup merge of #143662 - obi1kenobi:pg/unsafe-attribute-wrappers, r=t-rustdoc
[rustdoc] Display unsafe attrs with edition 2024 `unsafe()` wrappers.

Use Rust 2024 edition representation for unsafe attributes in rustdoc HTML:
- `#[no_mangle]` -> `#[unsafe(no_mangle)]`
- `#[export_name = "foo"]` -> `#[unsafe(export_name = "foo")]`
- `#[link_section = ".text"]` -> `#[unsafe(link_section = ".text")]`

The 2024 edition representation is used regardless of the crate's own edition. This ensures that Rustaceans don't have to learn the rules of an outdated edition (e.g. that `unsafe()` wasn't always necessary) in order to understand a crate's documentation.

After some looking through the `T-rustdoc` issues, I was not able to find an existing issue for this. Apologies if I missed it.

r? ``````@aDotInTheVoid``````
2025-08-02 11:24:21 +02:00
Samuel Tardieu
93917ea97c
Rollup merge of #143360 - folkertdev:const-continue-outside-loop-match, r=WaffleLapkin
loop match: error on `#[const_continue]` outside `#[loop_match]`

tracking issue https://github.com/rust-lang/rust/issues/132306
fixes https://github.com/rust-lang/rust/issues/143119
fixes https://github.com/rust-lang/rust/issues/143165

Fixes several ICEs because a panic was reachable.

``````@rustbot`````` label +F-loop_match
2025-08-02 11:24:20 +02:00
Samuel Tardieu
fc4b3fa3f9
Rollup merge of #132748 - lolbinarycat:rustdoc-intra-doc-link-warn-more-54191, r=GuillaumeGomez
get rid of some false negatives in rustdoc::broken_intra_doc_links

rustdoc will not try to do intra-doc linking if the "path" of a link looks too much like a "real url".

however, only inline links (`[text](url)`) can actually contain a url, other types of links (reference links, shortcut links) contain a *reference* which is later resolved to an actual url.

the "path" in this case cannot be a url, and therefore it should not be skipped due to looking like a url.

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

to minimize the number of false positives that will be introduced, the following heuristic is used:

If there's no backticks, be lenient revert to old behavior.
This is to prevent churn by linting on stuff that isn't meant to be a link.
only shortcut links have simple enough syntax that they
are likely to be written accidentlly, collapsed and reference links
need 4 metachars, and reference links will not usually use
backticks in the reference name.
therefore, only shortcut syntax gets the lenient behavior.
here's a truth table for how link kinds that cannot be urls are handled:

|              |  is shortcut link  | not shortcut link |
|--------------|--------------------|-------------------|
| has backtick |    never ignore    |    never ignore   |
| no backtick  | ignore if url-like |    never ignore   |
2025-08-02 11:24:20 +02:00
bors
889701db1f Auto merge of #129183 - estebank:cfg-visitor, r=davidtwco
Detect more `cfg`d out items in resolution errors

Use a visitor to collect *all* items (including those nested) that were stripped behind a `cfg` condition.

```
error[E0425]: cannot find function `f` in this scope
  --> $DIR/nested-cfg-attrs.rs:4:13
   |
LL | fn main() { f() }
   |             ^ not found in this scope
   |
note: found an item that was configured out
  --> $DIR/nested-cfg-attrs.rs:2:4
   |
LL | fn f() {}
   |    ^
note: the item is gated here
  --> $DIR/nested-cfg-attrs.rs:1:35
   |
LL | #[cfg_attr(all(), cfg_attr(all(), cfg(FALSE)))]
   |                                   ^^^^^^^^^^
```
2025-08-02 05:09:31 +00:00
bors
c23f07d8c5 Auto merge of #144479 - cjgillot:incr-privacy-mod, r=petrochenkov
Perform check_private_in_public by module.

Based on https://github.com/rust-lang/rust/pull/116316
2025-08-02 01:59:11 +00:00
Esteban Küber
4b24c4bf23 Tweak rendering of cfg'd out item
```
error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner`
  --> $DIR/diagnostics-cross-crate.rs:18:23
   |
LL |     cfged_out::inner::doesnt_exist::hello();
   |                       ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner`
   |
note: found an item that was configured out
  --> $DIR/auxiliary/cfged_out.rs:6:13
   |
LL |     #[cfg(false)]
   |           ----- the item is gated here
LL |     pub mod doesnt_exist {
   |             ^^^^^^^^^^^^
```
2025-08-01 23:58:15 +00:00
Esteban Küber
4ba4559a9d remove recursive search for items 2025-08-01 22:02:52 +00:00
Esteban Küber
adcda6ca9a Detect more cfgd out items in resolution errors
Use a visitor to collect *all* items (including those nested) that were stripped behind a `cfg` condition.

```
error[E0425]: cannot find function `f` in this scope
  --> $DIR/nested-cfg-attrs.rs:4:13
   |
LL | fn main() { f() }
   |             ^ not found in this scope
   |
note: found an item that was configured out
  --> $DIR/nested-cfg-attrs.rs:2:4
   |
LL | fn f() {}
   |    ^
note: the item is gated here
  --> $DIR/nested-cfg-attrs.rs:1:35
   |
LL | #[cfg_attr(all(), cfg_attr(all(), cfg(FALSE)))]
   |                                   ^^^^^^^^^^
```
2025-08-01 21:50:36 +00:00
bors
63f6845e57 Auto merge of #144458 - compiler-errors:no-witness-mini, r=lcnr
Remove the witness type from coroutine *args* (without actually removing the type)

This does as much of rust-lang/rust#144157 as we can without having to break rust-lang/rust#143545 and/or introduce some better way of handling higher ranked assumptions.

Namely, it:
* Stalls coroutines based off of the *coroutine* type rather than the witness type.
* Reworks the dtorck constraint hack to not rely on the witness type.
* Removes the witness type from the args of the coroutine, eagerly creating the type for nested obligations when needed (auto/clone impls).

I'll experiment with actually removing the witness type in a follow-up.

r? lcnr
2025-08-01 21:07:49 +00:00
bjorn3
ae2f8d9216 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-01 20:04:59 +00:00
lucarlig
19c6815a21 Multiple bounds checking elision failures 2025-08-01 18:38:22 +01:00
lucarlig
1a64684b04 LLVM error with unsupported expression in static initializer for const pointer in array on macOS 2025-08-01 18:01:21 +01:00
bors
924a5a4b7f Auto merge of #144773 - RalfJung:rollup-uif2yyj, r=RalfJung
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#144397 (`tests/ui/issues/`: The Issues Strike Back [2/N])
 - rust-lang/rust#144410 (Make tier 3 musl targets link dynamically by default)
 - rust-lang/rust#144708 (Add tracing to step.rs and friends)
 - rust-lang/rust#144730 (Create a typed wrapper for codegen backends in bootstrap)
 - rust-lang/rust#144771 (Remove some noisy triagebot pings for myself)
 - rust-lang/rust#144772 (add unsupported_calling_conventions to lint list)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-08-01 10:20:07 +00:00
Ralf Jung
37ad0776ac
Rollup merge of #144397 - Kivooeo:issue2, r=jieyouxu
`tests/ui/issues/`: The Issues Strike Back [2/N]

Some `tests/ui/issues/` housekeeping, to trim down number of tests directly under `tests/ui/issues/`. Part of https://github.com/rust-lang/rust/issues/133895.

r? ``@jieyouxu``
2025-08-01 09:59:03 +02:00
Jacob Pratt
400b8b6862
Rollup merge of #144700 - aDotInTheVoid:macro-rules-for-macro-fools, r=GuillaumeGomez
rustdoc-json: Move `#[macro_export]` from `Other` to it's own  variant

Followup to rust-lang/rust#142936.

cargo-semver-checks [cares about this attribute](4a0d1b0ca1/src/visibility_tracker.rs (L459-L476)), and it wasn't included in the initial PR for structured attributes CC `@obi1kenobi.`

r? `@GuillaumeGomez`
2025-08-01 00:38:20 -04:00
Jacob Pratt
c7ec9bcc6e
Rollup merge of #144691 - xizheyin:suggest-confuse, r=estebank
Extend `is_case_difference` to handle digit-letter confusables

This PR extends `is_case_difference` to handle digit-letter confusables

Add support for detecting 0/O, 1/l, 5/S, 8/B, 9/g confusables in error suggestions.

r? `@estebank`
2025-08-01 00:38:20 -04:00
Jacob Pratt
e6b80f3407
Rollup merge of #143849 - lolbinarycat:rustdoc-priv-normalize-143222, r=GuillaumeGomez
rustdoc: never link to unnamable items

fixes rust-lang/rust#143222
2025-08-01 00:38:19 -04:00
Folkert de Vries
040f71e812
loop match: error on #[const_continue] outside #[loop_match] 2025-08-01 00:28:52 +02:00
Waffle Lapkin
5aec4379e3
detect infinite recursion with tail calls in ctfe 2025-07-31 23:59:55 +02:00
Urgau
8a3a7e625a Add lint against dangling pointers form local variables 2025-07-31 22:35:22 +02:00
Michael Goulet
e9765781b2 Remove the witness type from coroutine args 2025-07-31 17:38:28 +00:00