300211 Commits

Author SHA1 Message Date
Jieyou Xu
491b873d83
Add myself to infra-ci reviewer group 2025-07-17 17:33:44 +08:00
Jieyou Xu
2ca2d93035
Auto-label src/ci and .github/workflows with A-CI
And include `.github/workflows` for `T-infra` trigger files.
2025-07-17 17:32:26 +08:00
bors
014bd8290f Auto merge of #140399 - tiif:unstable_impl, r=lcnr,BoxyUwU
Implement unstable trait impl

This PR allows marking impls of stable trait with stable type as unstable.

## Approach

In std/core, an impl can be marked as unstable by annotating it with ``#[unstable_feature_bound(feat_name)]``. This will add a ``ClauseKind::Unstable_Feature(feat_name)`` to the list of predicates in ``predicates_of`` .

When an unstable impl's function is called, we will first iterate through all the goals in ``param_env`` to check if there is any ``ClauseKind::UnstableFeature(feat_name)`` in ``param_env``.

The existence of ``ClauseKind::Unstable_Feature(feat_name)`` in ``param_env`` means an``#[unstable_feature_bound(feat_name)]`` is present at the call site of the function, so we allow the check to succeed in this case.

If ``ClauseKind::UnstableFeature(feat_name)`` does not exist in ``param_env``, we will still allow the check to succeed for either of the cases below:
1. The feature is enabled through ``#[feature(feat_name)]`` outside of std / core.
2. We are in codegen because we may be monomorphizing a body from an upstream crate which had an unstable feature enabled that the downstream crate do not.

For the rest of the case, it will fail with ambiguity.

## Limitation

In this PR, we do not support:
1. using items that need ``#[unstable_feature_bound]`` within stable APIs
2. annotate main function with ``#[unstable_feature_bound]``
3. annotate ``#[unstable_feature_bound]`` on items other than free function and impl

## Acknowledgement
The design and mentoring are done by `@BoxyUwU`
2025-07-17 01:57:55 +00:00
bors
fd2eb391d0 Auto merge of #144019 - RalfJung:miri-sync, r=RalfJung
Miri subtree update

r? `@ghost`
2025-07-16 21:49:31 +00:00
bors
5795086bdf Auto merge of #144028 - samueltardieu:rollup-x6f9h8n, r=samueltardieu
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#142936 (rustdoc-json: Structured attributes)
 - rust-lang/rust#143355 (wrapping shift: remove first bitmask and table)
 - rust-lang/rust#143448 (remote-test-client: Exit code `128 + <signal-number>` instead of `3`)
 - rust-lang/rust#143692 (miri: fix out-of-bounds error for ptrs with negative offsets)
 - rust-lang/rust#143738 (Move several float tests to floats/mod.rs)
 - rust-lang/rust#143920 (Make more of codegen_llvm safe)
 - rust-lang/rust#143921 (Constify `Index` traits)
 - rust-lang/rust#143939 (Add 0323pin as maintainer of NetBSD targets, fix link to pkgsrc-wip and explain.)
 - rust-lang/rust#143948 (Update mdbook to 0.4.52)
 - rust-lang/rust#143957 (tidy: check for invalid file names)
 - rust-lang/rust#143968 (Add tracing to `InterpCx::fn_abi_of_instance/fn_abi_of_fn_ptr`)
 - rust-lang/rust#143990 (Add LocalKey<Cell>::update)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-16 15:10:02 +00:00
Samuel Tardieu
96a9df4cf9
Rollup merge of #143990 - camsteffen:localkey-cell, r=tgross35
Add LocalKey<Cell>::update

Tracking issue: rust-lang/rust#143989
2025-07-16 17:06:44 +02:00
Samuel Tardieu
2a8f97910a
Rollup merge of #143968 - Stypox:tracing-FnAbiOf, r=RalfJung
Add tracing to `InterpCx::fn_abi_of_instance/fn_abi_of_fn_ptr`

This PR adds tracing to the `InterpCx::fn_abi_of_instance`/`::fn_abi_of_fn_ptr` functions by shadowing `FnAbiOf`'s trait methods with inherent methods on `InterpCx`, like done in rust-lang/rust#142721. The reason why I am targeting these two functions is because they are used for Miri interpretation, and they make a `layout_of` query down the line without passing through the `layout_of` that was traced in rust-lang/rust#142721.

There are other places where `layout_of` is called without being traced (see the analysis below), but that's because the `Machine` used there is not `MiriMachine` but rather `CompileTimeMachine` which does not implement `enter_trace_span()`. But after discussing with ```````@RalfJung``````` we agreed that the const-eval part should not be traced together with Miri, that's why I am ignoring the other places where `layout_of` is called.

r? ```````@RalfJung```````

<details><summary>Analysis of the places where <code>layout_of</code> is called</summary>

I did some analysis for https://github.com/rust-lang/rust/pull/142721#discussion_r2171494841, and these are all the places where the query `tcx.layout_of` is called (directly or indirectly) outside of a traced `InterpCx::layout_of` while a program is being interpreted by Miri:

```
adjust_for_rust_scalar  at ./compiler/rustc_ty_utils/src/abi.rs:302:35
{closure#2}             at ./compiler/rustc_ty_utils/src/abi.rs:522:25
eval_body_using_ecx<>   at ./compiler/rustc_const_eval/src/const_eval/eval_queries.rs:49:22
{closure#1}<>           at ./compiler/rustc_const_eval/src/interpret/operand.rs:851:76
{closure#0}<>           at ./compiler/rustc_const_eval/src/interpret/stack.rs:612:18
size_and_align          at ./compiler/rustc_middle/src/mir/interpret/mod.rs:387:38
```

I got these by:
- patching rustc with this patch that adds a span to the `layout_of` query which prints the backtrace:
[layout_of_other_places.diff.txt](https://github.com/user-attachments/files/21235523/layout_of_other_places.diff.txt)
- adding this to my bootstrap.toml to have debug symbols inside the Miri binary: `rust.debuginfo-level = "line-tables-only"` and also `build.tool.miri.features = ["tracing"]`
- obtaining a trace file with `MIRI_TRACING=1 ./x.py run miri --stage 1 --warnings warn --args src/tools/miri/tests/pass/hello.rs` (note: maybe using a file different than "src/tools/miri/tests/pass/hello.rs" would lead to more places where layout_of is called?)
-  running this query in Perfetto to select all `layout_of` spans that have as a direct parent a span named "frame" (as opposed to the parent being `InterpCx::layout_of`) and extract their backtrace: `select args.string_value from slice left join args on slice.arg_set_id = args.id where slice.name = "tcx.layout_of" and slice.parent_id in (select slice2.id from slice as slice2 where slice2.name = "frame") group by args.string_value`
- exporting the data as `.tsv` and processing that file through this Python script. It finds the first path in the backtraces where "layout" isn't mentioned, which imo is a good heuristic to not consider `layout_of` wrappers/friends as call places, but rather go down the backtrace until an actual call place is reached. [layout_of_other_places.py.txt](https://github.com/user-attachments/files/21235529/layout_of_other_places.py.txt)

</details>
2025-07-16 17:06:43 +02:00
Samuel Tardieu
19470bc9c5
Rollup merge of #143957 - samueltardieu:tidy-filenames, r=Kobzol
tidy: check for invalid file names

Check for file names added to git with:
- non-UTF8 filenames (this would fail "fmt check" with a decoding error for the moment, but maybe we should not count on it as it is an accidental failure)
- control characters (such as "\n" or "\r" in file names)
- ":" (which is a special character on Windows, made rust-lang/rust#142936 fail in bors while it could have be caught earlier)

It only checks files known by git as a developer might want to have "strange" file names alongside their local repository as long as they don't check them in.

r? jieyouxu
as he stumbled upon such a file in rust-lang/rust#142936
2025-07-16 17:06:43 +02:00
Samuel Tardieu
645463a12d
Rollup merge of #143948 - ehuss:update-mdbook, r=Mark-Simulacrum
Update mdbook to 0.4.52

Changelog: https://github.com/rust-lang/mdBook/blob/master/CHANGELOG.md#mdbook-0452

This primarily picks up a few fixes.
2025-07-16 17:06:42 +02:00
Samuel Tardieu
cc685d8111
Rollup merge of #143939 - he32:netbsd-maintainers, r=jieyouxu
Add 0323pin as maintainer of NetBSD targets, fix link to pkgsrc-wip and explain.
2025-07-16 17:06:42 +02:00
Samuel Tardieu
9eda137008
Rollup merge of #143921 - oli-obk:const-index, r=fee1-dead
Constify `Index` traits

tracking issue: rust-lang/rust#143775

the `SliceIndex` trait cannot be implemented by users as it is sealed. While it would be useful for the `get` method on slices, it seems weird to have a feature gate for that that isn't also gating index syntax at the same time, so I put them under the same feature gate.

r? ```````@fee1-dead```````
2025-07-16 17:06:41 +02:00
Samuel Tardieu
b564ecf04b
Rollup merge of #143920 - oli-obk:cg-llvm-safety, r=jieyouxu
Make more of codegen_llvm safe

Best reviewed commit-by-commit.
2025-07-16 17:06:40 +02:00
Samuel Tardieu
096a66d8d8
Rollup merge of #143738 - rocurley:float_tests_refactor_2, r=tgross35
Move several float tests to floats/mod.rs

This PR moves several tests to `floats/mod.rs`, as discussed in https://github.com/rust-lang/rust/issues/141726. The tests moved are:

- `test_num_f*`
- `test_infinity`
- `test_neg_infinity`
- `test_zero`
- `test_neg_zero`
- `test_one`
- `test_is_nan`
- `test_is_infinite`
- `test_is_finite`
- `test_is_normal`
- `test_classify`

Each test is its own commit, so it may be easiest to review each commit individually.

r? tgross35
2025-07-16 17:06:40 +02:00
Samuel Tardieu
7b5e08f8ef
Rollup merge of #143692 - RalfJung:miri-oob, r=oli-obk
miri: fix out-of-bounds error for ptrs with negative offsets

r? ```````@oli-obk```````
2025-07-16 17:06:39 +02:00
Samuel Tardieu
17332ed916
Rollup merge of #143448 - Enselic:remote-test-client-signals, r=Mark-Simulacrum
remote-test-client: Exit code `128 + <signal-number>` instead of `3`

If the remote process is terminated by a signal, make `remote-test-client` exit with the code `128 + <signal-number>` instead of always `3`. This follows common practice among tools such as bash [^1]:

> When a command terminates on a fatal signal whose number is N, Bash uses the
> value 128+N as the exit status.

It also allows us to differentiate between `run-pass` and `run-crash` ui tests without special case code in compiletest for that when `remote-test-client` is used. See https://github.com/rust-lang/rust/pull/143002 and in particular https://github.com/rust-lang/rust/pull/143002#issuecomment-3037061667.

Exiting with code `3` has been done from the start (see https://github.com/rust-lang/rust/pull/39400) and seems arbitrary rather than a deliberate design decision, so changing it does not seem like an extraordinarily big deal.

### Regression testing

Note that https://github.com/rust-lang/rust/pull/143002 will act as a regression test once it is rebased on this PR.

### Why a separate PR

I think it is comforting to know that CI does not break with just this change. But if my reviewer prefers, we can move this commit to be part of https://github.com/rust-lang/rust/pull/143002 instead.

[^1]: https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
2025-07-16 17:06:38 +02:00
Samuel Tardieu
37aba8388e
Rollup merge of #143355 - hkBst:cleanup-shift-double-bitmask, r=Mark-Simulacrum
wrapping shift: remove first bitmask and table

```rust
        #[inline(always)]
        pub const fn wrapping_shl(self, rhs: u32) -> Self {
            // SAFETY: the masking by the bitsize of the type ensures that we do not shift
            // out of bounds
            unsafe {
                self.unchecked_shl(rhs & (Self::BITS - 1))
            }
        }
```
already does the bitmask, so it seems unnecessary here.

More context: internals.rust-lang.org/t/wrapping-shift-operator-code-doing-bitmasking-twice/23167
2025-07-16 17:06:38 +02:00
Samuel Tardieu
9f2015d3d3
Rollup merge of #142936 - aDotInTheVoid:rdj-shatts-forrealthistime, r=GuillaumeGomez
rustdoc-json: Structured attributes

Implements and closes rust-lang/rust#141358.

This has 2 primary benefits.

1. For rustdoc-json consumers, they no longer need to parse strings of attributes, but it's there in a structured and normalized way. CC ```@obi1kenobi```
2. For rustc conributors, the output of HIR pretty printing is no longer a versioned thing in the output. People can work on rust-lang/rust#131229 without needing to bump `FORMAT_VERSION`. CC ```@jdonszelmann``` ```@JonathanBrouwer.```

(Over time, as the attribute refractor continues, I expect we'll add new things to `rustdoc_json_types::Attribute`. But this can be done separately to the rustc changes).

Todo before being mergable:
- [x] Update test assertions.
- [x] Fix modeling of `#[repr]`.
- [ ] ~~Add tests of `#[doc(hidden)]` in `Item::attrs` (probably in a seperate PR).~~ I'm gonna punt this to a future PR
- [x] Documentation.
2025-07-16 17:06:37 +02:00
Ralf Jung
fe090dbb83
Merge pull request #4459 from ibraheemdev/ibraheem/global-ctor
Add support for global constructors (i.e. life before main)
2025-07-16 11:00:19 +00:00
bors
1c6de21509 Auto merge of #143458 - petrochenkov:bindnomod, r=SparrowLii
resolve: Merge `NameBindingKind::Module` into `NameBindingKind::Res`

This is a simplification, but also an optimization, because now we load modules from external crates in a more lazy fashion.
2025-07-16 10:58:42 +00:00
Ralf Jung
a7818abc14 minor tweaks and comments 2025-07-16 12:34:28 +02:00
Ralf Jung
ed212ffece
Merge pull request #4456 from nia-e/trace-incorporate-events
trace: incorporate events
2025-07-16 08:03:33 +00:00
Ibraheem Ahmed
7daf0e68e0
update comment to reference legacy .ctors section
Co-authored-by: Ralf Jung <post@ralfj.de>
2025-07-16 03:53:20 -04:00
Nia Espera
06f0dca106
hook up native-lib bits 2025-07-16 09:32:30 +02:00
bors
f21fbac535 Auto merge of #143998 - ehuss:update-cargo, r=ehuss
Update cargo

1 commits in eabb4cd923deb73e714f7ad3f5234d68ca284dbe..6833aa715d724437dc1247d0166afe314ab6854e
2025-07-09 22:07:55 +0000 to 2025-07-13 02:25:52 +0000
- Add `[hints]` table in `Cargo.toml`, and a `hints.mostly-unused` hint (rust-lang/cargo#15673)
2025-07-16 07:04:52 +00:00
Vadim Petrochenkov
7f398fd5f6 resolve: Optimize fn traits_in_module 2025-07-16 08:30:48 +03:00
Vadim Petrochenkov
1a9a226058 resolve: Import ty::Visibility everywhere 2025-07-16 08:30:48 +03:00
Vadim Petrochenkov
01b546a19b resolve: Remove trait ToNameBinding 2025-07-16 08:30:44 +03:00
Vadim Petrochenkov
babe2c0d0f resolve: Merge NameBindingKind::Module into NameBindingKind::Res 2025-07-16 08:28:17 +03:00
bors
231257f583 Auto merge of #144003 - ChrisDenton:ci4, r=ChrisDenton
Ensure home directory exists

This works around a missing mingw home directory in CI.
2025-07-16 03:17:45 +00:00
Chris Denton
262d02e6fd
Ensure home directory exists
This works around a missing mingw home directory in CI
2025-07-16 03:15:06 +00:00
Eric Huss
10bc064d89 Update cargo 2025-07-15 18:32:00 -07:00
Ibraheem Ahmed
d060859376 add test for global constructors 2025-07-15 17:24:47 -04:00
Ibraheem Ahmed
85c89494d9 add support for global constructors (i.e. life before main) 2025-07-15 17:24:44 -04:00
Cameron Steffen
1120cb2fe5 Add LocalKey<Cell>::update 2025-07-15 16:17:57 -05:00
Alona Enraght-Moony
078332fdc8 rustdoc-json: Structured attributes
Implements https://www.github.com/rust-lang/rust/issues/141358.

This has 2 primary benefits:

1. For rustdoc-json consumers, they no longer need to parse strings of
   attributes, but it's there in a structured and normalized way.
2. For rustc contributors, the output of HIR pretty printing is no
   longer a versioned thing in the output. People can work on
   https://github.com/rust-lang/rust/issues/131229 without needing to
   bump `FORMAT_VERSION`.

(Over time, as the attribute refractor continues, I expect we'll add new
things to `rustdoc_json_types::Attribute`. But this can be done
separately to the rustc changes).
2025-07-15 16:52:41 +00:00
Havard Eidnes
8770e5734e
Add 0323pin as target maintainer, and fix link to pkgsrc-wip and explain. 2025-07-15 23:57:33 +08:00
bors
3014e79f9c Auto merge of #143877 - xizheyin:143813, r=scottmcm,saethlin
`std::vec`: Add UB check for `set_len`, `from_raw_parts_in`, and etc.

Closes rust-lang/rust#143813

I noticed that `from_parts_in` do the similar things like `from_raw_parts_in`, so I add the UB check in the last commit. If it is not appropriate, I will remove it.

And I fix a typo in the first commit.

r? `@scottmcm`
2025-07-15 14:47:10 +00:00
Ralf Jung
62aea72e36
Merge pull request #4469 from Patrick-6/add-spinloop-hints
Add std::hint::spin_loop() to tests
2025-07-15 14:28:27 +00:00
Patrick-6
9a76dde4d2 Make spin function naming more consistent 2025-07-15 15:59:51 +02:00
tiif
e331de149f Fix CI 2025-07-15 13:48:30 +00:00
tiif
7dd28181e2 Add tests 2025-07-15 13:48:30 +00:00
tiif
7356ff7517 Implement other logics 2025-07-15 13:48:30 +00:00
tiif
dd067a689a Lint against having both #[unstable_feature_bound] and #[stable] on the same item 2025-07-15 13:48:30 +00:00
tiif
ab29256b96 Make stability attribute not to error when unstable feature bound is in effect 2025-07-15 13:48:30 +00:00
tiif
1e5c7b2877 Add the core logic in old and new solvers 2025-07-15 13:48:30 +00:00
tiif
2586185831 Lower the UnstableFeatureBound predicate to UnstableFeature predicate 2025-07-15 13:48:29 +00:00
tiif
fecd99881d Setup unstable feature bound attribute 2025-07-15 13:48:29 +00:00
Ralf Jung
da4006571b
Merge pull request #4452 from Stypox/trace-borrow-tracker
Add tracing spans to borrow tracker functions
2025-07-15 13:10:46 +00:00
Stypox
14f47009cc
Add InterpCx::fn_abi_of_instance/_fn_ptr with tracing, shadowing FnAbiOf 2025-07-15 15:04:53 +02:00
bors
e27f16a499 Auto merge of #143958 - samueltardieu:rollup-lh1s143, r=samueltardieu
Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#142301 (tests: Fix duplicated-path-in-error fail with musl)
 - rust-lang/rust#143630 (Drop `./x suggest`)
 - rust-lang/rust#143736 (Give all bytes of TypeId provenance)
 - rust-lang/rust#143752 (Don't panic if WASI_SDK_PATH not set when detecting compiler)
 - rust-lang/rust#143837 (Adjust `run_make_support::symbols` helpers)
 - rust-lang/rust#143878 (Port `#[pointee]` to the new attribute parsing infrastructure)
 - rust-lang/rust#143905 (Recover and suggest to use `;` to construct array type)
 - rust-lang/rust#143907 (core: make `str::split_at_unchecked()` inline)
 - rust-lang/rust#143910 (Add experimental `backtrace-trace-only` std feature)
 - rust-lang/rust#143927 (Preserve constness in trait objects up to hir ty lowering)
 - rust-lang/rust#143935 (rustc_type_ir/walk: move docstring to `TypeWalker` itself)
 - rust-lang/rust#143938 (Update books)
 - rust-lang/rust#143941 (update `cfg_select!` documentation)

Failed merges:

 - rust-lang/rust#143926 (Remove deprecated fields in bootstrap)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-15 11:42:55 +00:00