Commit graph

307433 commits

Author SHA1 Message Date
Zalathar
b97bdcb0a0 Extract query-method inner functions to query::inner 2025-10-08 20:58:04 +11:00
Zalathar
c33b667e8b Hoist stranded use declarations 2025-10-08 17:59:22 +11:00
bors
f6aa851dba Auto merge of #147453 - matthiaskrgr:rollup-z3db8zi, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#146865 (kcfi: only reify trait methods when dyn-compatible)
 - rust-lang/rust#147205 (Add a new `wasm32-wasip3` target to Rust)
 - rust-lang/rust#147322 (cg_llvm: Consistently import `llvm::Type` and `llvm::Value`)
 - rust-lang/rust#147398 (Fix; correct placement of type inference error for method calls)
 - rust-lang/rust#147410 (Update `S-waiting-on-team` refs to new `S-waiting-on-{team}` labels)
 - rust-lang/rust#147422 (collect-license-metadata: Print a diff of the expected output)
 - rust-lang/rust#147431 (compiletest: Read the whole test file before parsing directives)
 - rust-lang/rust#147433 (Fix doc comment)

Failed merges:

 - rust-lang/rust#147390 (Use globals instead of metadata for std::autodiff)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-07 20:47:13 +00:00
Matthias Krüger
b5c3247b01
Rollup merge of #147433 - theemathas:theemathas-patch-1, r=chenyukang
Fix doc comment
2025-10-07 19:39:11 +02:00
Matthias Krüger
7b2e9fb442
Rollup merge of #147431 - Zalathar:directive, r=jieyouxu
compiletest: Read the whole test file before parsing directives

Few tests are larger than a handful of kilobytes, and nowadays we scan the whole file for directives anyway, so there's little reason not to just read the whole thing up-front.

This avoids having to deal with I/O within `iter_directives`, which should make it easier to overhaul directive processing.

r? jieyouxu
2025-10-07 19:39:10 +02:00
Matthias Krüger
68656b7579
Rollup merge of #147422 - jyn514:license-diff, r=Kobzol
collect-license-metadata: Print a diff of the expected output

Previously, `x test collect-license-metadata` gave the following message on errors:
```
gathering license information from REUSE (this might take a minute...)
finished gathering the license information from REUSE in 78.69s
loading existing license information
The existing /home/runner/work/ferrocene/ferrocene/license-metadata.json
file is out of date.
Run ./x run collect-license-metadata to update it.
Error: The existing
/home/runner/work/ferrocene/ferrocene/license-metadata.json file doesn't
match what REUSE reports.
Bootstrap failed while executing `test collect-license-metadata`
```

Notable, this doesn't actually say what went wrong. Print a diff in addition so it's more clear what broke:
```
...
                "license": {
                   "copyright": [
+                    "2010 The Rust Project Developers",
                     "2016, 2017, 2018, 2019, 2020, 2021 AXE Consultants. All Rights",
+                    "License. Subject to the terms and conditions of this",
                     "Notice",
-                    "The Ferrocene Developers"
+                    "The Ferrocene Developers",
+                    "[yyyy] [name of copyright owner]"
                   ],
...
```

Currently, this prints the entire text of the JSON file as context. That's not ideal, but it's rare for this to fail, so I think it's ok for now.

I considered using `assert_json_diff` instead of `similar`, but its errors are a lot harder to read IMO, even though they are better at omitting unnecessary context:

```
Diff: json atoms at path ".files.children[0].children[10].license.copyright[0]" are not equal:
    lhs:
        "2016 The Fuchsia Authors"
    rhs:
        "2019 The Crossbeam Project Developers"

json atoms at path ".files.children[0].children[10].license.spdx" are not equal:
    lhs:
        "BSD-2-Clause AND (Apache-2.0 OR MIT)"
    rhs:
        "Apache-2.0 OR MIT"

json atom at path ".files.children[0].children[10].children" is missing from lhs

json atoms at path ".files.children[0].children[10].name" are not equal:
    lhs:
        "library/std/src/sys/sync/mutex/fuchsia.rs"
    rhs:
        "library/std/src/sync/mpmc"
...
```
2025-10-07 19:39:09 +02:00
Matthias Krüger
a8cc1a2dab
Rollup merge of #147410 - Urgau:waiting-on-team-refactor, r=Kobzol
Update `S-waiting-on-team` refs to new `S-waiting-on-{team}` labels

Context: https://rust-lang.zulipchat.com/#narrow/channel/122651-general/topic/Team-based.20variant.20of.20.60S-waiting-on-team.60/with/542791637

r? `@Kobzol`
2025-10-07 19:39:09 +02:00
Matthias Krüger
0174900c5d
Rollup merge of #147398 - Jamesbarford:fix/method-call-type-inference-error, r=chenyukang
Fix; correct placement of type inference error for method calls

Addresses a FIXME for displaying errors on method calls;

Before;
```
error[E0282]: type annotations needed
  --> /<location>/src/main.rs:48:15
   |
## |             e.is_conversion_error();
   |               ^^^^^^^^^^^^^^^^^^^ cannot infer type
```

After;

```
error[E0282]: type annotations needed
  --> /<location>/src/main.rs:48:15
   |
## |             e.is_conversion_error();
   |             ^ cannot infer type
```
2025-10-07 19:39:08 +02:00
Matthias Krüger
d60f0a2b17
Rollup merge of #147322 - Zalathar:llvm-imports, r=jdonszelmann
cg_llvm: Consistently import `llvm::Type` and `llvm::Value`

We already have other modules that import these types and other types from `llvm`, so having the re-exports `type_::Type` and `value::Value` just distracts rust-analyzer and results in messier and less-consistent imports.

No functional change.
2025-10-07 19:39:07 +02:00
Matthias Krüger
60bbb533df
Rollup merge of #147205 - alexcrichton:wasip3, r=davidtwco
Add a new `wasm32-wasip3` target to Rust

This commit adds a new tier 3 target to rustc, `wasm32-wasip3`. This follows in the footsteps of the previous `wasm32-wasip2` target and is used to represent binding to the WASIp3 set of APIs managed by the WASI subgroup to the WebAssembly Community Group.

As of now the WASIp3 set of APIs are not finalized nor standardized. They're in the process of doing so and the current trajectory is to have the APIs published in December of this year. The goal here is to get the wheels turning in Rust to have the target in a
more-ready-than-nonexistent state by the time this happens in December.

For now the `wasm32-wasip3` target looks exactly the same as `wasm32-wasip2` except that `target_env = "p3"` is specified. This indicates to crates in the ecosystem that WASIp3 APIs should be used, such as the [`wasip3` crate]. Over time this target will evolve as implementation in guest toolchains progress, notably:

* The standard library will use WASIp3 APIs natively once they're finalized in the WASI subgroup.
* Support through `wasi-libc` will be updated to use WASIp3 natively which Rust will then transitively use.
* Longer-term, features such as cooperative multithreading will be added to the WASIp3-track of targets to enable using `std::thread`, for example, on this target.

These changes are all expected to be non-breaking changes for users of this target. Runtimes supporting WASIp3, currently Wasmtime and Jco, support WASIp2 APIs as well and will work with components whether or not they import WASIp2, both WASIp2 and WASIp3, or just WASIp3 APIs. This means that changing the internal implementation details of libstd over time is expected to be a non-breaking change.

[`wasip3` crate]: https://crates.io/crates/wasip3
2025-10-07 19:39:07 +02:00
Matthias Krüger
ffba05ee29
Rollup merge of #146865 - folkertdev:kcfi-only-reify-dyn-compatible, r=rcvalle
kcfi: only reify trait methods when dyn-compatible

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

Only generate a `ReifyShim` for trait method calls if the trait is dyn-compatible.

Until now kcfi would generate a `ReifyShim` whenever a trait method was cast to a function pointer. But technically the shim is only needed for dyn-compatible traits (where the method might end up in a vtable).

Up to this point that was only slightly inefficient, but in combination with c-variadic trait methods it is wrong. For c-variadic trait methods the generated shim is incorrect, and that is why c-variadic methods make a trait no longer dyn-compatible: we should simply never generate a `ReifyShim` that is c-variadic.

With this change the documentation on `ReifyReason` is now actually correct:

>  If KCFI is enabled, creating a function pointer from a method on a dyn-compatible trait. This includes the case of converting `::call`-like methods on closure-likes to function pointers.

cc ```@maurer``` ```@workingjubilee```

r? ```@rcvalle```
2025-10-07 19:39:06 +02:00
bors
d62f33a7c6 Auto merge of #147449 - matthiaskrgr:rollup-njyi5yr, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#145943 (stdlib docs: document lifetime extension for `format_args!`'s arguments)
 - rust-lang/rust#147243 (cmse: disallow `impl Trait` in `cmse-nonsecure-entry` return types)
 - rust-lang/rust#147402 ([rustdoc] Don't serialize & deserialize data that doesn't go OTW)
 - rust-lang/rust#147418 (Fix target list of `link_section`)
 - rust-lang/rust#147429 (Print tip for human error format in runtest)
 - rust-lang/rust#147441 (Fix comments error for Provenance impls)
 - rust-lang/rust#147442 (c-variadic: fix thir-print for `...` without a pattern)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-07 17:37:56 +00:00
Urgau
659575bfbe Add t- prefix to S-waiting-on-{team} labels 2025-10-07 18:15:02 +02:00
Matthias Krüger
5f03328084
Rollup merge of #147442 - folkertdev:thir-print-c-variadic, r=fmease
c-variadic: fix thir-print for `...` without a pattern

tracking issue: https://github.com/rust-lang/rust/issues/44930
fixes https://github.com/rust-lang/rust/issues/147409

r? `@fmease`
2025-10-07 17:42:15 +02:00
Matthias Krüger
883032b3d8
Rollup merge of #147441 - chenyukang:yukang-trivial-fix-comments, r=RalfJung
Fix comments error for Provenance impls

r? `@RalfJung`
2025-10-07 17:42:14 +02:00
Matthias Krüger
2d353c35e8
Rollup merge of #147429 - chenyukang:yukang-fix-test-tip, r=fmease
Print tip for human error format in runtest

When working on https://github.com/rust-lang/rust/pull/147354, spent some time to figure out that there is `//~ ERROR` left on test file, this PR will give a better error message for this scenario.
2025-10-07 17:42:13 +02:00
Matthias Krüger
0072d0cd1c
Rollup merge of #147418 - JonathanBrouwer:link_section_targets, r=jdonszelmann
Fix target list of `link_section`

Fixes https://github.com/rust-lang/rust/issues/147411#event-20124673569

r? `@jdonszelmann`
`@rustbot` beta-nominate T-compiler
2025-10-07 17:42:13 +02:00
Matthias Krüger
4461dd9f02
Rollup merge of #147402 - yotamofek:wip/rustdoc/search_index/impl-display, r=GuillaumeGomez
[rustdoc] Don't serialize & deserialize data that doesn't go OTW

`@GuillaumeGomez`
2025-10-07 17:42:12 +02:00
Matthias Krüger
7ab1fd1816
Rollup merge of #147243 - folkertdev:cmse-bail-impl-trait, r=davidtwco
cmse: disallow `impl Trait` in `cmse-nonsecure-entry` return types

tracking issue: https://github.com/rust-lang/rust/issues/75835
fixes https://github.com/rust-lang/rust/issues/147242

Refactors some logic to be more robust in the future, and then disallows `impl Trait` as a return type for the cmse ABIs.

The `is_valid_cmse_output_layout` function disallows `union` values like before. That is not entirely correct, but preserves the current behavior. Some additional logic is needed for `union` values (and any types where parts may be uninitialized) that I'll tackle in a later PR.

can be reviewed commit-by-commit.

r? types
2025-10-07 17:42:11 +02:00
Matthias Krüger
bce59abf1e
Rollup merge of #145943 - dianne:format-args-assign-docs, r=joboet
stdlib docs: document lifetime extension for `format_args!`'s arguments

Since rust-lang/rust#140748 is stable and rust-lang/rust#92698 is closed, the section about `format_args!`'s argument lifetime limitation is outdated. I've updated it to point to the Reference docs, which will specify lifetime extension rules for builtin macros once rust-lang/reference#1980 or equivalent is merged.

I've also taken the liberty of updating one of the doctests to assign the result of `format_args!` to a variable, both to provide an example and because I think it reads a little better.

r? `@m-ou-se`
2025-10-07 17:42:10 +02:00
Folkert de Vries
fbdc685ed0
cmse: disallow impl Trait in cmse-nonsecure-entry return types 2025-10-07 17:31:08 +02:00
bors
fed46ffd50 Auto merge of #145608 - Darksonn:derefmut-pin-fix, r=lcnr
Prevent downstream `impl DerefMut for Pin<LocalType>`

The safety requirements for [`PinCoerceUnsized`](https://doc.rust-lang.org/stable/std/pin/trait.PinCoerceUnsized.html) are essentially that the type does not have a malicious `Deref` or `DerefMut` impl. However, the `Pin` type is fundamental, so the end-user can provide their own implementation of `DerefMut` for `Pin<&SomeLocalType>`, so it's possible for `Pin` to have a malicious `DerefMut` impl. This unsoundness is known as rust-lang/rust#85099.

Unfortunately, this means that the implementation of `PinCoerceUnsized` for `Pin` is currently unsound. To fix that, modify the impl so that it becomes impossible for downstream crates to provide their own implementation of `DerefMut` for `Pin` by abusing a hidden struct that is not fundamental.

This PR is a breaking change, but it fixes rust-lang/rust#85099. The PR supersedes rust-lang/rust#144896.

r? lcnr
2025-10-07 14:26:48 +00:00
Folkert de Vries
0a3f1d5b98
c-variadic: fix thir-print for ... without a pattern 2025-10-07 16:00:39 +02:00
yukang
713e0dddfd Fix comments error for CtfeProvenance 2025-10-07 21:05:45 +08:00
Yotam Ofek
c5ab530749 move serde impls to separate module 2025-10-07 13:37:49 +03:00
yukang
f8ee9f018c Print tip for human error format when check fail 2025-10-07 18:28:31 +08:00
Yotam Ofek
978ab7c542 nicer serde impls 2025-10-07 13:23:10 +03:00
Yotam Ofek
eb8d87d1d8 avoid in-process serializing&deserializing 2025-10-07 12:58:05 +03:00
James Barford-Evans
43f7eaa0ba Fix; correct placement of type inference error for method calls 2025-10-07 09:51:16 +01:00
Tim (Theemathas) Chirananthavat
0fe466cc25
Fix doc comment 2025-10-07 14:47:39 +07:00
Jonathan Brouwer
1589c6c12d
Add regression test for link_section targets 2025-10-07 09:40:27 +02:00
Zalathar
525ed4cc5c Read the whole test file before parsing directives
Few tests are larger than a handful of kilobytes, and nowadays we scan the
whole file for directives anyway, so there's little reason not to just read the
whole thing up-front.

This avoids having to deal with I/O within `iter_directives`, which should make
it easier to overhaul directive processing.
2025-10-07 18:02:52 +11:00
bors
4a54b26d30 Auto merge of #147428 - matthiaskrgr:rollup-k3nlxlu, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#145495 (Use declarative macro for `#[derive(TryFromU32)]`)
 - rust-lang/rust#147165 (test: Subtract code_offset from width for ui_testing)
 - rust-lang/rust#147354 (Fix wrong span for hightlight for duplicated diff lines)
 - rust-lang/rust#147395 (Improve diagnostics: update note and add help message)
 - rust-lang/rust#147396 (Fluent tidy improvements)
 - rust-lang/rust#147407 (Update books)
 - rust-lang/rust#147413 (don't panic on extern with just multiple quotes in the name)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-07 06:42:11 +00:00
Matthias Krüger
21bf6db483
Rollup merge of #147413 - karolzwolak:extern-multiple-quotes, r=fmease
don't panic on extern with just multiple quotes in the name

Continues rust-lang/rust#147377.
That PR fixed ICE when the extern name was a single quote `"'"`, but multiple quotes like `"''"` cause the same problem.
I had a random revelation that the trimming can remove more than one quote.
r? ``@nnethercote``
2025-10-07 07:04:20 +02:00
Matthias Krüger
0471a5814a
Rollup merge of #147407 - rustbot:docs-update, r=ehuss
Update books

## rust-lang/reference

4 commits in e11adf6016a362766eea5a3f9832e193994dd0c8..8efb9805686722dba511b7b27281bb6b77d32130
2025-10-06 15:04:20 UTC to 2025-10-01 17:30:01 UTC

- Clarify that "or it is dropped" is meant restrictively (rust-lang/reference#2035)
- add lifetime extension tests for tuple struct temporaries (rust-lang/reference#2033)
- Add `target_env = "macabi"` and `target_env = "sim"` (rust-lang/reference#1781)
- Typo fixes for the Tokens page (additions -> editions) (rust-lang/reference#2031)
2025-10-07 07:04:20 +02:00
Matthias Krüger
1afc08dbfe
Rollup merge of #147396 - GuillaumeGomez:fluent-tidy-improvements, r=kobzol
Fluent tidy improvements

Follow-up of rust-lang/rust#147345 and of rust-lang/rust#147191.

It uses `fluent_syntax` to parse `fluent` files (but not for blessing, not even sure how the current one works).

I also added an `assert` to ensure we never go to previous situation where the `fluent` files were actually not checked at all.

cc ``@Kivooeo``
r? kobzol
2025-10-07 07:04:19 +02:00
Matthias Krüger
6332a76b3d
Rollup merge of #147395 - reddevilmidzy:refact-error-msg, r=Kivooeo,jackh726
Improve diagnostics: update note and add help message

I moved the content from the note to a help message, as it seemed more appropriate there, and then added new information to the note(`Modules are usually placed outside of blocks, at the top level of the file`)!

resolve: rust-lang/rust#147314
2025-10-07 07:04:18 +02:00
Matthias Krüger
f64703ce7a
Rollup merge of #147354 - chenyukang:yukang-fix-147070-wrong-highlight-span, r=estebank
Fix wrong span for hightlight for duplicated diff lines

Fixes rust-lang/rust#147070

From comments: https://github.com/rust-lang/rust/issues/147070#issuecomment-3368593144
The lightlight row for diff must at least 2.

r? `@estebank`
2025-10-07 07:04:17 +02:00
Matthias Krüger
4209a4661a
Rollup merge of #147165 - Muscraft:subtract-code-offset, r=davidtwco
test: Subtract code_offset from width for ui_testing

`annotate-snippets` does not have a "UI test" mode like `rustc`, [where the code offset is not subtracted from the column width](f34ba774c7/compiler/rustc_errors/src/emitter.rs (L1985-L1987)). This makes it so `annotate-snippets` will shift the output for some very long tests 5 - 7 columns to the left. As part of my work to have `rustc` use `annotate-snippets`, and to reduce the test differences between the two, I figured it would be best if `rustc` started subtracting the code offset from the width as well.

The first commit exists to keep the test output changes of adding a new line to a test separate from adding the `--diagnostic-width` flag in the second commit. This makes it easier to verify that adding the flag does not affect the test's output.

[Zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/147480-t-compiler.2Fdiagnostics/topic/annotate-snippets.20hurdles)
2025-10-07 07:04:17 +02:00
Matthias Krüger
0bf117f481
Rollup merge of #145495 - fee1-dead-contrib:push-tynlnktvrmrx, r=Zalathar
Use declarative macro for `#[derive(TryFromU32)]`

cc ``@Zalathar``
2025-10-07 07:04:16 +02:00
bors
d773bd07d6 Auto merge of #147099 - cjgillot:split-nop-landing, r=lcnr
Refactor remove_noop_landing_pads in two loops.

The point is to avoid clearing the CFG cache as often.

r? `@ghost` for perf
2025-10-07 03:31:27 +00:00
yukang
231c39545e Fix wrong span for hightlight for duplicated diff lines 2025-10-07 02:45:11 +00:00
bors
ff5be13e2d Auto merge of #146355 - cjgillot:gvn-union, r=jackh726
GVN: Support unions.

Supporting union values is not very hard, and allows to const-prop them.

r? `@ghost` for perf
2025-10-07 00:22:40 +00:00
Jynn Nelson
bc930cd2d1 collect-license-metadata: Print a diff of the expected output
Previously, `x test collect-license-metadata` gave the following message
on errors:
```
gathering license information from REUSE (this might take a minute...)
finished gathering the license information from REUSE in 78.69s
loading existing license information
The existing /home/runner/work/ferrocene/ferrocene/license-metadata.json
file is out of date.
Run ./x run collect-license-metadata to update it.
Error: The existing
/home/runner/work/ferrocene/ferrocene/license-metadata.json file doesn't
match what REUSE reports.
Bootstrap failed while executing `test collect-license-metadata`
```

Notable, this doesn't actually say what went wrong.
Print a diff in addition so it's more clear what broke:
```
...
                "license": {
                   "copyright": [
+                    "2010 The Rust Project Developers",
                     "2016, 2017, 2018, 2019, 2020, 2021 AXE Consultants. All Rights",
+                    "License. Subject to the terms and conditions of this",
                     "Notice",
-                    "The Ferrocene Developers"
+                    "The Ferrocene Developers",
+                    "[yyyy] [name of copyright owner]"
                   ],
...
```

Currently, this prints the entire text of the JSON file as context.
That's not ideal, but it's rare for this to fail, so I think it's ok for
now.

I considered using `assert_json_diff` instead of `similar`, but its
errors are a lot harder to read IMO, even though they are better at
omitting unnecessary context:

```
Diff: json atoms at path ".files.children[0].children[10].license.copyright[0]" are not equal:
    lhs:
        "2016 The Fuchsia Authors"
    rhs:
        "2019 The Crossbeam Project Developers"

json atoms at path ".files.children[0].children[10].license.spdx" are not equal:
    lhs:
        "BSD-2-Clause AND (Apache-2.0 OR MIT)"
    rhs:
        "Apache-2.0 OR MIT"

json atom at path ".files.children[0].children[10].children" is missing from lhs

json atoms at path ".files.children[0].children[10].name" are not equal:
    lhs:
        "library/std/src/sys/sync/mutex/fuchsia.rs"
    rhs:
        "library/std/src/sync/mpmc"
...
```
2025-10-06 19:10:12 -04:00
bors
68ad25392f Auto merge of #147405 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? Manishearth

`Cargo.lock` update due to `toml` version bump. This caused `serde_core` being added as a transitive dependency, so `tidy --bless` had to be run.

(Sorry for the late sync)
2025-10-06 21:12:23 +00:00
Jonathan Brouwer
4787834eda
Fix target list of link_section
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-10-06 23:04:09 +02:00
Karol Zwolak
cb06d91cd0 don't panic on extern with just multiple quotes in the name 2025-10-06 22:12:51 +02:00
Camille Gillot
96c3978eaa Repurpose defunct test. 2025-10-06 19:32:32 +00:00
Camille Gillot
5407eb8ca2 GVN: Support unions. 2025-10-06 19:31:40 +00:00
reddevilmidzy
02126adc1b Improve diagnostics: replace 'non-inline module' with 'file module' and update note/help messages 2025-10-07 02:53:45 +09:00