Commit Graph

309925 Commits

Author SHA1 Message Date
joboet 47342cf971 alloc: remove test of unsound specialization behaviour 2025-11-09 17:31:19 +01:00
joboet e4e765b1f6 add a TrivialClone implementation when deriving both Clone and Copy 2025-11-09 17:31:17 +01:00
joboet 5fb5861765 (almost) get rid of the unsound #[rustc_unsafe_specialization_marker] on Copy, introduce TrivialClone 2025-11-09 15:51:25 +01:00
bors acda5e9f9a Auto merge of #148692 - matthiaskrgr:rollup-hryk71f, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#145656 (Stabilize s390x `vector` target feature and `is_s390x_feature_detected!` macro)
 - rust-lang/rust#147024 (std_detect: Support run-time detection on OpenBSD using elf_aux_info)
 - rust-lang/rust#147534 (Implement SIMD funnel shifts in const-eval/Miri)
 - rust-lang/rust#147540 (Stabilise `as_array` in `[_]` and `*const [_]`; stabilise `as_mut_array` in `[_]` and `*mut [_]`.)
 - rust-lang/rust#147686 (update isolate_highest_one for NonZero<T>)
 - rust-lang/rust#148230 (rustdoc: Properly highlight shebang, frontmatter & weak keywords in source code pages and code blocks)
 - rust-lang/rust#148555 (Fix rust-by-example spanish translation)
 - rust-lang/rust#148556 (Fix suggestion for returning async closures)
 - rust-lang/rust#148585 ([rustdoc] Replace `print` methods with functions to improve code readability)
 - rust-lang/rust#148600 (re-use `self.get_all_attrs` result for pass indirectly attribute)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-09 01:40:19 +00:00
bors 72b21e1a64 Auto merge of #139558 - camelid:mgca-const-items, r=oli-obk,BoxyUwU
mgca: Add ConstArg representation for const items

tracking issue: rust-lang/rust#132980
fixes rust-lang/rust#131046
fixes rust-lang/rust#134641

As part of implementing `min_generic_const_args`, we need to distinguish const items that can be used in the type system, such as in associated const equality projections, from const items containing arbitrary const code, which must be kept out of the type system. Specifically, all "type consts" must be either concrete (no generics) or generic with a trivial expression like `N` or a path to another type const item.

To syntactically distinguish these cases, we require, for now at least, that users annotate all type consts with the `#[type_const]` attribute. Then, we validate that the const's right-hand side is indeed eligible to be a type const and represent it differently in the HIR.

We accomplish this representation using a new `ConstItemRhs` enum in the HIR, and a similar but simpler enum in the AST. When `#[type_const]` is **not** applied to a const (e.g. on stable), we represent const item right-hand sides (rhs's) as HIR bodies, like before. However, when the attribute is applied, we instead lower to a `hir::ConstArg`. This syntactically distinguishes between trivial const args (paths) and arbitrary expressions, which are represented using `AnonConst`s. Then in `generics_of`, we can take advantage of the existing machinery to bar the `AnonConst` rhs's from using parent generics.
2025-11-08 22:31:33 +00:00
Noah Lev 45391bdbf5 Add tests for mismatched type_const 2025-11-08 13:50:48 -05:00
Noah Lev ad69a7a449 Fix rustdoc UI tests
Also removed a test that was literally a duplicate of the one I kept.
2025-11-08 13:50:48 -05:00
Noah Lev 5171e42cec Fix rustdoc tests 2025-11-08 13:50:48 -05:00
Noah Lev 339dea8aec Fix rustfmt 2025-11-08 13:50:48 -05:00
Noah Lev 66267da3e9 Use "rhs" terminology instead of "body" 2025-11-08 13:50:48 -05:00
Noah Lev dbb33c77ab Update crashes tests based on fixed or changed ICEs 2025-11-08 13:50:48 -05:00
Noah Lev 91054e8042 Fix clippy
When mgca is enabled, const rhs's that are paths may have false
negatives with the lints in non_copy_const.rs. But these should probably
be using the trait solver anyway, and it only happens under mgca.
2025-11-08 13:50:48 -05:00
Noah Lev f532622aa8 Fix rustdoc 2025-11-08 13:50:48 -05:00
Boxy Uwu d663152fa7 use right span for inferrable ret ty 2025-11-08 13:50:48 -05:00
Boxy Uwu 0a355170c0 fix associated_const_equality tests 2025-11-08 13:50:48 -05:00
Boxy Uwu a7626dc996 Fix const qualifs under mgca 2025-11-08 13:50:48 -05:00
Noah Lev 9864a2fbca add const_of_item query and use it in normalization 2025-11-08 13:50:47 -05:00
bors fb23dd3c6b Auto merge of #148691 - bjorn3:sync_cg_clif-2025-11-08, r=bjorn3
Subtree sync for rustc_codegen_cranelift

The highlights this time are 4 Cranelift updates, some refactorings and a couple of bugfixes.
2025-11-08 16:44:23 +00:00
bjorn3 61c3458105 Add missing --check-cfg 2025-11-08 15:04:45 +00:00
Matthias Krüger bbd3ab82bb Rollup merge of #148600 - folkertdev:pass-indirectly-reuse-attrs, r=JonathanBrouwer
re-use `self.get_all_attrs` result for pass indirectly attribute

Could be a fix for a potential performance regression reported here https://github.com/rust-lang/rust/pull/144529#issuecomment-3491236458. Apparently the regression later disappeared. Nevertheless, this seems like a decent refactor.

r? ````@JonathanBrouwer```` (vaguely attribute-related, maybe there are other optimizations to that PR that we're missing)
2025-11-08 15:42:26 +01:00
Matthias Krüger f2beff65ca Rollup merge of #148585 - GuillaumeGomez:improve-format-code, r=yotamofek
[rustdoc] Replace `print` methods with functions to improve code readability

We have a lot of `print` methods, making it quite tricky to know what the types we're manipulating are.

We did something similar with `Clean` trait a few years ago (the first PR was https://github.com/rust-lang/rust/pull/99638, followed by a lot of them).

Each commit replaces one type for easier review.

r? `````@yotamofek`````
2025-11-08 15:42:25 +01:00
Matthias Krüger 624e7ebff4 Rollup merge of #148556 - chenyukang:yukang-fix-148493-async-closure, r=JonathanBrouwer
Fix suggestion for returning async closures

Fixes rust-lang/rust#148493
2025-11-08 15:42:24 +01:00
Matthias Krüger 4bbbea655a Rollup merge of #148555 - ehuss:rust-by-example-es, r=Kobzol
Fix rust-by-example spanish translation

A spanish translation was added in https://github.com/rust-lang/rust-by-example/pull/1910, but the upstream integration was never added.

```@marioidival,``` I assume you intended for this to go live?
2025-11-08 15:42:24 +01:00
Matthias Krüger a029c11188 Rollup merge of #148230 - fmease:rustdoc-highlight-tweaks, r=GuillaumeGomez
rustdoc: Properly highlight shebang, frontmatter & weak keywords in source code pages and code blocks

Before | After
---|---
<img width="517" height="532" alt="Screenshot 2025-10-28 at 23-21-02 pre rs - source" src="https://github.com/user-attachments/assets/5026761f-c604-4bcc-a699-9e75eb73dff6" /> | <img width="499" height="531" alt="Screenshot 2025-10-28 at 23-21-51 pre rs - source" src="https://github.com/user-attachments/assets/cc8c65e7-e3ad-4e20-a2c3-2623cf799093" />
2025-11-08 15:42:23 +01:00
Matthias Krüger 9ccff4ae27 Rollup merge of #147686 - vrtgs:non-zero-isolate, r=joboet
update isolate_highest_one for NonZero<T>

## Rationale
Let `x = self` and
`m = (((1 as $Int) << (<$Int>::BITS - 1)).wrapping_shr(self.leading_zeros()))`
Then the previous code computed `NonZero::new_unchecked(x & m)`.
Since `m` has exactly one bit set (the most significant 1-bit of `x`), `(x & m) == m`.
Therefore, the masking step was redundant.

The shift is safe and does not need wrapping because:
* `self.leading_zeros() < $Int::BITS` because `self` is non-zero.
* The result of `unchecked_shr` is non-zero, satisfying the `NonZero` invariant. if wrapping happens we would be violating `NonZero` invariants.

why this micro optimization?
the old code was suboptimal it duplicated `$Int`’s isolate_highest_one logic instead of delegating to it. Since the type already wraps `$Int`, either delegation should be used for clarity or, if keeping a custom implementation, it should be optimized as above.
2025-11-08 15:42:22 +01:00
Matthias Krüger da2e3aabca Rollup merge of #147540 - bjoernager:slice-as-array, r=Amanieu
Stabilise `as_array` in `[_]` and `*const [_]`; stabilise `as_mut_array` in `[_]` and `*mut [_]`.

Tracking issue: rust-lang/rust#133508

Closes: rust-lang/rust#133508

This PR stabilises the `as_array` and `as_mut_array` associated functions from the `core_slice_as_array` feature gate:

```rust
// core::slice

impl<T> [T] {
    pub const fn as_array<const N: usize>(&self) -> Option<&[T; N]>;

    pub const fn as_mut_array<const N: usize>(&mut self) -> Option<&mut [T; N]>;
}

// core::ptr

impl<T> *const [T] {
    pub const fn as_array<const N: usize>(self) -> Option<*const [T; N]>;
}

impl<T> *mut [T] {
    pub const fn as_mut_array<const N: usize>(self) -> Option<*mut [T; N]>;
}
```

It also updates the feature gates and tracking issues for all items associated with the previous `slice_as_array` tracking issue (including these four that are being stabilised).

~~FCP missing.~~
2025-11-08 15:42:22 +01:00
Matthias Krüger 0f786bd8fb Rollup merge of #147534 - sayantn:simd-funnel-shifts, r=RalfJung
Implement SIMD funnel shifts in const-eval/Miri

Split off from rust-lang/rust#147520 with just this change for easier review

r? ```@RalfJung```
2025-11-08 15:42:21 +01:00
Matthias Krüger da171df13c Rollup merge of #147024 - brad0:std_detect_openbsd_elf_aux_info, r=Mark-Simulacrum
std_detect: Support run-time detection on OpenBSD using elf_aux_info
2025-11-08 15:42:20 +01:00
Matthias Krüger 7d63382000 Rollup merge of #145656 - folkertdev:stabilize-s390x-vector, r=Amanieu
Stabilize s390x `vector` target feature and `is_s390x_feature_detected!` macro

closes https://github.com/rust-lang/rust/issues/145649
closes https://github.com/rust-lang/rust/issues/135413
cc: https://github.com/rust-lang/rust/issues/130869
reference PR: https://github.com/rust-lang/reference/pull/1972

# Stabilization report

## Summary

This PR stabilizes the following s390x target features:

- `vector`
- `vector-enhancements-1`
- `vector-enhancements-2`
- `vector-enhancements-3`
- `vector-packed-decimal`
- `vector-packed-decimal-enhancement`
- `vector-packed-decimal-enhancement-2`
- `vector-packed-decimal-enhancement-3`
- `nnp-assist`
- `miscellaneous-extensions-2`
- `miscellaneous-extensions-3`
- `miscellaneous-extensions-4`

Additionally, it stabilizes the `std::arch::is_s390x_feature_detected!` macro itself and stably accepts the target features listed above.

## Tests & ABI details

Only the `vector` target feature changes the ABI, much like e.g. `avx2` it will, depending on the ABI, pass vector types in vector registers. This behavior is tested extensively:

- [tests/assembly-llvm/s390x-vector-abi.rs](https://github.com/rust-lang/rust/blob/22a86f8280becb12c34ee3efd952baf5cf086fa0/tests/assembly-llvm/s390x-vector-abi.rs)
- [tests/codegen-llvm/s390x-simd.rs](https://github.com/rust-lang/rust/blob/22a86f8280becb12c34ee3efd952baf5cf086fa0/tests/assembly-llvm/s390x-vector-abi.rs)
- [tests/ui/abi/simd-abi-checks-s390x.rs ](https://github.com/rust-lang/rust/blob/22a86f8280becb12c34ee3efd952baf5cf086fa0/tests/ui/abi/simd-abi-checks-s390x.rs )

The remaining features don't influence the ABI, they only influence instruction selection. In stdarch we test that the expected instructions are in fact generated when the target feature is enabled.

## Implementation history

For `is_s390x_feature_detected!`:

- https://github.com/rust-lang/stdarch/pull/1699
- https://github.com/rust-lang/rust/pull/138275
- https://github.com/rust-lang/stdarch/pull/1720
- https://github.com/rust-lang/stdarch/pull/1832

For `vector` and friends

- https://github.com/rust-lang/rust/pull/127506
- https://github.com/rust-lang/rust/pull/135630
- https://github.com/rust-lang/rust/pull/141250

## Unresolved questions

There is a fixme in [tests/ui/abi/simd-abi-checks-s390x.rs](https://github.com/rust-lang/rust/blob/22a86f8280becb12c34ee3efd952baf5cf086fa0/tests/ui/abi/simd-abi-checks-s390x.rs):

```
// FIXME: +soft-float itself doesn't set -vector
//`@[z13_soft_float]` compile-flags: --target s390x-unknown-linux-gnu -C target-cpu=z13 -C target-feature=-vector,+soft-float
//`@[z13_soft_float]` needs-llvm-components: systemz
```

I'm not sure whether that blocks stabilization?

---

The implementation first extracts the listed target features into their own `s390x_target_feature_vector` rust feature, and then stabilizes that. best reviewed commit-by-commit

r? `@Amanieu`
cc `@uweigand`  `@taiki-e`
2025-11-08 15:42:19 +01:00
bjorn3 b2a66027fe Update tidy allowed dependencies 2025-11-08 14:26:36 +00:00
bjorn3 ff3c7f04a7 Merge commit 'a0b865dc8782500efe9623859017dd5e16f85407' into sync_cg_clif-2025-11-08 2025-11-08 14:18:53 +00:00
bjorn3 a0b865dc87 Fix simd_gather intrinsic 2025-11-08 13:35:51 +00:00
bjorn3 18882dd547 Rustup to rustc 1.93.0-nightly (843f8ce2e 2025-11-07) 2025-11-08 13:25:51 +00:00
bjorn3 0e41b6302b Sync from rust 843f8ce2eb 2025-11-08 13:18:47 +00:00
bors 87f9dcd5e2 Auto merge of #147935 - luca3s:add-rtsan, r=petrochenkov
Add LLVM realtime sanitizer

This is a new attempt at adding the [LLVM real-time sanitizer](https://clang.llvm.org/docs/RealtimeSanitizer.html) to rust.

Previously this was attempted in https://github.com/rust-lang/rfcs/pull/3766.

Since then the `sanitize` attribute was introduced in https://github.com/rust-lang/rust/pull/142681 and it is a lot more flexible than the old `no_santize` attribute. This allows adding real-time sanitizer without the need for a new attribute, like it was proposed in the RFC. Because i only add a new value to a existing command line flag and to a attribute i don't think an MCP is necessary.

Currently real-time santizer is usable in rust code with the [rtsan-standalone](https://crates.io/crates/rtsan-standalone) crate. This downloads or builds the sanitizer runtime and then links it into the rust binary.

The first commit adds support for more detailed sanitizer information.
The second commit then actually adds real-time sanitizer.
The third adds a warning against using real-time sanitizer with async functions, cloures and blocks because it doesn't behave as expected when used with async functions. I am not sure if this is actually wanted, so i kept it in a seperate commit.
The fourth commit adds the documentation for real-time sanitizer.
2025-11-08 12:24:15 +00:00
bors bbb6f68e28 Auto merge of #147803 - jsgf:move-copy-codegen, r=madsmtm,saethlin
Add -Zannotate-moves for profiler visibility of move/copy operations (codegen)

**Note:** this is an alternative implementation of https://github.com/rust-lang/rust/pull/147206; rather than being a MIR transform, it adds the annotations closer to codegen. It's functionally the same but the implementation is lower impact and it could be more correct.

---

This implements a new unstable compiler flag `-Zannotate-moves` that makes move and copy operations visible in profilers by creating synthetic debug information. This is achieved with zero runtime cost by manipulating debug info scopes to make moves/copies appear as calls to `compiler_move<T, SIZE>` and `compiler_copy<T, SIZE>` marker functions in profiling tools.

This allows developers to identify expensive move/copy operations in their code using standard profiling tools, without requiring specialized tooling or runtime instrumentation.

The implementation works at codegen time. When processing MIR operands (`Operand::Move` and `Operand::Copy`), the codegen creates an `OperandRef` with an optional `move_annotation` field containing an `Instance` of the appropriate profiling marker function. When storing the operand, `store_with_annotation()` wraps the store operation in a synthetic debug scope that makes it appear inlined from the marker.

Two marker functions (`compiler_move` and `compiler_copy`) are defined in `library/core/src/profiling.rs`. These are never actually called - they exist solely as debug info anchors.

Operations are only annotated if:
   - We're generating debug info and the feature is enabled.
   - Meets the size threshold (default: 65 bytes, configurable via `-Zannotate-moves=SIZE`), and is non-zero
   - Has a memory representation

This has a very small size impact on object file size. With the default limit it's well under 0.1%, and even with a very small limit of 8 bytes it's still ~1.5%. This could be enabled by default.
2025-11-08 07:57:14 +00:00
bors 4e0baae06d Auto merge of #148674 - weihanglo:update-cargo, r=weihanglo
Update cargo submodule

22 commits in 6368002885a04cbeae39a82cf5118f941559a40a..445fe4a68f469bf936b2fd81de2c503b233a7f4f
2025-10-31 14:31:52 +0000 to 2025-11-07 18:08:19 +0000
- fix(depinfo): prevent invalid trailing backslash on Windows (rust-lang/cargo#16223)
- refactor: Remove lazycell (rust-lang/cargo#16224)
- refactor: extract ConfigValue to its own module (rust-lang/cargo#16222)
- fix(config): non-mergeable list from cli should take priority (rust-lang/cargo#16220)
- fix(compile): build.warnings=deny shouldn't block hard warnings (rust-lang/cargo#16213)
- fix: display absolute path in the `missing in PATH` warning (rust-lang/cargo#16125)
- fix: non-mergeable list from config cli merge the same way  (rust-lang/cargo#16219)
- docs(contrib): Link out to rustc diagnostic style guide (rust-lang/cargo#16216)
- fix: Remove build-plan (rust-lang/cargo#16212)
- Add native completions for `--package` on various commands (rust-lang/cargo#16210)
- fix(completions): don't wrap completion item help in parenthesis (rust-lang/cargo#16215)
- refactor(locking): Make disabling locking on NFS mounts explicit (rust-lang/cargo#16177)
- docs(unstable): Move compile-time-deps out of Stabilized section (rust-lang/cargo#16211)
- docs(ref): Rename DEP_NAME_KEY to DEP_LINKS_KEY (rust-lang/cargo#16205)
- feat(build-analysis): emit rebuild reason log entry (rust-lang/cargo#16203)
- chore: Update dependencies (rust-lang/cargo#16200)
- chore(deps): update cargo-semver-checks to v0.45.0 (rust-lang/cargo#16190)
- chore(deps): update msrv (rust-lang/cargo#16178)
- refactor: embed deserialize validation logic in ProgressConfig (rust-lang/cargo#16194)
- refactor(gctx): extract config schema to a module (rust-lang/cargo#16195)
- chore: bump to 0.94.0; update changelog (rust-lang/cargo#16191)
- chore(deps): update rust crate gix to 0.74.0 (rust-lang/cargo#16186)

r? ghost
2025-11-08 03:33:10 +00:00
bors ceb7df7e6f Auto merge of #147029 - neuschaefer:memchr-2.7.6, r=marcoieni
Update memchr to 2.7.6

memchr 2.7.6 contains a bugfix for aarch64_be.

Note: I'm not sure about how dependency updates are managed in rust.git. If something should go through another branch or will happen automatically, please let me know.
2025-11-07 21:58:38 +00:00
Weihang Lo 2bd3508ed8 Update cargo submodule 2025-11-07 16:30:54 -05:00
Vrtgs 057127cfee update isolate_highest_one for NonZero<T> 2025-11-08 00:22:36 +03:00
Gabriel Bjørnager Jensen fa8e8649ad Stabilise 'as_array' in '[_]' and '*const [_]'; Stabilise 'as_mut_array' in '[_]' and '*mut [_]'; Update feature gate and tracking issue for 'alloc_slice_into_array' items; 2025-11-07 15:14:41 +01:00
bors 843f8ce2eb Auto merge of #147798 - Zalathar:uutils, r=jieyouxu
ci: Switch back to default coreutils (uutils) after libffi-sys bump

Now that Miri has updated to the latest `libffi-sys`, we should be able to remove the GNU coreutils workaround, and switch back to the default coreutils (uutils) in the runners using Ubuntu 25.10 images.

If we encounter any other uutils compatibility problems in the future, they should hopefully be easier to trace back to specific changes.

- https://github.com/rust-lang/rust/pull/147581
- https://github.com/rust-lang/miri/pull/4634
- https://github.com/rust-lang/rust/pull/147744

Closes rust-lang/rust#147556.
2025-11-07 13:49:36 +00:00
Guillaume Gomez 0f0342949d Replace Display::fmt with write_char 2025-11-07 11:45:29 +01:00
Guillaume Gomez f2794ce6c0 Switch clean print methods into a function 2025-11-07 11:42:04 +01:00
sayantn a7aedeb5c8 implement SIMD funnel shifts in const-eval 2025-11-07 16:09:50 +05:30
bors 96064126a0 Auto merge of #147641 - cjgillot:liveness-cache-strings, r=estebank
Liveness: Cache the set of string constants for suggestions.

Even on a slow diagnostic path, listing all the constants in MIR can be expensive, so cache it.
2025-11-07 09:50:49 +00:00
bors 0bbef557bb Auto merge of #148624 - jhpratt:rollup-is5je9r, r=jhpratt
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#145768 (Offload device)
 - rust-lang/rust#145992 (Stabilize `vec_deque_pop_if`)
 - rust-lang/rust#147416 (Early return if span is from expansion so we dont get empty span and ice later on)
 - rust-lang/rust#147808 (btree: cleanup difference, intersection, is_subset)
 - rust-lang/rust#148520 (style: Use binary literals instead of hex literals in doctests for `highest_one` and `lowest_one`)
 - rust-lang/rust#148559 (Add typo suggestion for a misspelt Cargo environment variable)
 - rust-lang/rust#148567 (Fix incorrect precedence caused by range expression)
 - rust-lang/rust#148570 (Fix mismatched brackets in generated .dir-locals.el)
 - rust-lang/rust#148575 (fix dev guide link in rustc_query_system/dep_graph/README.md)
 - rust-lang/rust#148578 (core docs: add notes about availability of `Atomic*::from_mut_slice`)
 - rust-lang/rust#148603 (Backport 1.91.1 relnotes to main)
 - rust-lang/rust#148609 (Sync str::rsplit_once example with str::split_once)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-07 06:42:51 +00:00
Jacob Pratt c932d7c45f Rollup merge of #148609 - AMDmi3:rsplit_once_example, r=chenyukang
Sync str::rsplit_once example with str::split_once

This adds `"cfg=".rsplit_once('=')` case to `rsplit_once` example, bringing it in sync with example for `split_once`. For consistency and to make life easier for ones who want to ensure bahaviour of this specific edge case.
2025-11-07 00:21:24 -05:00
Jacob Pratt 0dafd5057f Rollup merge of #148603 - pietroalbini:ea-1.91.1-relnotes, r=pietroalbini
Backport 1.91.1 relnotes to main

Backport of the release notes from https://github.com/rust-lang/rust/pull/148593 to the main branch. This should land before Monday so that the automation creates the GitHub release.
2025-11-07 00:21:23 -05:00
Jacob Pratt 9d001902ae Rollup merge of #148578 - WaffleLapkin:equal-alignment-atomic-from-mut-slice, r=m-ou-se
core docs: add notes about availability of `Atomic*::from_mut_slice`

See https://github.com/rust-lang/rust/issues/76314#issuecomment-3496758620

r? libs-api
2025-11-07 00:21:23 -05:00