Commit Graph

323724 Commits

Author SHA1 Message Date
Jacob Pratt 07f5dcaac7 Rollup merge of #155279 - Sandijigs:test/lexer-unicode-pattern-white-space, r=jdonszelmann
Test/lexer unicode pattern white space

This PR adds a test for the Rust lexer to verify it correctly accepts vertical tab (`\x0B`) as valid whitespace between tokens. Vertical tab is part of Unicode Pattern_White_Space, which the Rust language specification uses to define whitespace.

Related: Outreachy tracking [Pattern_White_Space](https://www.unicode.org/reports/tr31/#R3a)
2026-04-14 23:02:34 -04:00
Jacob Pratt 5cff48a164 Rollup merge of #155172 - jackh726:supertrait-shadowing-cleanup, r=lcnr
Some small nits for supertrait_item_shadowing, and additional testing

cc rust-lang/rust#89151

r? types
2026-04-14 23:02:33 -04:00
Jacob Pratt 78a1300310 Rollup merge of #154765 - krtab:doc_ascii_whitespace, r=Mark-Simulacrum,WaffleLapkin
Clarify ascii whitespace exclusion of vertical tab in the doc

This especially means that for `c: char`, `c.is_ascii() && c.is_whitespace()` does **not** imply `c.is_ascii_whitespace()`, which can cause bug and is highly counterintuitive.
2026-04-14 23:02:33 -04:00
Jacob Pratt 3f19aa5672 Rollup merge of #153469 - Albab-Hasan:doc/command-path-search-behavior, r=ChrisDenton
docs: clarify path search behavior in std::process::Command::new

the existing docs mentioned that `PATH` is searched in an "os defined way" and that it could be controlled by setting PATH on the command but never explained which `PATH` is actually used.

on unix the key thing to understand is that when you modify the childs environment (via `env()`, `env_remove()`, or `env_clear()`), the `PATH` search uses whatever `PATH` ends up in the child's environment not the parents. so if you call `env_clear()` and forget to set `PATH`, you don't get the parents `PATH` as a fallback; you get the OS default (typically `/bin:/usr/bin`) which often won't find what you need.

the three cases are now documented:
- unmodified env: child inherits parents `PATH`, that gets searched
- `PATH` explicitly set `via env()`: the new value is searched
- `PATH` removed (`env_clear` or `env_remove`): falls back to OS default, not the parents `PATH`

on windows rust resolves the executable before spawning rather than letting `CreateProcessW` do it. the search order is: childs `PATH` (if explicitly set) first then system-defined directories then the parents `PATH`. the existing note about issue rust-lang/rust#37519 is preserved.

limitations in this doc:
- the unix fallback path behavior ("typically `/bin:/usr/bin`") is verified for linux/glibc. behavior on macOS, BSD, and musl is similar in practice but not fully confirmed here.
- the windows search order is summarized as "system-defined directories" which actually includes the application directory (the directory of the calling process's executable) as a distinct step before the system dirs that detail is omitted for brevity.
- `posix_spawnp` `PATH` source (calling process environ vs envp argument) is ambiguous in the `POSIX` spec; the behavior here is inferred from the guard in `unix.rs` that bypasses `posix_spawn` when `PATH` has been modified.

closes rust-lang/rust#137286 (hopefully)
2026-04-14 23:02:32 -04:00
Jacob Pratt 85c11f656b Rollup merge of #155314 - briansmith:b/comments, r=joshtriplett
`BorrowedBuf`: Update outdated safety comments in `set_init` users.

These comments appear to have been written before `BorrowedBuf`'s init tracking was simplified in
https://github.com/rust-lang/rust/pull/150129. The `BufWriter` comment of the usage within `BufWriter` will be handled separately.

CC rust-lang/rust#78485, rust-lang/rust#117693.
2026-04-14 23:02:31 -04:00
Jacob Pratt 48865507d0 Rollup merge of #155293 - usamoi:rustdoc-loongarch, r=GuillaumeGomez
fix arch names in cfg pretty printer

It's introduced in https://github.com/rust-lang/rust/pull/154328.

@rustbot label +beta-nominated

(it affects the documentation of [`core::arch::loongarch32`](https://doc.rust-lang.org/beta/core/arch/loongarch32/index.html) and [`core::arch::loongarch64`](https://doc.rust-lang.org/beta/core/arch/loongarch64/index.html))
2026-04-14 23:02:31 -04:00
Jacob Pratt de84f87874 Rollup merge of #155259 - durin42:llvm-23-loongarch-tailcall, r=chenyukang
explicit-tail-calls: disable two tests on LoongArch

A [recent LLVM change](https://github.com/llvm/llvm-project/pull/191508) broke these on LLVM 23.

I suspect these will eventually be fixed, so maybe it'd be okay/better to just leave this pending so it applies to our CI without merging it? I'm open to opinions.
2026-04-14 23:02:30 -04:00
Jacob Pratt c6363238fa Rollup merge of #154882 - zedddie:gate-tuple-const-params, r=BoxyUwU
Gate tuple const params behind `min_adt_const_params` feature

r? BoxyUwU
2026-04-14 23:02:30 -04:00
Brian Smith 10cff1530d BorrowedBuf: Update outdated safety comments in set_init users.
These comments appear to have been written before `BorrowedBuf`'s
init tracking was simplified in
https://github.com/rust-lang/rust/pull/150129. The `BufWriter` comment
of the usage within `BufWriter` will be handled separately.
2026-04-14 14:59:21 -07:00
Albab Hasan a34d15f423 Update library/std/src/process.rs
Co-authored-by: Chris Denton <chris@chrisdenton.dev>
2026-04-14 23:39:04 +06:00
albab-hasan 97761a0c23 docs: move PATH search details under Platform-specific behavior, add stability
caveat
2026-04-14 23:02:47 +06:00
bors a5c825cd82 Auto merge of #155292 - JonathanBrouwer:rollup-AJQWqfn, r=JonathanBrouwer
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#154049 (delegation: Track more precise spans for glob delegations)
 - rust-lang/rust#155134 (Replace custom trim_ascii_start with the standard library method)
 - rust-lang/rust#155235 (add the `fma4` x86 target feature)
 - rust-lang/rust#155218 (coroutines: Skip the closure signature annotation check for tainted bodies)
 - rust-lang/rust#155274 (limit duplicate-profiler-builtins test to targets that can do dynamic linking)
 - rust-lang/rust#155276 (`#[rustc_must_match_exhaustively]` detect let else)
 - rust-lang/rust#155281 (Revert "allow `windows-gnu` targets to embed gdb visualizer scripts")
2026-04-14 15:41:02 +00:00
usamoi 05081b96c9 fix arch names in cfg pretty printer 2026-04-14 23:38:25 +08:00
Jonathan Brouwer 2d27fe6a5e Rollup merge of #155281 - folkertdev:revert-154840, r=folkertdev
Revert "allow `windows-gnu` targets to embed gdb visualizer scripts"

Fixes https://github.com/rust-lang/rust/issues/155277

This reverts commit 472b966548.

This was merged as https://github.com/rust-lang/rust/pull/154840, but causes linker errors in the wild.

cc @Walnut356 @mati865
r? @ghost
2026-04-14 16:29:37 +02:00
Jonathan Brouwer 960a56fc4c Rollup merge of #155276 - jdonszelmann:must-match-exhaustively-let-else, r=JonathanBrouwer
`#[rustc_must_match_exhaustively]` detect let else

Extension of https://github.com/rust-lang/rust/pull/155047, I forgor to lint on let-else :3
2026-04-14 16:29:36 +02:00
Jonathan Brouwer 10e6d6c7d9 Rollup merge of #155274 - tshepang:patch-1, r=lqd
limit duplicate-profiler-builtins test to targets that can do dynamic linking

this is the error I got for an example of such a target
```
=== STDERR ===
error: extern location for dylib_a does not exist: libdylib_a.so
 --> main.rs:2:5
  |
2 |     dylib_a::something();
  |     ^^^^^^^

error: extern location for dylib_b does not exist: libdylib_b.so
 --> main.rs:3:5
  |
3 |     dylib_b::something_else();
  |     ^^^^^^^
2026-04-14 16:29:35 +02:00
Jonathan Brouwer aed02c58fc Rollup merge of #155218 - jakubadamw:issue-139570, r=tiif
coroutines: Skip the closure signature annotation check for tainted bodies

When a coroutine has too many parameters, `check_match` fails and `construct_error` builds a MIR body with only the coroutine's computed arguments (env + resume type). The user-provided signature, however, still reflects all the parameters the user wrote. `check_signature_annotation` then tries to `zip_eq` these two mismatched iterators, causing a panic. Checking `tainted_by_errors` and bailing early avoids this, since `construct_error` bodies cannot meaningfully be compared against user annotations.

Example currently ICEing:

```rust
fn main() {
    |(1, 42), ()| yield;
}
```

Closes rust-lang/rust#139570.
2026-04-14 16:29:34 +02:00
Jonathan Brouwer b7286260c8 Rollup merge of #155235 - folkertdev:fma4-target-feature, r=sayantn
add the `fma4` x86 target feature

tracking issue: https://github.com/rust-lang/rust/issues/155233

Implications are based on LLVM

https://github.com/llvm/llvm-project/blob/df6c82053c5e1f9814d130d423f34871bc6423c5/llvm/lib/Target/X86/X86.td#L201-L206

This feature adds a slightly better instruction encoding for fma. We might want to expose the intrinsics in `stdarch` with that target feature, but just adding the target feature in user code should already take advantage of this improved encoding.

This target feature is used in `libm`.

r? sayantn
2026-04-14 16:29:33 +02:00
Jonathan Brouwer 5da0b6cf1c Rollup merge of #155134 - thebabalola:fix/replace-trim-ascii-start-with-stdlib, r=mati865
Replace custom trim_ascii_start with the standard library method

The markdown parser in `rustc_errors` has a local `trim_ascii_start` function that strips leading ASCII whitespace from a byte slice. The standard library has had `<[u8]>::trim_ascii_start()` since Rust 1.80, which does the same thing.

This PR removes the custom function and calls the stdlib method directly in `parse_unordered_li` and `parse_ordered_li`. No behaviour change.

I also added a test covering the list item leading-whitespace trimming behaviour, including a tab case.

Fixes rustfoundation/interop-initiative#53
2026-04-14 16:29:32 +02:00
Jonathan Brouwer 49da27c336 Rollup merge of #154049 - petrochenkov:deleglobspan, r=jackh726
delegation: Track more precise spans for glob delegations

The last commit also fixes a macro hygiene issue with `self` in delegations found in https://github.com/rust-lang/rust/pull/154002.
2026-04-14 16:29:31 +02:00
Folkert de Vries 17f5fa0dd4 Revert "allow windows-gnu targets to embed gdb visualizer scripts"
This reverts commit 472b966548.
2026-04-14 13:27:46 +02:00
Sandijigs 7d4b12b600 Add lexer test for vertical tab as Pattern_White_Space whitespace 2026-04-14 11:49:28 +01:00
Jana Dönszelmann 26a0fdcdcd fixup let-else on typing mode in the compiler 2026-04-14 11:05:19 +02:00
Jana Dönszelmann 778d27441d also check let-else 2026-04-14 11:05:19 +02:00
bors 12f35ad39e Auto merge of #155209 - JonathanBrouwer:attr_cleanup2, r=jdonszelmann
Post-attribute ports cleanup pt. 1 (again)

This is a re-implementation of most (but not all) of https://github.com/rust-lang/rust/pull/154808

The code is the same as in that PR, other than a few changes, I'll leave comments where I changed things.
I did re-implement most of the commits rather than cherry-picking, so it's probably good to check the entire diff regardless

r? @jdonszelmann
2026-04-14 08:59:40 +00:00
Tshepang Mbambo 8619841f05 limit duplicate-profiler-builtins test to targets that can do dynamic linking 2026-04-14 10:57:46 +02:00
Vadim Petrochenkov f001d789c8 Update some tests after rebase 2026-04-14 11:33:15 +03:00
Vadim Petrochenkov 166c499a47 delegation: Give declaration of self syntax context of the delegation body
Instead of the last segment of the delegation path.
`self` is something that introduced by the whole delegation item, not some specific part of it, and the last segment may need to have a different context for path resolution purposes.
2026-04-14 11:32:34 +03:00
Vadim Petrochenkov 8114c5dc2e expand: More precise location for glob delegation
The span location of the last segment in the desugared path is inherited from the star symbol's span
2026-04-14 11:32:34 +03:00
Vadim Petrochenkov 7114404a26 ast: Preserve the star symbol span in glob delegation items 2026-04-14 11:32:33 +03:00
bors 7db0ab43a7 Auto merge of #155270 - jhpratt:rollup-Djg7HpJ, r=jhpratt
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#152530 (Use the term struct-like variant instead of anonymous structs for data of struct-like enum variants)
 - rust-lang/rust#155005 (preserve SIMD element type information)
 - rust-lang/rust#155230 (Avoid linting `doc_cfg` as unused in rustc)
2026-04-14 04:56:46 +00:00
Jacob Pratt ec3a6b407f Rollup merge of #155230 - TaKO8Ki:fix-unused-features-doc-cfg, r=Kivooeo
Avoid linting `doc_cfg` as unused in rustc

Fixes rust-lang/rust#154487

https://github.com/rust-lang/rust/blob/af80b0f2cd0505bcc86eaa675d1ab403110d373a/src/librustdoc/passes/propagate_doc_cfg.rs#L19-L26
2026-04-14 00:37:25 -04:00
Jacob Pratt 803a7227fb Rollup merge of #155005 - folkertdev:simd-element-type-llvm, r=nnethercote
preserve SIMD element type information

Preserve the SIMD element type and provide it to LLVM for better optimization.

This is relevant for AArch64 types like `int16x4x2_t`, see also https://github.com/llvm/llvm-project/issues/181514. Such types are defined like so:

```rust
#[repr(simd)]
struct int16x4_t([i16; 4]);

#[repr(C)]
struct int16x4x2_t(pub int16x4_t, pub int16x4_t);
```

Previously this would be translated to the opaque `[2 x <8 x i8>]`, with this PR it is instead `[2 x <4 x i16>]`. That change is not relevant for the ABI, but using the correct type prevents bitcasts that can (indeed, do) confuse the LLVM pattern matcher.

This change will make it possible to implement the deinterleaving loads on AArch64 in a portable way (without neon-specific intrinsics), which means that e.g. Miri or the cranelift backend can run them without additional support.

discussion at [#t-compiler > loss of vector element type information](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/loss.20of.20vector.20element.20type.20information/with/584483611)
2026-04-14 00:37:24 -04:00
Jacob Pratt 47d991a1aa Rollup merge of #152530 - orzechow:struct_like_enum_variants_docs, r=ChrisDenton
Use the term struct-like variant instead of anonymous structs for data of struct-like enum variants

The current term in the docs `anonymous structs` seems to be outdated.
I'd suggest `struct-like data` or rephrasing the whole sentence to use `struct-like variant`.

The terminology used in the [Rust Book on enums](https://doc.rust-lang.org/stable/book/ch06-01-defining-an-enum.html#listing-6-2) is
> named fields, like a struct

The [Reference on enums](https://doc.rust-lang.org/stable/reference/items/enumerations.html#r-items.enum.constructor) uses
> struct-like enum variant

The term `anonymous struct` on the other hand is neither mentioned in the Rust book on [structs](https://doc.rust-lang.org/stable/book/ch05-01-defining-structs.html) or [enums](https://doc.rust-lang.org/stable/book/ch06-01-defining-an-enum.html#listing-6-2), nor the references on [structs](https://doc.rust-lang.org/stable/reference/items/structs.html) or [enums](https://doc.rust-lang.org/stable/reference/items/enumerations.html#r-items.enum.constructor).
2026-04-14 00:37:23 -04:00
bors 0006519783 Auto merge of #155267 - jhpratt:rollup-fgQZJCS, r=jhpratt
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#149357 (Implement `-Z allow-partial-mitigations` (RFC 3855))
 - rust-lang/rust#154939 (Refactor: simplify report_selection_error)
 - rust-lang/rust#152688 (Trait aliases: Also imply default trait bounds on type params other than `Self`)
 - rust-lang/rust#154352 (rustdoc: dep-info for standalone markdown inputs)
 - rust-lang/rust#155195 (tidy: handle `#[cfg_attr(bootstrap, doc = "...")]` in `compiler/` comments)
2026-04-14 01:06:31 +00:00
Jacob Pratt 30d2f5aca6 Rollup merge of #155195 - jieyouxu:tidy-compiler-doc-attr, r=WaffleLapkin
tidy: handle `#[cfg_attr(bootstrap, doc = "...")]` in `compiler/` comments

For the unbalanced backtick check that Waffle ran into in https://github.com/rust-lang/rust/pull/154887.

This PR cherry-picks Waffle's tidy patch in that PR (and adds some explaining comments) even though I'd say this is somewhat hacky[^1]. But since the original tidy check implementation is already based on heuristics and so are likewise fuzzy, this is probably fine in practice for most cases.

[^1]: There can be false positives/negatives like having both fragments `cfg_attr` and `doc` inside a string literal, but I would expect that to be very very niche, so it's "good enough".

(I wanted to write a regression test, but this check needs some restructuring to make it more easy to test that I don't want to bundle in this PR.)

r? wafflelapkin (or bootstrap/compiler)
2026-04-13 20:12:07 -04:00
Jacob Pratt 4691e61f79 Rollup merge of #154352 - notriddle:emit-md, r=fmease
rustdoc: dep-info for standalone markdown inputs

Part of https://github.com/rust-lang/rust/pull/146220#issuecomment-3936957755

r? @fmease
2026-04-13 20:12:07 -04:00
Jacob Pratt 7e40efc366 Rollup merge of #152688 - fmease:implied-preds-default-bounds, r=jackh726
Trait aliases: Also imply default trait bounds on type params other than `Self`

Trait aliases already correctly imply default trait bounds on `Self` type params. However, due to an oversight, they didn't do that for normal type params.

Fixes rust-lang/rust#152687.
2026-04-13 20:12:06 -04:00
Jacob Pratt 2a0b5343df Rollup merge of #154939 - chenyukang:yukang-refactor-fn-pointer-cast-suggestion, r=davidtwco
Refactor: simplify report_selection_error

Split out `suggest_cast_to_fn_pointer` for better readability.
2026-04-13 20:12:05 -04:00
Jacob Pratt 7d1b042d45 Rollup merge of #149357 - arielb1:enforce-partial-mitigations, r=rcvalle
Implement `-Z allow-partial-mitigations` (RFC 3855)

This implements `-Z allow-partial-mitigations` as an unstable option, currently with support for control-flow-guard and stack-protector.

As a difference from the RFC, we have `-Z allow-partial-mitigations=!foo` rather than `-Z deny-partial-mitigations=foo`, since I couldn't find an easy way to have an allow/deny pair of flags where the latter flag wins.

To allow for stabilization, this is only enabled starting from the next edition. Maybe a better policy is possible (bikeshed).

r? @rcvalle
2026-04-13 20:12:05 -04:00
thebabalola fdfdb0837c Replace custom trim_ascii_start with the standard library method
The local trim_ascii_start function in the markdown parser duplicates
<[u8]>::trim_ascii_start() from the standard library (stable since 1.80).
Remove the custom function and call the stdlib method directly.

No behaviour change.

Fixes https://github.com/rustfoundation/interop-initiative/issues/53
2026-04-13 23:07:39 +01:00
thebabalola 1e02a2b10b Add test for list item leading whitespace trimming 2026-04-13 23:07:39 +01:00
bors 338dff3e3a Auto merge of #136006 - oli-obk:push-tzonluoyuwkq, r=wesleywiser
Start using pattern types in libcore



cc rust-lang/rust#135996

Replaces the innards of `NonNull` with `*const T is !null`.

This does affect LLVM's optimizations, as now reading the field preserves the metadata that the field is not null, and transmuting to another type (e.g. just a raw pointer), will also preserve that information for optimizations. This can cause LLVM opts to do more work, but it's not guaranteed to produce better machine code.

Once we also remove all uses of rustc_layout_scalar_range_start from rustc itself, we can remove the support for that attribute entirely and handle all such needs via pattern types
2026-04-13 21:54:46 +00:00
Augie Fackler fb9e970c1f explicit-tail-calls: disable two tests on LoongArch
A recent LLVM change broke these on LLVM 23.
2026-04-13 17:00:43 -04:00
zedddie 9a9f5b5141 gate primitives behind min_adt_const_params; change suggestion to min_adt_const_params 2026-04-13 22:26:05 +02:00
Jonathan Brouwer a0f105e63e Remove AttributeTemplate from BUILTIN_ATTRIBUTES 2026-04-13 20:52:23 +02:00
Jonathan Brouwer ad41fc08b3 Remove EncodeCrossCrate from BUILTIN_ATTRIBUTES 2026-04-13 20:51:30 +02:00
Jonathan Brouwer 034de09cb3 Remove AttributeType from BUILTIN_ATTRIBUTES 2026-04-13 20:51:29 +02:00
Jonathan Brouwer da8cf97e64 Remove AttributeDuplicates from BUILTIN_ATTRIBUTES 2026-04-13 20:51:24 +02:00
Jonathan Brouwer e391f7717f Remove emit_fatal_malformed_builtin_attribute 2026-04-13 20:51:21 +02:00