Commit Graph

310291 Commits

Author SHA1 Message Date
msmoiz e628b059bb update language from "no lines" to "empty iterator" 2025-11-13 16:44:07 -08:00
msmoiz 4996edc53d add note to lines docs about empty str behavior 2025-11-13 08:36:22 -08:00
bors d682af88a5 Auto merge of #147918 - yotamofek:pr/stringdex-fork, r=GuillaumeGomez
Upgrade `stringdex` to 0.0.3

Includes a bunch of optimizations for a nice perf win
2025-11-13 10:15:39 +00:00
Yotam Ofek e921e28c7a Upgrade stringdex to 0.0.3 2025-11-13 10:15:30 +02:00
bors 5dbf4069dc Auto merge of #148885 - Zalathar:rollup-wrvewer, r=Zalathar
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#147701 (rustdoc: don't ignore path distance for doc aliases)
 - rust-lang/rust#148735 (Fix ICE caused by invalid spans for shrink_file)
 - rust-lang/rust#148839 (fix rtsan_nonblocking_async lint closure ICE)
 - rust-lang/rust#148846 (add a test for combining RPIT with explicit tail calls)
 - rust-lang/rust#148872 (fix: Do not ICE when missing match arm with ill-formed subty is met)
 - rust-lang/rust#148880 (Remove explicit install of `eslint` inside of `tidy`'s Dockerfile)
 - rust-lang/rust#148883 (bootstrap: dont require cmake if local-rebuild is enabled)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-13 02:39:06 +00:00
Stuart Cook 314a6cdadf Rollup merge of #148883 - weihanglo:sanity, r=Kobzol
bootstrap: dont require cmake if local-rebuild is enabled

This is for people rebuilding stdlib directly from stage 0 with the full toolchain from rust-src rustup component. The toolchain itself should have sufficient LLVM tools, so CMake and LLVM are not required when `build.local-rebuild = true`

Fixes rust-lang/rust#148835

r? Kobzol
2025-11-13 11:57:11 +11:00
Stuart Cook 3a4a738c9f Rollup merge of #148880 - yotamofek:pr/dockerfile-eslint-install, r=Kobzol,GuillaumeGomez
Remove explicit install of `eslint` inside of `tidy`'s Dockerfile

`tidy` will already install it (when needed) due to it being in `package.json`

With this change, we don't have the version of `eslint` specific in two different places :)

(this was added in rust-lang/rust#141705 , before `tidy` gained the ability to run `npm install`, and is not needed anymore)
2025-11-13 11:57:11 +11:00
Stuart Cook 17c25e4483 Rollup merge of #148872 - ShoyuVanilla:issue-148192, r=chenyukang
fix: Do not ICE when missing match arm with ill-formed subty is met

Fixes rust-lang/rust#148192

The ICE comes from the following line, calling `normalize_erasing_regions` to a projection type whose trait bound is not met:
https://github.com/rust-lang/rust/blob/2fcbda6c1a70606bdb09857e01d01fc6229da712/compiler/rustc_pattern_analysis/src/rustc.rs#L185-L194

The above function is called while trying to lint missing match arms, or scrutinize ctors of missing(not necessary error) match arms.

So, the following code can trigger ICEs.
```rust
trait WhereTrait {
    type Type;
}

fn foo(e: Enum) {
    match e {
        Enum::Map(_) => (), // ICE, while trying to lint missing arms
    }

    if let Enum::Map(_) = e {} // ICE, while trying to scrutinize missing ctors (even worse)
}

enum Enum {
    Map(()),
    Map2(<() as WhereTrait>::Type),
}
```

This ICE won't be triggered with the following code, as this is filtered out before `check_match` as the existence of ill-formed type inside the variant marks the body as tainted by error in `hir_typeck`, but for the above code, the `hir_typeck` complains nothing because everything it sees is locally correct.

```rust
fn foo(e: Enum) {
    match e {
        Enum::Map2(_) => (), // No ICE
    }
}
```

I've considered visiting and wf checking for the match scrutinee before entering `check_match`, but that might regress the perf and I think just emitting delayed bug would enough as the normalization failure would be originated by other errors like ill-formdness.
2025-11-13 11:57:10 +11:00
Stuart Cook 1f2d7db112 Rollup merge of #148846 - folkertdev:tail-call-rpit, r=WaffleLapkin
add a test for combining RPIT with explicit tail calls

tracking issue: https://github.com/rust-lang/rust/issues/112788
fixes https://github.com/rust-lang/rust/issues/139305

Combining return position impl trait (RPIT) with guaranteed tail calls does not currently work, but at least it does not ICE any more.

Using RPIT probably should work, see also https://github.com/rust-lang/rust/issues/144953.

The snippet in the issue is not valid for a variety of reasons, and based on the assert that got triggered the ICE was just any `-> impl Trait` at all, so I've made a minimal example using RPIT.

r? `@WaffleLapkin`
2025-11-13 11:57:09 +11:00
Stuart Cook 20f111f0d8 Rollup merge of #148839 - luca3s:rtsan_ice_fix, r=WaffleLapkin
fix rtsan_nonblocking_async lint closure ICE

Fixes https://github.com/rust-lang/rust/issues/148750, which i introduced in https://github.com/rust-lang/rust/pull/147935.
I also added the bug report to the tests.
2025-11-13 11:57:08 +11:00
Stuart Cook 06b18db01b Rollup merge of #148735 - chenyukang:yukang-fix-ice-148732, r=nnethercote
Fix ICE caused by invalid spans for shrink_file

Fixes rust-lang/rust#148732

There are two issues in this function:
1. the original issue is caused by a typo error, which is fixed in the first commit
2. another different ice(Patch span `7..7` is beyond the end of buffer `0`) will be reported after fixing the first one, is caused by spans cross file boundaries due to macro expansion. It is fixed in the second commit.

r? `@nnethercote`

edited: also fixes rust-lang/rust#148684, added a new testcase for it in the last commit.
2025-11-13 11:57:07 +11:00
Stuart Cook c3171d19d5 Rollup merge of #147701 - lolbinarycat:rustdoc-search-alias-fix, r=GuillaumeGomez
rustdoc: don't ignore path distance for doc aliases

Ran into a bit of an issue due to the overloading of space (it needs to be a metachar for most searches, but not for doc aliases that have space in them).  Not sure if I need to also need to account for other whitespace chars.

<img width="1778" height="494" alt="screenshot" src="https://github.com/user-attachments/assets/041e76f1-3b29-4de5-a72b-1431021fb676" />

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

r? `@GuillaumeGomez`
2025-11-13 11:57:07 +11:00
bors 503dce33e2 Auto merge of #148789 - m-ou-se:new-fmt-args-alt, r=wafflelapkin,jdonszelmann
New format_args!() and fmt::Arguments implementation

Part of https://github.com/rust-lang/rust/issues/99012

This is a new implementation of `format_args!()` and `fmt::Arguments`. With this implementation, `fmt::Arguments` is only two pointers in size. (Instead of six, before.) This makes it the same size as a `&str` and makes it fit in a register pair.

---

This `fmt::Arguments` can store a `&'static str` _without any indirection_ or additional storage. This means that simple cases like `print_fmt(format_args!("hello"))` are now just as efficient for the caller as `print_str("hello")`, as shown by this example:

> code:
> ```rust
> fn main() {
>     println!("Hello, world!");
> }
> ```
>
> before:
> ```asm
> main:
>  sub     rsp, 56
>  lea     rax, [rip + .Lanon_hello_world]
>  mov     qword ptr [rsp + 8], rax
>  mov     qword ptr [rsp + 16], 1
>  mov     qword ptr [rsp + 24], 8
>  xorps   xmm0, xmm0
>  movups  xmmword ptr [rsp + 32], xmm0
>  lea     rdi, [rsp + 8]
>  call    qword ptr [rip + std::io::stdio::_print]
>  add     rsp, 56
>  ret
> ```
>
> after:
> ```asm
> main:
>  lea     rsi, [rip + .Lanon_hello_world]
>  mov     edi, 29
>  jmp     qword ptr [rip + std::io::stdio::_print]
> ```

(`panic!("Hello, world!");` shows a similar change.)

---

This implementation stores all static information as just a single (byte) string, without any indirection:

> code:
> ```rust
> format_args!("Hello, {name:-^20}!")
> ```
>
> lowering before:
> ```rust
> fmt::Arguments::new_v1_formatted(
>     &["Hello, ", "!\n"],
>     &args,
>     &[
>         Placeholder {
>             position: 0usize,
>             flags: 3355443245u32,
>             precision: format_count::Implied,
>             width: format_count::Is(20u16),
>         },
>     ],
> )
> ```
>
> lowering after:
> ```rust
> fmt::Arguments::new(
>     b"\x07Hello, \xc3-\x00\x00\xc8\x14\x00\x02!\n\x00",
>     &args,
> )
> ```

This saves a ton of pointers and simplifies the expansion significantly, but does mean that individual pieces (e.g. `"Hello, "` and `"!\n"`) cannot be reused. (Those pieces are often smaller than a pointer to them, though, in which case reusing them is useless.)

---

The details of the new representation are documented in [library/core/src/fmt/mod.rs](https://github.com/m-ou-se/rust/blob/new-fmt-args-alt/library/core/src/fmt/mod.rs#L609-L712).
2025-11-12 23:21:24 +00:00
Weihang Lo b1e8d562db bootstrap: dont require cmake if local-rebuild is enabled
This is for people rebuilding stdlib directly from stage 0
with the full toolchain from rust-src rustup component.
The toolchain itself should have sufficient LLVM tools,
so CMake and LLVM are not required when `build.local-rebuild = true`
2025-11-12 16:56:21 -05:00
bors 01867557cd Auto merge of #148873 - Muscraft:update-cargo, r=Muscraft
Update cargo

10 commits in 445fe4a68f469bf936b2fd81de2c503b233a7f4f..2d4fa139552ebdd5f091a1401ed03f7dc62cb43f
2025-11-07 18:08:19 +0000 to 2025-11-12 15:56:06 +0000
- feat: Add unstable rustc-unicode flag (rust-lang/cargo#16243)
- fix(package): all tar entries timestamp be the same (rust-lang/cargo#16242)
- feat: emit help messages for github pull request url in dependency (rust-lang/cargo#16207)
- docs: fix comments for alternative registry fns (rust-lang/cargo#16235)
- add into_value utility function for inheritableField (rust-lang/cargo#16234)
- fix(command-vendor): strip_prefix panic in cp_sources method (rust-lang/cargo#16214)
- fix(lock): Be moore direct in the error message (rust-lang/cargo#16233)
- fix(lock): In error, differentiate between creating and updating lockfile (rust-lang/cargo#16227)
- fix(cli): Refer to commands, not subcommands (rust-lang/cargo#16226)
- fix(run): Help teach about argument escaping (rust-lang/cargo#16225)
2025-11-12 19:48:55 +00:00
Yotam Ofek c09185c8ac Remove explicit install of eslint inside of tidy's Dockerfile
`tidy` will already install it (when needed) due to it being in `package.json`
2025-11-12 21:39:58 +02:00
Scott Schafer 554a6396d8 Update cargo 2025-11-12 10:08:16 -07:00
Shoyu Vanilla dae003b04b fix: Do not ICE when missing match arm with ill-formed subty is met 2025-11-13 01:36:35 +09:00
bors d6deffe2de Auto merge of #148552 - chenyukang:yukang-fix-148392-closure-diag, r=petrochenkov
Provide more general note for borrowing outside of closure

Fixes rust-lang/rust#148392
2025-11-12 14:32:06 +00:00
Mara Bos cfbdc2c36d Simplify loop in format_args lowering. 2025-11-12 14:56:58 +01:00
Mara Bos e9d212ddce Bless clippy tests. 2025-11-12 14:43:05 +01:00
Mara Bos 83a0d71e6d Add comment. 2025-11-12 14:33:41 +01:00
Mara Bos 2a14add94d Clarify comment. 2025-11-12 14:31:11 +01:00
Mara Bos 832a525692 Add debug assert. 2025-11-12 14:30:20 +01:00
Mara Bos fda03011ef Fix comment about potential niche in FormattingOptions. 2025-11-12 14:25:37 +01:00
Mara Bos 9b4843196c Bless coverage tests. 2025-11-12 12:48:45 +01:00
Mara Bos 8b20d0d0a1 Allow larger string pieces in fmt::Arguments repr. 2025-11-12 12:48:44 +01:00
Mara Bos f92c5f1c09 Change assert to span_err. 2025-11-12 12:48:44 +01:00
Mara Bos 3f85b01256 Clarify internal fmt::Arguments documentation. 2025-11-12 12:48:43 +01:00
Mara Bos ef1e3cadfd Bless clippy tests. 2025-11-12 12:48:39 +01:00
Mara Bos 04c5e7b54a Document fmt::Arguments internal representation. 2025-11-12 12:48:39 +01:00
Mara Bos 560b12d094 Don't encode zero width or precision in fmt string. 2025-11-12 12:48:38 +01:00
Mara Bos 564c78fe62 Remove the 'always set' bit from FormattingOptions.
We don't need it anymore.
2025-11-12 12:48:37 +01:00
Mara Bos be7a559a8a Make clippy happy. 2025-11-12 12:48:36 +01:00
Mara Bos 7b42543f81 Bless tests. 2025-11-12 12:48:27 +01:00
Mara Bos d66d15be2b New format_args!()+fmt::Arguments implementation. 2025-11-12 12:45:40 +01:00
Mara Bos 756751bf0c Expose expr_unsafe in LoweringContext. 2025-11-12 12:45:40 +01:00
bors 2fcbda6c1a Auto merge of #148466 - liigo:better-rustdoc, r=GuillaumeGomez
rustdoc: quality of life changes

- Support `=` shortcut (alongside `+`) to expand all sections. Already support `s` and `S`, `Shift` or not.
- ~~Fix search-input's placeholder. The input is auto focused, any key press will be accepted as input not shortcut, current placeholder is missleading.~~
2025-11-12 10:58:49 +00:00
yukang 4a2c9a11d5 skip invalid span in error emitter 2025-11-12 17:47:15 +08:00
bors 95aeb46965 Auto merge of #148424 - Zalathar:tests, r=Kobzol
bootstrap: Add snapshot tests for path-to-step handling

This PR adds a suite of snapshot tests for how bootstrap translates command-line “paths” (which are not necessarily actual paths) into a set of top-level steps to execute.

Unlike the existing suite of snapshot tests (for transitive step logging), I decided to use `.snap` files over inline snapshots, because I find that inline snapshots quickly make test files impossible to navigate. Instead, I set up a macro that makes it relatively easy to add or modify test cases.

Using `.snap` files also means that the tests can be blessed by setting `INSTA_UPDATE=always`, without necessarily needing the `cargo insta` tool installed, though the tool can still be used instead if desired.

These snapshot tests capture _current_ behavior, to prevent unintended changes or regressions. If the current behavior is wrong or undersirable, then any fix will necessarily have to re-bless the affected tests!

r? Kobzol
2025-11-12 06:53:53 +00:00
Liigo Zhuang 9f3d84b226 rustdoc: add = shortcut to expand all sections.
Essentially, `=` is "`+` without shift". Current `+` shortcut requires an extra `shift`, unless you use numpad `+`.
2025-11-12 14:29:10 +08:00
Zalathar 2412e1555c Add several snapshot tests for path-to-step handling 2025-11-12 13:16:52 +11:00
Zalathar 9d4620dde7 Set up snapshot tests for bootstrap's path-to-step handling 2025-11-12 13:15:15 +11:00
bors 0b329f801a Auto merge of #148851 - Zalathar:rollup-4y7ywyd, r=Zalathar
Rollup of 16 pull requests

Successful merges:

 - rust-lang/rust#146627 (Simplify `jemalloc` setup)
 - rust-lang/rust#147753 (Suggest add bounding value for RangeTo)
 - rust-lang/rust#147832 (rustdoc: Don't pass `RenderOptions` to `DocContext`)
 - rust-lang/rust#147974 (Improve diagnostics for buffer reuse with borrowed references)
 - rust-lang/rust#148080 ([rustdoc] Fix invalid jump to def macro link generation)
 - rust-lang/rust#148465 (Adjust spans into the `for` loops context before creating the new desugaring spans.)
 - rust-lang/rust#148500 (Update git index before running diff-index)
 - rust-lang/rust#148531 (rustc_target: introduce Abi, Env, Os)
 - rust-lang/rust#148536 (cmse: add test for `async` and `const` functions)
 - rust-lang/rust#148770 (implement `feature(c_variadic_naked_functions)`)
 - rust-lang/rust#148780 (fix filecheck typos in tests)
 - rust-lang/rust#148819 (Remove specialized warning for removed target)
 - rust-lang/rust#148830 (miri subtree update)
 - rust-lang/rust#148833 (Update rustbook dependencies)
 - rust-lang/rust#148834 (fix(rustdoc): Color doctest errors)
 - rust-lang/rust#148841 (Remove more `#[must_use]` from portable-simd)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-12 01:28:30 +00:00
Stuart Cook 2443cfb7a3 Rollup merge of #148841 - dtolnay:simdmustuse, r=calebzulawski
Remove more `#[must_use]` from portable-simd

These lines were missed in <https://github.com/rust-lang/rust/commit/f3515fb127ae07f1b13340dde0c61a20291eb304>/rust-lang/rust#136923 because core_simd/src/masks/bitmask.rs is only conditionally compiled.

https://github.com/rust-lang/rust/blob/25d319a0f656ee8faa7a534da299e76e96068a40/library/portable-simd/crates/core_simd/src/masks.rs#L9-L13

Removing them unblocks bootstrapping rustc in an environment where avx512f is enabled. Without this change:

```console
error: `#[must_use]` attribute cannot be used on trait methods in impl blocks
   --> library/core/src/../../portable-simd/crates/core_simd/src/masks/bitmask.rs:173:5
    |
173 |     #[must_use = "method returns a new mask and does not mutate the original value"]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = help: `#[must_use]` can be applied to data types, functions, unions, required trait methods, provided trait methods, inherent methods, foreign functions, and traits
    = note: `-D unused-attributes` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(unused_attributes)]`
```

To reproduce:

`RUSTC_BOOTSTRAP=1 RUSTFLAGS=-Ctarget-feature=+avx512f cargo +nightly check --manifest-path=library/portable-simd/crates/core_simd/Cargo.toml --target=x86_64-unknown-linux-gnu --no-default-features`
2025-11-12 12:26:44 +11:00
Stuart Cook 0675923ef8 Rollup merge of #148834 - Muscraft:fix-doctest-colors, r=fmease
fix(rustdoc): Color doctest errors

`@fmease's` [Deep analysis](https://github.com/rust-lang/rust/issues/148749#issuecomment-3508455278) on the problem
> Yeah, here's a deep analysis by me from a few weeks back of what's going on ([#148101 (comment)](https://github.com/rust-lang/rust/pull/148101#discussion_r2462756875)):
>
> > […]
> > However, since said PR ([#147207](https://github.com/rust-lang/rust/pull/147207): migrating coloring crates), `HumanEmitter::supports_color()` unconditionally(!) returns `false` (in fact, `Emitter::supports_color` is no longer used by anyone else and should be removed), so there's no reason to keep it. Rephrased, since that PR all compiler diagnostics for doctests are uncolored.
> > You could argue that I should keep it and patch `supports_color` in rustc to "work again". However, I'd rather rework our doctest coloring wholesale in a separate PR. At least before that migration PR, our setup was quite busted:
> >
> > 1. First of all, it didn't query+set `supports_color` for syntactically invalid doctests, so syntax errors were always shown without color (contrary to e.g., name resolution errors).
> > 2. Second of all, calling `supports_color()` here was quite frankly wrong: Piping the output of `rustdoc … --test` into a file (or `| cat` or whatever) did **not** suppress colors. I'm not actually sure if we can ever address that nicely (without stripping ANSI codes after the fact) since we pass that diagnostic to `libtest`, right? I might very well be wrong here, maybe it's a non-issue.

<hr>

```rust
/// ```
/// foo
/// ```
fn foo() {}
```
```
rustdoc --test lib.rs
```

Stable:
<img width="377" height="290" alt="stable" src="https://github.com/user-attachments/assets/cd20f947-b58d-42db-8735-797613baa9cc" />

Beta:
<img width="377" height="290" alt="beta" src="https://github.com/user-attachments/assets/f02588fd-41d2-4642-b03a-5554a68671eb" />

Nightly:
<img width="377" height="290" alt="nightly" src="https://github.com/user-attachments/assets/871cb417-f47e-4058-8a76-3bcd538ce141" />

After:
<img width="377" height="290" alt="after" src="https://github.com/user-attachments/assets/5734c01f-3f1c-44bb-9404-628c0c33b440" />

Note: This will need to be backported to `beta`

Fixes: rust-lang/rust#148749
2025-11-12 12:26:43 +11:00
Stuart Cook 9b7cfdfa0c Rollup merge of #148833 - clubby789:cargo-update-rustbook-11-11-25, r=ehuss
Update rustbook dependencies

https://github.com/rust-lang/rust/pull/145849#issuecomment-3394832713
2025-11-12 12:26:42 +11:00
Stuart Cook 39066236df Rollup merge of #148830 - RalfJung:miri, r=RalfJung
miri subtree update

Lands the new avx512 support for zlib-rs, and the epoll fixes for Tokio.

Subtree update of `miri` to https://github.com/rust-lang/miri/commit/667796bf66d8ff81feaed139d00f44878e26532b.

Created using https://github.com/rust-lang/josh-sync.

r? ````@ghost````
2025-11-12 12:26:42 +11:00
Stuart Cook 672c6b603c Rollup merge of #148819 - bjorn3:fix_fixme, r=jieyouxu
Remove specialized warning for removed target

It has been removed 9 months ago, which is more than a few months.
2025-11-12 12:26:41 +11:00
Stuart Cook 64b56378f5 Rollup merge of #148780 - klensy:filecheck-typo, r=jieyouxu
fix filecheck typos in tests

Fixes few filecheck annotation typos in tests.
2025-11-12 12:26:41 +11:00