From 0e4bebafa9c81d6fc0559beba1344ad2b230a5d4 Mon Sep 17 00:00:00 2001 From: Urgau Date: Thu, 29 Jan 2026 18:24:29 +0100 Subject: [PATCH 01/20] Add basic triagebot configuration --- triagebot.toml | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 triagebot.toml diff --git a/triagebot.toml b/triagebot.toml new file mode 100644 index 0000000000000..43048b5e4514c --- /dev/null +++ b/triagebot.toml @@ -0,0 +1,44 @@ +## See for documentation +## of these features. + +# Allow users to use labels commands. +# Documentation at: https://forge.rust-lang.org/triagebot/labeling.html +[relabel] +allow-unauthenticated = [ + "A-*", + "C-*", + "E-*", + "F-*", + "I-*", + "ISA-*", + "O-*", +] + +# Allow users to assign 'r?` someone to an issue or PR. +# Documentation at: https://forge.rust-lang.org/triagebot/issue-assignment.html +[assign] +warn_non_default_branch = true + +# Warns when a PR contains merge commits +# Documentation at: https://forge.rust-lang.org/triagebot/no-merge.html +[no-merges] +exclude_titles = ["Sync from"] + +# Canonicalize issue numbers to avoid closing the wrong issue +# when commits are included in upstream sync, as well as warning links in commits. +# Documentation at: https://forge.rust-lang.org/triagebot/issue-links.html +[issue-links] +check-commits = "uncanonicalized" + +# Enable issue transfers within the org +# Documentation at: https://forge.rust-lang.org/triagebot/transfer.html +[transfer] + +# Enable comments linking to triagebot range-diff when a PR is rebased +# onto a different base commit +# Documentation at: https://forge.rust-lang.org/triagebot/range-diff.html +[range-diff] + +# Add link to the review body to review changes since posting it. +# Documentation at: https://forge.rust-lang.org/triagebot/review-changes-since.html +[review-changes-since] From 01f91e468c6950e598421b5e9ca202381dbb3ed6 Mon Sep 17 00:00:00 2001 From: okaneco <47607823+okaneco@users.noreply.github.com> Date: Sat, 7 Feb 2026 01:26:56 -0500 Subject: [PATCH 02/20] Add `Select` and `ToBytes` to prelude --- crates/core_simd/src/simd/prelude.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/core_simd/src/simd/prelude.rs b/crates/core_simd/src/simd/prelude.rs index e5d7a2aeb73df..6e93f16e10b1c 100644 --- a/crates/core_simd/src/simd/prelude.rs +++ b/crates/core_simd/src/simd/prelude.rs @@ -7,7 +7,7 @@ #[doc(no_inline)] pub use super::{ - Mask, Simd, + Mask, Select, Simd, ToBytes, cmp::{SimdOrd, SimdPartialEq, SimdPartialOrd}, num::{SimdFloat, SimdInt, SimdUint}, ptr::{SimdConstPtr, SimdMutPtr}, From a8af194738bb6e12de64bb3ee00b47090a37eda1 Mon Sep 17 00:00:00 2001 From: b01o Date: Sun, 8 Feb 2026 13:37:49 +0800 Subject: [PATCH 03/20] docs(simd): fix `load_select_or_default` documentation --- crates/core_simd/src/vector.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/core_simd/src/vector.rs b/crates/core_simd/src/vector.rs index 5b3a689f3611b..37930ab495a28 100644 --- a/crates/core_simd/src/vector.rs +++ b/crates/core_simd/src/vector.rs @@ -363,7 +363,7 @@ where /// corresponding element in `enable` is `true`. /// /// When the element is disabled or out of bounds for the slice, that memory location - /// is not accessed and the corresponding value from `or` is passed through. + /// is not accessed and the default value for the element type is returned. /// /// # Examples /// ``` @@ -371,12 +371,11 @@ where /// # #[cfg(feature = "as_crate")] use core_simd::simd; /// # #[cfg(not(feature = "as_crate"))] use core::simd; /// # use simd::{Simd, Mask}; - /// let vec: Vec = vec![10, 11, 12, 13, 14, 15, 16, 17, 18]; + /// let vec: Vec = vec![10, 11]; /// let enable = Mask::from_array([true, true, false, true]); - /// let or = Simd::from_array([-5, -4, -3, -2]); /// - /// let result = Simd::load_select(&vec, enable, or); - /// assert_eq!(result, Simd::from_array([10, 11, -3, 13])); + /// let result = Simd::load_select_or_default(&vec, enable); + /// assert_eq!(result, Simd::from_array([10, 11, 0, 0])); /// ``` #[must_use] #[inline] From 08aa04d7aa398732cca0c72643d090dbba23f6a7 Mon Sep 17 00:00:00 2001 From: b01o Date: Sun, 8 Feb 2026 15:12:24 +0800 Subject: [PATCH 04/20] show both kinds of masking-out elements in the example --- crates/core_simd/src/vector.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/core_simd/src/vector.rs b/crates/core_simd/src/vector.rs index 37930ab495a28..f1a76a1a9649c 100644 --- a/crates/core_simd/src/vector.rs +++ b/crates/core_simd/src/vector.rs @@ -371,11 +371,11 @@ where /// # #[cfg(feature = "as_crate")] use core_simd::simd; /// # #[cfg(not(feature = "as_crate"))] use core::simd; /// # use simd::{Simd, Mask}; - /// let vec: Vec = vec![10, 11]; - /// let enable = Mask::from_array([true, true, false, true]); + /// let vec: Vec = vec![10, 11, 12]; + /// let enable = Mask::from_array([true, true, false, true, false]); /// /// let result = Simd::load_select_or_default(&vec, enable); - /// assert_eq!(result, Simd::from_array([10, 11, 0, 0])); + /// assert_eq!(result, Simd::from_array([10, 11, 0, 0, 0])); /// ``` #[must_use] #[inline] From 81dcf4c4a8bd3829bb823e1e180f15ec51a78b35 Mon Sep 17 00:00:00 2001 From: b01o Date: Sun, 8 Feb 2026 15:28:29 +0800 Subject: [PATCH 05/20] more clear example --- crates/core_simd/src/vector.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/core_simd/src/vector.rs b/crates/core_simd/src/vector.rs index f1a76a1a9649c..c8e0b8c7eb9b3 100644 --- a/crates/core_simd/src/vector.rs +++ b/crates/core_simd/src/vector.rs @@ -372,10 +372,10 @@ where /// # #[cfg(not(feature = "as_crate"))] use core::simd; /// # use simd::{Simd, Mask}; /// let vec: Vec = vec![10, 11, 12]; - /// let enable = Mask::from_array([true, true, false, true, false]); + /// let enable = Mask::from_array([false, true, true, true]); /// /// let result = Simd::load_select_or_default(&vec, enable); - /// assert_eq!(result, Simd::from_array([10, 11, 0, 0, 0])); + /// assert_eq!(result, Simd::from_array([0, 11, 12, 0])); /// ``` #[must_use] #[inline] From af5171205fef878164b72b9372661fd1382cc737 Mon Sep 17 00:00:00 2001 From: ron Date: Tue, 10 Feb 2026 10:50:42 -0500 Subject: [PATCH 06/20] Fix typos in documentation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - beginners-guide.md: fix missing letter ("within you" → "within your") - .github/PULL_REQUEST_TEMPLATE.md: remove duplicate word ("tests for test interactions" → "tests for interactions") --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- beginners-guide.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 31422b7934501..5d354305e56de 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -10,7 +10,7 @@ For a given vector math operation on TxN, please add tests for interactions with - [ ] 0 -For a given vector math operation on TxN where T is a float, please add tests for test interactions with: +For a given vector math operation on TxN where T is a float, please add tests for interactions with: - [ ] a really large number, larger than the mantissa - [ ] a really small "subnormal" number - [ ] NaN diff --git a/beginners-guide.md b/beginners-guide.md index 4250a18315a6e..c56873ea4b8d7 100644 --- a/beginners-guide.md +++ b/beginners-guide.md @@ -56,7 +56,7 @@ The list notes the bit widths available at each feature level, though the operat ### Selecting Additional Target Features -If you want to enable support for a target feature within your build, generally you should use a [target-feature](https://rust-lang.github.io/packed_simd/perf-guide/target-feature/rustflags.html#target-feature) setting within you `RUSTFLAGS` setting. +If you want to enable support for a target feature within your build, generally you should use a [target-feature](https://rust-lang.github.io/packed_simd/perf-guide/target-feature/rustflags.html#target-feature) setting within your `RUSTFLAGS` setting. If you know that you're targeting a specific CPU you can instead use the [target-cpu](https://rust-lang.github.io/packed_simd/perf-guide/target-feature/rustflags.html#target-cpu) flag and the compiler will enable the correct set of features for that CPU. From e66819d2cf58f4030203b88138ca8b3942cfa9dc Mon Sep 17 00:00:00 2001 From: Ronen Ulanovsky Date: Sat, 21 Feb 2026 19:42:47 +0200 Subject: [PATCH 07/20] Add round_ties_even to StdFloat trait Adds `round_ties_even` using `simd_round_ties_even` intrinsic, matching the scalar `f32::round_ties_even` / `f64::round_ties_even` API. Closes rust-lang/portable-simd#390 --- crates/core_simd/tests/round.rs | 8 ++++++++ crates/std_float/src/lib.rs | 8 ++++++++ crates/std_float/tests/float.rs | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/crates/core_simd/tests/round.rs b/crates/core_simd/tests/round.rs index 4c1ac3c36f894..95b17f415822b 100644 --- a/crates/core_simd/tests/round.rs +++ b/crates/core_simd/tests/round.rs @@ -42,6 +42,14 @@ macro_rules! float_rounding_test { ) } + fn round_ties_even() { + test_helpers::test_unary_elementwise( + &Vector::::round_ties_even, + &Scalar::round_ties_even, + &|_| true, + ) + } + fn fract() { test_helpers::test_unary_elementwise_flush_subnormals( &Vector::::fract, diff --git a/crates/std_float/src/lib.rs b/crates/std_float/src/lib.rs index b269efc9b1d76..acc1bfc19501a 100644 --- a/crates/std_float/src/lib.rs +++ b/crates/std_float/src/lib.rs @@ -156,6 +156,14 @@ pub trait StdFloat: Sealed + Sized { unsafe { intrinsics::simd_trunc(self) } } + /// Rounds each element to the nearest integer-valued float. + /// Ties are resolved by rounding to the number with an even least significant digit. + #[must_use = "method returns a new vector and does not mutate the original value"] + #[inline] + fn round_ties_even(self) -> Self { + unsafe { intrinsics::simd_round_ties_even(self) } + } + /// Returns the floating point's fractional value, with its integer part removed. #[must_use = "method returns a new vector and does not mutate the original value"] fn fract(self) -> Self; diff --git a/crates/std_float/tests/float.rs b/crates/std_float/tests/float.rs index c608ba49564e0..797e12ec71402 100644 --- a/crates/std_float/tests/float.rs +++ b/crates/std_float/tests/float.rs @@ -71,7 +71,7 @@ macro_rules! impl_tests { mod $scalar { use std_float::StdFloat; - unary_test! { $scalar, sqrt, ceil, floor, round, trunc } + unary_test! { $scalar, sqrt, ceil, floor, round, trunc, round_ties_even } ternary_test! { $scalar, mul_add } // https://github.com/rust-lang/miri/issues/3555 From dc5ab0d0490d9ac6f3cb0899f887f5b6fd3c4a64 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Sat, 14 Mar 2026 16:11:08 +0100 Subject: [PATCH 08/20] update `proptest` from `0.10` to `1.0` --- Cargo.lock | 96 ++++++++++++++++++++++++---------- crates/core_simd/Cargo.toml | 8 ++- crates/test_helpers/Cargo.toml | 2 +- 3 files changed, 77 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5a5f0d8907ae3..754a93653ee7f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,9 +10,9 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "bitflags" -version = "1.3.2" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" [[package]] name = "bumpalo" @@ -20,12 +20,6 @@ version = "3.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - [[package]] name = "cc" version = "1.2.33" @@ -45,6 +39,7 @@ checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" name = "core_simd" version = "0.1.0" dependencies = [ + "getrandom", "proptest", "std_float", "test_helpers", @@ -61,6 +56,20 @@ dependencies = [ "num-traits", ] +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi", + "wasip2", + "wasm-bindgen", +] + [[package]] name = "js-sys" version = "0.3.77" @@ -71,6 +80,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "libc" +version = "0.2.183" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" + [[package]] name = "log" version = "0.4.27" @@ -122,16 +137,17 @@ dependencies = [ [[package]] name = "proptest" -version = "0.10.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12e6c80c1139113c28ee4670dc50cc42915228b51f56a9e407f0ec60f966646f" +checksum = "37566cb3fdacef14c0737f9546df7cfeadbfbc9fef10991038bf5015d0c80532" dependencies = [ "bitflags", - "byteorder", "num-traits", "rand", "rand_chacha", "rand_xorshift", + "regex-syntax", + "unarray", ] [[package]] @@ -143,22 +159,27 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + [[package]] name = "rand" -version = "0.7.3" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" dependencies = [ "rand_chacha", "rand_core", - "rand_hc", ] [[package]] name = "rand_chacha" -version = "0.2.2" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", "rand_core", @@ -166,28 +187,28 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.5.1" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" dependencies = [ - "rand_core", + "getrandom", ] [[package]] name = "rand_xorshift" -version = "0.2.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8" +checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a" dependencies = [ "rand_core", ] +[[package]] +name = "regex-syntax" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" + [[package]] name = "rustversion" version = "1.0.22" @@ -238,6 +259,12 @@ dependencies = [ "proptest", ] +[[package]] +name = "unarray" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" + [[package]] name = "unicode-ident" version = "1.0.18" @@ -254,6 +281,15 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + [[package]] name = "wasm-bindgen" version = "0.2.100" @@ -441,6 +477,12 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" + [[package]] name = "zerocopy" version = "0.8.26" diff --git a/crates/core_simd/Cargo.toml b/crates/core_simd/Cargo.toml index 537ce459c07cd..b388aaae86660 100644 --- a/crates/core_simd/Cargo.toml +++ b/crates/core_simd/Cargo.toml @@ -18,10 +18,16 @@ wasm-bindgen = "0.2" wasm-bindgen-test = "0.3" [dev-dependencies.proptest] -version = "0.10" +version = "1.0" default-features = false features = ["alloc"] +# Enable the `wasm_js` feature so that getrandom works on wasm32-unknown-unknown. +[dev-dependencies.getrandom] +version = "0.3.4" +default-features = false +features = ["wasm_js"] + [dev-dependencies.test_helpers] path = "../test_helpers" diff --git a/crates/test_helpers/Cargo.toml b/crates/test_helpers/Cargo.toml index 408bb04c7aa40..f1e0a9b29a962 100644 --- a/crates/test_helpers/Cargo.toml +++ b/crates/test_helpers/Cargo.toml @@ -5,5 +5,5 @@ edition = "2021" publish = false [dependencies] -proptest = { version = "0.10", default-features = false, features = ["alloc"] } +proptest = { version = "1.0", default-features = false, features = ["alloc", "std"] } float-cmp = "0.10" From 5c37faf35c77439b16f76d3a3a4e2c5a2e14a33f Mon Sep 17 00:00:00 2001 From: Karl Meakin Date: Sat, 14 Mar 2026 18:36:00 +0000 Subject: [PATCH 09/20] Add tests for `Mask::first_set` Add exhuastive tests for `Mask::first_set` for all masks of size 8. --- crates/core_simd/tests/masks.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/core_simd/tests/masks.rs b/crates/core_simd/tests/masks.rs index 53fb2367b6055..98a74be8e3955 100644 --- a/crates/core_simd/tests/masks.rs +++ b/crates/core_simd/tests/masks.rs @@ -133,6 +133,19 @@ macro_rules! test_mask_api { cast_impl::(); cast_impl::(); } + + #[test] + fn first_set() { + for bitmask in 0..=u8::MAX { + let mask = Mask::<$type, 8>::from_bitmask(bitmask as u64); + let expected = if bitmask == 0 { + None + } else { + Some(bitmask.trailing_zeros() as usize) + }; + assert_eq!(mask.first_set(), expected); + } + } } } } From b99b62c2d969c47d92fbb48606388a5bc96081ec Mon Sep 17 00:00:00 2001 From: Karl Meakin Date: Sat, 14 Mar 2026 18:31:47 +0000 Subject: [PATCH 10/20] Optimize `Mask::first_set` Apply two optimizations to `Mask::first_set`: 1) Move the call to `simd_cast` into the `const` block when initializing `index`. This removes runtime shuffles necessary to translate a `Simd` to a `Simd`. 2) Replace the call to `mask.select` with `simd_or(!self, index)`. This is cheaper than doing a comparison and on some architectures the `or` can be combined with the `not` into a single instruction. See https://godbolt.org/z/YebG6aoMY for an example of the difference in generated assembly. --- crates/core_simd/src/masks.rs | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/crates/core_simd/src/masks.rs b/crates/core_simd/src/masks.rs index 3e2209556b66b..a5334afbe5f8b 100644 --- a/crates/core_simd/src/masks.rs +++ b/crates/core_simd/src/masks.rs @@ -371,22 +371,20 @@ where // * perform _unsigned_ reduce-min // * check if the result is -1 or an index - let index = Simd::from_array( - const { - let mut index = [0; N]; - let mut i = 0; - while i < N { - index[i] = i; - i += 1; - } - index - }, - ); + let index: Simd = const { + let mut index = [0; N]; + let mut i = 0; + while i < N { + index[i] = i; + i += 1; + } + // Safety: the input and output are integer vectors + unsafe { core::intrinsics::simd::simd_cast(Simd::from_array(index)) } + }; // Safety: the input and output are integer vectors - let index: Simd = unsafe { core::intrinsics::simd::simd_cast(index) }; - - let masked_index = self.select(index, Self::splat(true).to_simd()); + let masked_index: Simd = + unsafe { core::intrinsics::simd::simd_or((!self).to_simd(), index) }; // Safety: the input and output are integer vectors let masked_index: Simd = From ed150fbd5b8bc57c83693a9dbca334822b9c1ea2 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Wed, 18 Mar 2026 21:13:31 +0100 Subject: [PATCH 11/20] bump toolchain to `nightly-2026-03-18` --- crates/core_simd/src/lib.rs | 4 +--- crates/std_float/tests/float.rs | 2 +- crates/test_helpers/src/lib.rs | 3 +-- rust-toolchain.toml | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/crates/core_simd/src/lib.rs b/crates/core_simd/src/lib.rs index fe26d99b9194c..8390ce8faac8d 100644 --- a/crates/core_simd/src/lib.rs +++ b/crates/core_simd/src/lib.rs @@ -1,17 +1,15 @@ #![no_std] #![feature( - const_eval_select, convert_float_to_int, core_intrinsics, decl_macro, - intra_doc_pointers, repr_simd, - simd_ffi, staged_api, prelude_import, ptr_metadata, rustc_attrs )] +#![cfg_attr(doc, feature(intra_doc_pointers))] #![cfg_attr( all( any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "arm",), diff --git a/crates/std_float/tests/float.rs b/crates/std_float/tests/float.rs index 797e12ec71402..0fa5da3dca506 100644 --- a/crates/std_float/tests/float.rs +++ b/crates/std_float/tests/float.rs @@ -25,7 +25,7 @@ macro_rules! unary_approx_test { &core_simd::simd::Simd::<$scalar, LANES>::$func, &$scalar::$func, &|_| true, - 8, + 16, ) } )* diff --git a/crates/test_helpers/src/lib.rs b/crates/test_helpers/src/lib.rs index eb3d3f68bc2ea..4b036740af418 100644 --- a/crates/test_helpers/src/lib.rs +++ b/crates/test_helpers/src/lib.rs @@ -1,7 +1,6 @@ -#![feature(powerpc_target_feature)] #![cfg_attr( any(target_arch = "powerpc", target_arch = "powerpc64"), - feature(stdarch_powerpc) + feature(powerpc_target_feature, stdarch_powerpc) )] pub mod array; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 639d07df73374..6a58e59fb93ef 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2026-01-26" +channel = "nightly-2026-03-18" components = ["rustfmt", "clippy", "miri", "rust-src"] From 8ada24abbf66b36b409dd41d1685bb6460502576 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 26 Mar 2026 22:06:02 -0600 Subject: [PATCH 12/20] Add support for Hexagon HVX (#509) * Add support for Hexagon HVX Add vendor module and tests for Qualcomm Hexagon HVX (Hexagon Vector eXtension) SIMD support. HVX provides wide vector operations in either 64-byte (512-bit) or 128-byte (1024-bit) mode. Note: u8x128/i8x128 types are not included because portable-simd currently limits lane count to 64 (bitmask operations use u64). In 128-byte HVX mode, u8x64 maps to a half-vector (512-bit). * fixup! Add support for Hexagon HVX fixup! Add support for Hexagon HVX Address reviewer feedback: - Remove hexagon_hvx test file (existing tests suffice with -C flags) - Move HvxVector imports into their respective cfg modules - Change u8x128/i8x128 comment to FIXME for discoverability --- crates/core_simd/src/lib.rs | 1 + crates/core_simd/src/vendor.rs | 3 ++ crates/core_simd/src/vendor/hexagon.rs | 40 ++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 crates/core_simd/src/vendor/hexagon.rs diff --git a/crates/core_simd/src/lib.rs b/crates/core_simd/src/lib.rs index 8390ce8faac8d..115be44661c3a 100644 --- a/crates/core_simd/src/lib.rs +++ b/crates/core_simd/src/lib.rs @@ -29,6 +29,7 @@ any(target_arch = "powerpc", target_arch = "powerpc64"), feature(stdarch_powerpc) )] +#![cfg_attr(target_arch = "hexagon", feature(stdarch_hexagon))] #![warn(missing_docs, clippy::missing_inline_in_public_items)] // basically all items, really #![deny( unsafe_op_in_unsafe_fn, diff --git a/crates/core_simd/src/vendor.rs b/crates/core_simd/src/vendor.rs index 57536e4fc77dc..6b3c640c2f7c5 100644 --- a/crates/core_simd/src/vendor.rs +++ b/crates/core_simd/src/vendor.rs @@ -32,3 +32,6 @@ mod powerpc; #[cfg(target_arch = "loongarch64")] mod loongarch64; + +#[cfg(target_arch = "hexagon")] +mod hexagon; diff --git a/crates/core_simd/src/vendor/hexagon.rs b/crates/core_simd/src/vendor/hexagon.rs new file mode 100644 index 0000000000000..2b8ea55fde659 --- /dev/null +++ b/crates/core_simd/src/vendor/hexagon.rs @@ -0,0 +1,40 @@ +//! Conversions to Hexagon HVX SIMD types. + +use crate::simd::*; + +// HVX 128-byte mode (1024-bit vectors) +// Enable with: -C target-feature=+hvx-length128b +#[cfg(target_feature = "hvx-length128b")] +mod hvx_128b { + use super::*; + use core::arch::hexagon::v128::HvxVector; + + // Full vectors (1024-bit) map to HvxVector + from_transmute! { unsafe u16x64 => HvxVector } + from_transmute! { unsafe i16x64 => HvxVector } + from_transmute! { unsafe u32x32 => HvxVector } + from_transmute! { unsafe i32x32 => HvxVector } + from_transmute! { unsafe u64x16 => HvxVector } + from_transmute! { unsafe i64x16 => HvxVector } + + // FIXME: u8x128/i8x128 don't exist in portable-simd (max lane count is 64) + // u8x64/i8x64 are only 512-bit (half of HvxVector in 128B mode) +} + +// HVX 64-byte mode (512-bit vectors) +// Default when hvx-length128b is not specified +#[cfg(not(target_feature = "hvx-length128b"))] +mod hvx_64b { + use super::*; + use core::arch::hexagon::v64::HvxVector; + + // Full vectors (512-bit) map to HvxVector + from_transmute! { unsafe u8x64 => HvxVector } + from_transmute! { unsafe i8x64 => HvxVector } + from_transmute! { unsafe u16x32 => HvxVector } + from_transmute! { unsafe i16x32 => HvxVector } + from_transmute! { unsafe u32x16 => HvxVector } + from_transmute! { unsafe i32x16 => HvxVector } + from_transmute! { unsafe u64x8 => HvxVector } + from_transmute! { unsafe i64x8 => HvxVector } +} From 63d7f8e7ae4f437445cb6eaf5aa11a9f5d9160d9 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Fri, 10 Apr 2026 00:20:11 -0700 Subject: [PATCH 13/20] Initial methods to start on transmute v2 --- library/core/src/mem/mod.rs | 97 +++++++++++++++++++ ...smutes.forget_at_home.PreCodegen.after.mir | 20 ++++ ...ransmutes.neo_to_cast.PreCodegen.after.mir | 13 +++ ...tes.pad_for_alignment.PreCodegen.after.mir | 29 ++++++ ...mutes.prefix_of_array.PreCodegen.after.mir | 29 ++++++ ...smutes.prefix_to_cast.PreCodegen.after.mir | 21 ++++ tests/mir-opt/pre-codegen/transmutes.rs | 50 ++++++++++ 7 files changed, 259 insertions(+) create mode 100644 tests/mir-opt/pre-codegen/transmutes.forget_at_home.PreCodegen.after.mir create mode 100644 tests/mir-opt/pre-codegen/transmutes.neo_to_cast.PreCodegen.after.mir create mode 100644 tests/mir-opt/pre-codegen/transmutes.pad_for_alignment.PreCodegen.after.mir create mode 100644 tests/mir-opt/pre-codegen/transmutes.prefix_of_array.PreCodegen.after.mir create mode 100644 tests/mir-opt/pre-codegen/transmutes.prefix_to_cast.PreCodegen.after.mir create mode 100644 tests/mir-opt/pre-codegen/transmutes.rs diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index a987970c9bcc3..91934cfceb4e3 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -32,6 +32,7 @@ use crate::alloc::Layout; use crate::clone::TrivialClone; +use crate::cmp::Ordering; use crate::marker::{Destruct, DiscriminantKind}; use crate::panic::const_assert; use crate::{clone, cmp, fmt, hash, intrinsics, ptr}; @@ -1088,6 +1089,102 @@ pub const unsafe fn transmute_copy(src: &Src) -> Dst { } } +/// Like [`transmute`], but only initializes the "common prefix" of the first +/// `min(size_of::(), size_of::())` bytes of the destination from the +/// corresponding bytes of the source. +/// +/// This is equivalent to a "union cast" through a `union` with `#[repr(C)]`. +/// +/// That means some size mismatches are not UB, like `[T; 2]` to `[T; 1]`. +/// Increasing size is usually UB from being insufficiently initialized -- like +/// `u8` to `u32` -- but isn't always. For example, going from `u8` to +/// `#[repr(C, align(4))] AlignedU8(u8);` is sound. +/// +/// Prefer normal `transmute` where possible, for the extra checking, since +/// both do exactly the same thing at runtime, if they both compile. +/// +/// # Safety +/// +/// If `size_of::() >= size_of::()`, the first `size_of::()` bytes +/// of `src` must be be *valid* when interpreted as a `Dst`. (In this case, the +/// preconditions are the same as for `transmute_copy(&ManuallyDrop::new(src))`.) +/// +/// If `size_of::() <= size_of::()`, the bytes of `src` padded with +/// uninitialized bytes afterwards up to a total size of `size_of::()` +/// must be *valid* when interpreted as a `Dst`. +/// +/// In both cases, any safety preconditions of the `Dst` type must also be upheld. +/// +/// # Examples +/// +/// ``` +/// #![feature(transmute_prefix)] +/// use std::mem::transmute_prefix; +/// +/// assert_eq!(unsafe { transmute_prefix::<[i32; 4], [i32; 2]>([1, 2, 3, 4]) }, [1, 2]); +/// +/// let expected = if cfg!(target_endian = "little") { 0x34 } else { 0x12 }; +/// assert_eq!(unsafe { transmute_prefix::(0x1234) }, expected); +/// +/// // Would be UB because the destination is incompletely initialized. +/// // transmute_prefix::(123) +/// +/// // OK because the destination is allowed to be partially initialized. +/// let _: std::mem::MaybeUninit = unsafe { transmute_prefix(123_u8) }; +/// ``` +#[unstable(feature = "transmute_prefix", issue = "155079")] +pub const unsafe fn transmute_prefix(src: Src) -> Dst { + #[repr(C)] + union Transmute { + a: ManuallyDrop, + b: ManuallyDrop, + } + + match const { Ord::cmp(&Src::SIZE, &Dst::SIZE) } { + // SAFETY: When Dst is bigger, the union is the size of Dst + Ordering::Less => unsafe { + let a = transmute_neo(src); + intrinsics::transmute_unchecked(Transmute:: { a }) + }, + // SAFETY: When they're the same size, we can use the MIR primitive + Ordering::Equal => unsafe { intrinsics::transmute_unchecked::(src) }, + // SAFETY: When Src is bigger, the union is the size of Src + Ordering::Greater => unsafe { + let u: Transmute = intrinsics::transmute_unchecked(src); + transmute_neo(u.b) + }, + } +} + +/// New version of `transmute`, exposed under this name so it can be iterated upon +/// without risking breakage to uses of "real" transmute. +/// +/// It will not be stabilized under this name. +/// +/// # Examples +/// +/// ``` +/// #![feature(transmute_neo)] +/// use std::mem::transmute_neo; +/// +/// assert_eq!(unsafe { transmute_neo::(0.0) }, 0); +/// ``` +/// +/// ```compile_fail,E0080 +/// #![feature(transmute_neo)] +/// use std::mem::transmute_neo; +/// +/// unsafe { transmute_neo::(123) }; +/// ``` +#[unstable(feature = "transmute_neo", issue = "155079")] +pub const unsafe fn transmute_neo(src: Src) -> Dst { + const { assert!(Src::SIZE == Dst::SIZE) }; + + // SAFETY: the const-assert just checked that they're the same size, + // and any other safety invariants need to be upheld by the caller. + unsafe { intrinsics::transmute_unchecked(src) } +} + /// Opaque type representing the discriminant of an enum. /// /// See the [`discriminant`] function in this module for more information. diff --git a/tests/mir-opt/pre-codegen/transmutes.forget_at_home.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/transmutes.forget_at_home.PreCodegen.after.mir new file mode 100644 index 0000000000000..5fc28fddedf8b --- /dev/null +++ b/tests/mir-opt/pre-codegen/transmutes.forget_at_home.PreCodegen.after.mir @@ -0,0 +1,20 @@ +// MIR for `forget_at_home` after PreCodegen + +fn forget_at_home(_1: String) -> () { + debug x => _1; + let mut _0: (); + scope 1 (inlined transmute_prefix::) { + scope 2 { + } + scope 3 { + scope 4 (inlined transmute_neo::, ()>) { + } + } + scope 5 (inlined transmute_neo::>) { + } + } + + bb0: { + return; + } +} diff --git a/tests/mir-opt/pre-codegen/transmutes.neo_to_cast.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/transmutes.neo_to_cast.PreCodegen.after.mir new file mode 100644 index 0000000000000..6d6b1775d05b0 --- /dev/null +++ b/tests/mir-opt/pre-codegen/transmutes.neo_to_cast.PreCodegen.after.mir @@ -0,0 +1,13 @@ +// MIR for `neo_to_cast` after PreCodegen + +fn neo_to_cast(_1: f32) -> i32 { + debug x => _1; + let mut _0: i32; + scope 1 (inlined transmute_neo::) { + } + + bb0: { + _0 = copy _1 as i32 (Transmute); + return; + } +} diff --git a/tests/mir-opt/pre-codegen/transmutes.pad_for_alignment.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/transmutes.pad_for_alignment.PreCodegen.after.mir new file mode 100644 index 0000000000000..100eebf0c2448 --- /dev/null +++ b/tests/mir-opt/pre-codegen/transmutes.pad_for_alignment.PreCodegen.after.mir @@ -0,0 +1,29 @@ +// MIR for `pad_for_alignment` after PreCodegen + +fn pad_for_alignment(_1: u32) -> Align64 { + debug x => _1; + let mut _0: Align64; + scope 1 (inlined transmute_prefix::>) { + let _2: std::mem::ManuallyDrop; + let mut _3: std::mem::transmute_prefix::Transmute>; + scope 2 { + } + scope 3 { + scope 4 (inlined transmute_neo::>, Align64>) { + } + } + scope 5 (inlined transmute_neo::>) { + } + } + + bb0: { + StorageLive(_2); + _2 = copy _1 as std::mem::ManuallyDrop (Transmute); + StorageLive(_3); + _3 = transmute_prefix::Transmute::> { a: copy _2 }; + _0 = move _3 as Align64 (Transmute); + StorageDead(_3); + StorageDead(_2); + return; + } +} diff --git a/tests/mir-opt/pre-codegen/transmutes.prefix_of_array.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/transmutes.prefix_of_array.PreCodegen.after.mir new file mode 100644 index 0000000000000..4050338e2418c --- /dev/null +++ b/tests/mir-opt/pre-codegen/transmutes.prefix_of_array.PreCodegen.after.mir @@ -0,0 +1,29 @@ +// MIR for `prefix_of_array` after PreCodegen + +fn prefix_of_array(_1: [u32; 4]) -> [u32; 2] { + debug x => _1; + let mut _0: [u32; 2]; + scope 1 (inlined transmute_prefix::<[u32; 4], [u32; 2]>) { + let _2: std::mem::transmute_prefix::Transmute<[u32; 4], [u32; 2]>; + let mut _3: std::mem::ManuallyDrop<[u32; 2]>; + scope 2 { + } + scope 3 { + scope 4 (inlined transmute_neo::, [u32; 2]>) { + } + } + scope 5 (inlined transmute_neo::<[u32; 4], ManuallyDrop<[u32; 4]>>) { + } + } + + bb0: { + StorageLive(_2); + _2 = copy _1 as std::mem::transmute_prefix::Transmute<[u32; 4], [u32; 2]> (Transmute); + StorageLive(_3); + _3 = move (_2.1: std::mem::ManuallyDrop<[u32; 2]>); + _0 = copy _3 as [u32; 2] (Transmute); + StorageDead(_3); + StorageDead(_2); + return; + } +} diff --git a/tests/mir-opt/pre-codegen/transmutes.prefix_to_cast.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/transmutes.prefix_to_cast.PreCodegen.after.mir new file mode 100644 index 0000000000000..c0500fbae06fb --- /dev/null +++ b/tests/mir-opt/pre-codegen/transmutes.prefix_to_cast.PreCodegen.after.mir @@ -0,0 +1,21 @@ +// MIR for `prefix_to_cast` after PreCodegen + +fn prefix_to_cast(_1: f32) -> i32 { + debug x => _1; + let mut _0: i32; + scope 1 (inlined transmute_prefix::) { + scope 2 { + } + scope 3 { + scope 4 (inlined transmute_neo::, i32>) { + } + } + scope 5 (inlined transmute_neo::>) { + } + } + + bb0: { + _0 = copy _1 as i32 (Transmute); + return; + } +} diff --git a/tests/mir-opt/pre-codegen/transmutes.rs b/tests/mir-opt/pre-codegen/transmutes.rs new file mode 100644 index 0000000000000..4825e6079c2e3 --- /dev/null +++ b/tests/mir-opt/pre-codegen/transmutes.rs @@ -0,0 +1,50 @@ +//@ compile-flags: -O -Zmir-opt-level=2 + +#![crate_type = "lib"] +#![feature(transmute_neo)] +#![feature(transmute_prefix)] + +use std::mem::{transmute_neo, transmute_prefix}; + +// EMIT_MIR transmutes.neo_to_cast.PreCodegen.after.mir +pub fn neo_to_cast(x: f32) -> i32 { + // CHECK-LABEL: fn neo_to_cast + // CHECK: _0 = copy _1 as i32 (Transmute); + unsafe { transmute_neo(x) } +} + +// EMIT_MIR transmutes.prefix_to_cast.PreCodegen.after.mir +pub fn prefix_to_cast(x: f32) -> i32 { + // CHECK-LABEL: fn prefix_to_cast + // CHECK: _0 = copy _1 as i32 (Transmute); + unsafe { transmute_prefix(x) } +} + +// EMIT_MIR transmutes.prefix_of_array.PreCodegen.after.mir +pub fn prefix_of_array(x: [u32; 4]) -> [u32; 2] { + // CHECK-LABEL: fn prefix_of_array + // CHECK: _2 = copy _1 as {{.+}}::Transmute<[u32; 4], [u32; 2]> (Transmute); + // CHECK: _3 = move (_2.1: {{.+}}::ManuallyDrop<[u32; 2]>); + // CHECK: _0 = copy _3 as [u32; 2] (Transmute); + unsafe { transmute_prefix(x) } +} + +#[repr(C, align(64))] +struct Align64(T); + +// EMIT_MIR transmutes.pad_for_alignment.PreCodegen.after.mir +pub fn pad_for_alignment(x: u32) -> Align64 { + // CHECK-LABEL: fn pad_for_alignment + // CHECK: _2 = copy _1 as {{.+}}::ManuallyDrop (Transmute); + // CHECK: _3 = {{.+}}::Transmute::> { a: copy _2 }; + // CHECK: _0 = move _3 as Align64 (Transmute); + unsafe { transmute_prefix(x) } +} + +// EMIT_MIR transmutes.forget_at_home.PreCodegen.after.mir +pub fn forget_at_home(x: String) { + // CHECK-LABEL: fn forget_at_home + // CHECK: bb0: + // CHECK-NEXT: return; + unsafe { transmute_prefix(x) } +} From 6bcd172f5a82fa3bb508bbecf2d5d9777a3473e6 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Fri, 10 Apr 2026 16:08:23 +0200 Subject: [PATCH 14/20] add `cfg(target_object_format = "...")` --- compiler/rustc_abi/src/lib.rs | 10 ++ compiler/rustc_feature/src/builtin_attrs.rs | 1 + compiler/rustc_feature/src/unstable.rs | 2 + compiler/rustc_session/src/config/cfg.rs | 11 +- compiler/rustc_span/src/symbol.rs | 8 ++ compiler/rustc_target/src/spec/mod.rs | 10 ++ .../cfg-target-object-format.md | 34 ++++++ src/librustdoc/clean/cfg.rs | 7 ++ tests/auxiliary/minicore.rs | 6 + tests/rustdoc-ui/doc-cfg-2.stderr | 2 +- tests/ui/cfg/cfg_target_object_format.rs | 105 ++++++++++++++++++ tests/ui/cfg/disallowed-cli-cfgs.rs | 7 +- ...owed-cli-cfgs.target_object_format_.stderr | 8 ++ tests/ui/check-cfg/cargo-build-script.stderr | 2 +- tests/ui/check-cfg/cargo-feature.none.stderr | 2 +- tests/ui/check-cfg/cargo-feature.some.stderr | 2 +- tests/ui/check-cfg/cfg-select.stderr | 2 +- .../cfg-value-for-cfg-name-duplicate.stderr | 2 +- .../cfg-value-for-cfg-name-multiple.stderr | 2 +- .../exhaustive-names-values.feature.stderr | 2 +- .../exhaustive-names-values.full.stderr | 2 +- tests/ui/check-cfg/hrtb-crash.stderr | 2 +- tests/ui/check-cfg/mix.stderr | 2 +- tests/ui/check-cfg/nested-cfg.stderr | 2 +- .../check-cfg/raw-keywords.edition2015.stderr | 2 +- .../check-cfg/raw-keywords.edition2021.stderr | 2 +- .../report-in-external-macros.cargo.stderr | 2 +- .../report-in-external-macros.rustc.stderr | 2 +- tests/ui/check-cfg/well-known-names.stderr | 1 + tests/ui/check-cfg/well-known-values.rs | 3 + tests/ui/check-cfg/well-known-values.stderr | 67 ++++++----- .../feature-gate-cfg_target_object_format.rs | 6 + ...ature-gate-cfg_target_object_format.stderr | 13 +++ tests/ui/macros/cfg.stderr | 2 +- tests/ui/macros/cfg_select.stderr | 2 +- 35 files changed, 282 insertions(+), 53 deletions(-) create mode 100644 src/doc/unstable-book/src/language-features/cfg-target-object-format.md create mode 100644 tests/ui/cfg/cfg_target_object_format.rs create mode 100644 tests/ui/cfg/disallowed-cli-cfgs.target_object_format_.stderr create mode 100644 tests/ui/feature-gates/feature-gate-cfg_target_object_format.rs create mode 100644 tests/ui/feature-gates/feature-gate-cfg_target_object_format.stderr diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index f28c9aa266737..ec6eb7e7dc106 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -52,6 +52,8 @@ use rustc_hashes::Hash64; use rustc_index::{Idx, IndexSlice, IndexVec}; #[cfg(feature = "nightly")] use rustc_macros::{Decodable_NoContext, Encodable_NoContext, HashStable_Generic}; +#[cfg(feature = "nightly")] +use rustc_span::{Symbol, sym}; mod callconv; mod canon_abi; @@ -770,6 +772,14 @@ impl Endian { Self::Big => "big", } } + + #[cfg(feature = "nightly")] + pub fn desc_symbol(&self) -> Symbol { + match self { + Self::Little => sym::little, + Self::Big => sym::big, + } + } } impl fmt::Debug for Endian { diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 1b2f391dc7a12..60223cc835043 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -62,6 +62,7 @@ const GATED_CFGS: &[GatedCfg] = &[ sym::cfg_target_has_reliable_f16_f128, Features::cfg_target_has_reliable_f16_f128, ), + (sym::target_object_format, sym::cfg_target_object_format, Features::cfg_target_object_format), ]; /// Find a gated cfg determined by the `pred`icate which is given the cfg's name. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index c2fe6e1360201..c56ddd35e2c0e 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -410,6 +410,8 @@ declare_features! ( (unstable, cfg_target_has_atomic, "1.60.0", Some(94039)), /// Allows `cfg(target_has_atomic_equal_alignment = "...")`. (unstable, cfg_target_has_atomic_equal_alignment, "1.60.0", Some(93822)), + /// Allows `cfg(target_object_format = "...")`. + (unstable, cfg_target_object_format, "CURRENT_RUSTC_VERSION", Some(152586)), /// Allows `cfg(target_thread_local)`. (unstable, cfg_target_thread_local, "1.7.0", Some(29594)), /// Allows the use of `#[cfg(ub_checks)` to check if UB checks are enabled. diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs index 1d5287cfd80ac..9c76f4f3db92f 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -144,6 +144,7 @@ pub(crate) fn disallow_cfgs(sess: &Session, user_cfgs: &Cfg) { | (sym::target_endian, Some(_)) | (sym::target_env, None | Some(_)) | (sym::target_family, Some(_)) + | (sym::target_object_format, Some(_)) | (sym::target_os, Some(_)) | (sym::target_pointer_width, Some(_)) | (sym::target_vendor, None | Some(_)) @@ -252,8 +253,9 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg { ins_sym!(sym::target_abi, sess.target.cfg_abi.desc_symbol()); ins_sym!(sym::target_arch, sess.target.arch.desc_symbol()); - ins_str!(sym::target_endian, sess.target.endian.as_str()); + ins_sym!(sym::target_endian, sess.target.endian.desc_symbol()); ins_sym!(sym::target_env, sess.target.env.desc_symbol()); + ins_sym!(sym::target_object_format, sess.target.options.binary_format.desc_symbol()); for family in sess.target.families.as_ref() { ins_str!(sym::target_family, family); @@ -420,12 +422,13 @@ impl CheckCfg { // sym::target_* { - const VALUES: [&Symbol; 8] = [ + const VALUES: [&Symbol; 9] = [ &sym::target_abi, &sym::target_arch, &sym::target_endian, &sym::target_env, &sym::target_family, + &sym::target_object_format, &sym::target_os, &sym::target_pointer_width, &sym::target_vendor, @@ -449,6 +452,7 @@ impl CheckCfg { Some(values_target_endian), Some(values_target_env), Some(values_target_family), + Some(values_target_object_format), Some(values_target_os), Some(values_target_pointer_width), Some(values_target_vendor), @@ -460,11 +464,12 @@ impl CheckCfg { for target in Target::builtins().chain(iter::once(current_target.clone())) { values_target_abi.insert(target.options.cfg_abi.desc_symbol()); values_target_arch.insert(target.arch.desc_symbol()); - values_target_endian.insert(Symbol::intern(target.options.endian.as_str())); + values_target_endian.insert(target.options.endian.desc_symbol()); values_target_env.insert(target.options.env.desc_symbol()); values_target_family.extend( target.options.families.iter().map(|family| Symbol::intern(family)), ); + values_target_object_format.insert(target.options.binary_format.desc_symbol()); values_target_os.insert(target.options.os.desc_symbol()); values_target_pointer_width.insert(sym::integer(target.pointer_width)); values_target_vendor.insert(target.vendor_symbol()); diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index bfa731e4bbe19..e7126cf70b574 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -589,6 +589,7 @@ symbols! { cfg_target_has_atomic, cfg_target_has_atomic_equal_alignment, cfg_target_has_reliable_f16_f128, + cfg_target_object_format, cfg_target_thread_local, cfg_target_vendor, cfg_trace: "", // must not be a valid identifier @@ -623,6 +624,7 @@ symbols! { coerce_pointee_validated, coerce_shared, coerce_unsized, + coff, cold, cold_path, collapse_debuginfo, @@ -853,6 +855,7 @@ symbols! { eii_internals, eii_shared_macro, element_ty, + elf, // Notes about `sym::empty`: // - It should only be used when it genuinely means "empty symbol". Use // `Option` when "no symbol" is a possibility. @@ -1167,6 +1170,7 @@ symbols! { linkonce_odr, lint_reasons, literal, + little, big, load, loaded_from_disk, local, @@ -1193,6 +1197,7 @@ symbols! { lt, m68k, m68k_target_feature, + macho: "mach-o", macro_at_most_once_rep, macro_attr, macro_attributes_in_derive_output, @@ -2014,6 +2019,7 @@ symbols! { target_has_reliable_f16_math, target_has_reliable_f128, target_has_reliable_f128_math, + target_object_format, target_os, target_pointer_width, target_thread_local, @@ -2237,6 +2243,7 @@ symbols! { vtable_size, warn, wasip2, + wasm, wasm32, wasm64, wasm_abi, @@ -2271,6 +2278,7 @@ symbols! { x86_amx_intrinsics, x87_reg, x87_target_feature, + xcoff, xer, xmm_reg, xop_target_feature, diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 0601f9d7c2cfb..e8ef1d986062a 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1395,6 +1395,16 @@ impl BinaryFormat { Self::Xcoff => object::BinaryFormat::Xcoff, } } + + pub fn desc_symbol(&self) -> Symbol { + match self { + Self::Coff => sym::coff, + Self::Elf => sym::elf, + Self::MachO => sym::macho, + Self::Wasm => sym::wasm, + Self::Xcoff => sym::xcoff, + } + } } impl ToJson for Align { diff --git a/src/doc/unstable-book/src/language-features/cfg-target-object-format.md b/src/doc/unstable-book/src/language-features/cfg-target-object-format.md new file mode 100644 index 0000000000000..34d6e2faca0fd --- /dev/null +++ b/src/doc/unstable-book/src/language-features/cfg-target-object-format.md @@ -0,0 +1,34 @@ +# `cfg_target_object_format` + +The tracking issue for this feature is: [#152586] + +[#152586]: https://github.com/rust-lang/rust/issues/152586 + +------------------------ + +The `cfg_target_object_format` feature makes it possible to execute different code +depending on the current target's object file format. + +## Examples + +```rust +#![feature(cfg_target_object_format)] + +#[cfg(target_object_format = "elf")] +fn a() { + // ... +} + +#[cfg(target_object_format = "mach-o")] +fn a() { + // ... +} + +fn b() { + if cfg!(target_object_format = "wasm") { + // ... + } else { + // ... + } +} +``` diff --git a/src/librustdoc/clean/cfg.rs b/src/librustdoc/clean/cfg.rs index 086ee7def98bc..d3422a93075b8 100644 --- a/src/librustdoc/clean/cfg.rs +++ b/src/librustdoc/clean/cfg.rs @@ -423,6 +423,13 @@ impl fmt::Display for Display<'_> { (sym::unix, None) => "Unix", (sym::windows, None) => "Windows", (sym::debug_assertions, None) => "debug-assertions enabled", + (sym::target_object_format, Some(format)) => match self.1 { + Format::LongHtml => { + return write!(fmt, "object format {format}"); + } + Format::LongPlain => return write!(fmt, "object format `{format}`"), + Format::ShortHtml => return write!(fmt, "{format}"), + }, (sym::target_os, Some(os)) => human_readable_target_os(*os).unwrap_or_default(), (sym::target_arch, Some(arch)) => { human_readable_target_arch(*arch).unwrap_or_default() diff --git a/tests/auxiliary/minicore.rs b/tests/auxiliary/minicore.rs index 5c6eb54832437..6e200afb5c17c 100644 --- a/tests/auxiliary/minicore.rs +++ b/tests/auxiliary/minicore.rs @@ -187,6 +187,12 @@ macro_rules! stringify { }; } +#[rustc_builtin_macro] +#[macro_export] +macro_rules! compile_error { + ($msg:expr $(,)?) => {{ /* compiler built-in */ }}; +} + #[lang = "add"] pub trait Add { type Output; diff --git a/tests/rustdoc-ui/doc-cfg-2.stderr b/tests/rustdoc-ui/doc-cfg-2.stderr index a842cbc402887..164e755de8ad7 100644 --- a/tests/rustdoc-ui/doc-cfg-2.stderr +++ b/tests/rustdoc-ui/doc-cfg-2.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `foo` LL | #[doc(cfg(foo), cfg(bar))] | ^^^ | - = help: expected names are: `FALSE` and `test` and 31 more + = help: expected names are: `FALSE` and `test` and 32 more = help: to expect this configuration use `--check-cfg=cfg(foo)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/cfg/cfg_target_object_format.rs b/tests/ui/cfg/cfg_target_object_format.rs new file mode 100644 index 0000000000000..cea2027b35c0b --- /dev/null +++ b/tests/ui/cfg/cfg_target_object_format.rs @@ -0,0 +1,105 @@ +//@ add-minicore +//@ check-pass +//@ ignore-backends: gcc +// +//@ revisions: linux_gnu linux_musl linux_ohos linux_powerpc +//@[linux_gnu] compile-flags: --target aarch64-unknown-linux-gnu +//@[linux_gnu] needs-llvm-components: aarch64 +//@[linux_musl] compile-flags: --target aarch64-unknown-linux-musl +//@[linux_musl] needs-llvm-components: aarch64 +//@[linux_ohos] compile-flags: --target aarch64-unknown-linux-ohos +//@[linux_ohos] needs-llvm-components: aarch64 +//@[linux_powerpc] compile-flags: --target powerpc-unknown-linux-gnu +//@[linux_powerpc] needs-llvm-components: powerpc +// +//@ revisions: darwin ios +//@[darwin] compile-flags: --target aarch64-apple-darwin +//@[darwin] needs-llvm-components: aarch64 +//@[ios] compile-flags: --target aarch64-apple-ios +//@[ios] needs-llvm-components: aarch64 +// +//@ revisions: win_msvc win_gnu +//@[win_msvc] compile-flags: --target aarch64-pc-windows-msvc +//@[win_msvc] needs-llvm-components: aarch64 +//@[win_gnu] compile-flags: --target x86_64-pc-windows-gnu +//@[win_gnu] needs-llvm-components: x86 +// +//@ revisions: wasm32 wasm64 +//@[wasm32] compile-flags: --target wasm32-unknown-unknown +//@[wasm32] needs-llvm-components: webassembly +//@[wasm64] compile-flags: --target wasm64-unknown-unknown +//@[wasm64] needs-llvm-components: webassembly +// +//@ revisions: aix +//@[aix] compile-flags: --target powerpc64-ibm-aix +//@[aix] needs-llvm-components: powerpc +// +//@ revisions: hermit sgx uefi +//@[hermit] compile-flags: --target x86_64-unknown-hermit +//@[hermit] needs-llvm-components: x86 +//@[sgx] compile-flags: --target x86_64-fortanix-unknown-sgx +//@[sgx] needs-llvm-components: x86 +//@[uefi] compile-flags: --target x86_64-unknown-uefi +//@[uefi] needs-llvm-components: x86 +// +//@ revisions: bpfeb bpfel +//@[bpfeb] compile-flags: --target bpfeb-unknown-none +//@[bpfeb] needs-llvm-components: bpf +//@[bpfel] compile-flags: --target bpfel-unknown-none +//@[bpfel] needs-llvm-components: bpf +// +//@ revisions: avr +//@[avr] compile-flags: --target avr-none -Ctarget-cpu=atmega328 +//@[avr] needs-llvm-components: avr +// +//@ revisions: msp430 +//@[msp430] compile-flags: --target msp430-none-elf +//@[msp430] needs-llvm-components: msp430 +// +//@ revisions: thumb +//@[thumb] compile-flags: --target thumbv7m-none-eabi +//@[thumb] needs-llvm-components: arm +#![crate_type = "lib"] +#![feature(no_core, lang_items, cfg_target_object_format)] +#![no_core] + +extern crate minicore; +use minicore::*; + +macro_rules! assert_cfg { + ($rhs:ident = $rhs_val:literal) => { + #[cfg(not($rhs = $rhs_val))] + compile_error!(concat!("expected `", stringify!($rhs), " = ", $rhs_val, "`",)); + }; +} + +const _: () = { + cfg_select!( + target_os = "linux" => assert_cfg!(target_object_format = "elf"), + target_os = "aix" => assert_cfg!(target_object_format = "xcoff"), + target_os = "uefi" => assert_cfg!(target_object_format = "coff"), + target_os = "windows" => assert_cfg!(target_object_format = "coff"), + target_os = "hermit" => assert_cfg!(target_object_format = "elf"), + + target_arch = "bpf" => assert_cfg!(target_object_format = "elf"), + target_arch = "avr" => assert_cfg!(target_object_format = "elf"), + target_arch = "msp430" => assert_cfg!(target_object_format = "elf"), + + target_abi = "eabi" => assert_cfg!(target_object_format = "elf"), + target_vendor = "apple" => assert_cfg!(target_object_format = "mach-o"), + target_family = "wasm" => assert_cfg!(target_object_format = "wasm"), + + windows => assert_cfg!(target_object_format = "coff"), + + _ => {} + ); +}; + +const _: () = { + cfg_select!( + target_object_format = "mach-o" => assert_cfg!(target_vendor = "apple"), + target_object_format = "wasm" => assert_cfg!(target_family = "wasm"), + target_object_format = "xcoff" => assert_cfg!(target_os = "aix"), + _ => {} + ); +}; diff --git a/tests/ui/cfg/disallowed-cli-cfgs.rs b/tests/ui/cfg/disallowed-cli-cfgs.rs index f7f9d2b5cd7f9..1ce65a7d657e6 100644 --- a/tests/ui/cfg/disallowed-cli-cfgs.rs +++ b/tests/ui/cfg/disallowed-cli-cfgs.rs @@ -3,9 +3,9 @@ //@ revisions: sanitizer_cfi_generalize_pointers_ sanitizer_cfi_normalize_integers_ //@ revisions: proc_macro_ panic_ target_feature_ unix_ windows_ target_abi_ //@ revisions: target_arch_ target_endian_ target_env_ target_family_ target_os_ -//@ revisions: target_pointer_width_ target_vendor_ target_has_atomic_ -//@ revisions: target_has_atomic_equal_alignment_ target_has_atomic_load_store_ -//@ revisions: target_thread_local_ relocation_model_ +//@ revisions: target_object_format_ target_pointer_width_ target_vendor_ +//@ revisions: target_has_atomic_ target_has_atomic_equal_alignment_ +//@ revisions: target_has_atomic_load_store_ target_thread_local_ relocation_model_ //@ revisions: fmt_debug_ //@ revisions: emscripten_wasm_eh_ //@ revisions: reliable_f16_ reliable_f16_math_ reliable_f128_ reliable_f128_math_ @@ -26,6 +26,7 @@ //@ [target_endian_]compile-flags: --cfg target_endian="little" //@ [target_env_]compile-flags: --cfg target_env //@ [target_family_]compile-flags: --cfg target_family="unix" +//@ [target_object_format_]compile-flags: --cfg target_object_format="elf" //@ [target_os_]compile-flags: --cfg target_os="linux" //@ [target_pointer_width_]compile-flags: --cfg target_pointer_width="32" //@ [target_vendor_]compile-flags: --cfg target_vendor diff --git a/tests/ui/cfg/disallowed-cli-cfgs.target_object_format_.stderr b/tests/ui/cfg/disallowed-cli-cfgs.target_object_format_.stderr new file mode 100644 index 0000000000000..463f4a99cfa0a --- /dev/null +++ b/tests/ui/cfg/disallowed-cli-cfgs.target_object_format_.stderr @@ -0,0 +1,8 @@ +error: unexpected `--cfg target_object_format="elf"` flag + | + = note: config `target_object_format` is only supposed to be controlled by `--target` + = note: manually setting a built-in cfg can and does create incoherent behaviors + = note: `#[deny(explicit_builtin_cfgs_in_flags)]` on by default + +error: aborting due to 1 previous error + diff --git a/tests/ui/check-cfg/cargo-build-script.stderr b/tests/ui/check-cfg/cargo-build-script.stderr index 03a7156a4d69e..6039af936a319 100644 --- a/tests/ui/check-cfg/cargo-build-script.stderr +++ b/tests/ui/check-cfg/cargo-build-script.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `has_foo` LL | #[cfg(has_foo)] | ^^^^^^^ | - = help: expected names are: `has_bar` and 31 more + = help: expected names are: `has_bar` and 32 more = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] diff --git a/tests/ui/check-cfg/cargo-feature.none.stderr b/tests/ui/check-cfg/cargo-feature.none.stderr index b83d1794984de..c710781b68ce9 100644 --- a/tests/ui/check-cfg/cargo-feature.none.stderr +++ b/tests/ui/check-cfg/cargo-feature.none.stderr @@ -25,7 +25,7 @@ warning: unexpected `cfg` condition name: `tokio_unstable` LL | #[cfg(tokio_unstable)] | ^^^^^^^^^^^^^^ | - = help: expected names are: `docsrs`, `feature`, and `test` and 31 more + = help: expected names are: `docsrs`, `feature`, and `test` and 32 more = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] diff --git a/tests/ui/check-cfg/cargo-feature.some.stderr b/tests/ui/check-cfg/cargo-feature.some.stderr index 2cddcbbcd7f9e..9e3726f6c6259 100644 --- a/tests/ui/check-cfg/cargo-feature.some.stderr +++ b/tests/ui/check-cfg/cargo-feature.some.stderr @@ -25,7 +25,7 @@ warning: unexpected `cfg` condition name: `tokio_unstable` LL | #[cfg(tokio_unstable)] | ^^^^^^^^^^^^^^ | - = help: expected names are: `CONFIG_NVME`, `docsrs`, `feature`, and `test` and 31 more + = help: expected names are: `CONFIG_NVME`, `docsrs`, `feature`, and `test` and 32 more = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] diff --git a/tests/ui/check-cfg/cfg-select.stderr b/tests/ui/check-cfg/cfg-select.stderr index e8b6fe6eff104..8733f42b14710 100644 --- a/tests/ui/check-cfg/cfg-select.stderr +++ b/tests/ui/check-cfg/cfg-select.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `invalid_cfg1` LL | invalid_cfg1 => {} | ^^^^^^^^^^^^ | - = help: expected names are: `FALSE` and `test` and 31 more + = help: expected names are: `FALSE` and `test` and 32 more = help: to expect this configuration use `--check-cfg=cfg(invalid_cfg1)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr index 68e1259dbb842..ed80d25ffccda 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `value` LL | #[cfg(value)] | ^^^^^ | - = help: expected names are: `bar`, `bee`, `cow`, and `foo` and 31 more + = help: expected names are: `bar`, `bee`, `cow`, and `foo` and 32 more = help: to expect this configuration use `--check-cfg=cfg(value)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr index 5279f3b09015d..5e0f1b02dd459 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `my_value` LL | #[cfg(my_value)] | ^^^^^^^^ | - = help: expected names are: `bar` and `foo` and 31 more + = help: expected names are: `bar` and `foo` and 32 more = help: to expect this configuration use `--check-cfg=cfg(my_value)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr index 9281392b59ec3..6e21c47c1d7d1 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key` LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `feature` and 31 more + = help: expected names are: `feature` and 32 more = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/exhaustive-names-values.full.stderr b/tests/ui/check-cfg/exhaustive-names-values.full.stderr index 9281392b59ec3..6e21c47c1d7d1 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.full.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.full.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key` LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `feature` and 31 more + = help: expected names are: `feature` and 32 more = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/hrtb-crash.stderr b/tests/ui/check-cfg/hrtb-crash.stderr index 431cf9cf53e25..f83bef31e3a18 100644 --- a/tests/ui/check-cfg/hrtb-crash.stderr +++ b/tests/ui/check-cfg/hrtb-crash.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `b` LL | for<#[cfg(b)] c> u8:; | ^ help: found config with similar value: `target_feature = "b"` | - = help: expected names are: `FALSE`, `docsrs`, and `test` and 31 more + = help: expected names are: `FALSE`, `docsrs`, and `test` and 32 more = help: to expect this configuration use `--check-cfg=cfg(b)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/mix.stderr b/tests/ui/check-cfg/mix.stderr index be4d7c7727636..b42619b04e9bf 100644 --- a/tests/ui/check-cfg/mix.stderr +++ b/tests/ui/check-cfg/mix.stderr @@ -44,7 +44,7 @@ warning: unexpected `cfg` condition name: `uu` LL | #[cfg_attr(uu, unix)] | ^^ | - = help: expected names are: `feature` and 31 more + = help: expected names are: `feature` and 32 more = help: to expect this configuration use `--check-cfg=cfg(uu)` = note: see for more information about checking conditional configuration diff --git a/tests/ui/check-cfg/nested-cfg.stderr b/tests/ui/check-cfg/nested-cfg.stderr index 6fdae732bbe58..73a1160a2d487 100644 --- a/tests/ui/check-cfg/nested-cfg.stderr +++ b/tests/ui/check-cfg/nested-cfg.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown` LL | #[cfg(unknown)] | ^^^^^^^ | - = help: expected names are: `FALSE` and `test` and 31 more + = help: expected names are: `FALSE` and `test` and 32 more = help: to expect this configuration use `--check-cfg=cfg(unknown)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/raw-keywords.edition2015.stderr b/tests/ui/check-cfg/raw-keywords.edition2015.stderr index 29c1a71c0b7a6..1524c3558fc95 100644 --- a/tests/ui/check-cfg/raw-keywords.edition2015.stderr +++ b/tests/ui/check-cfg/raw-keywords.edition2015.stderr @@ -14,7 +14,7 @@ warning: unexpected `cfg` condition name: `r#false` LL | #[cfg(r#false)] | ^^^^^^^ | - = help: expected names are: `async`, `edition2015`, `edition2021`, and `r#true` and 31 more + = help: expected names are: `async`, `edition2015`, `edition2021`, and `r#true` and 32 more = help: to expect this configuration use `--check-cfg=cfg(r#false)` = note: see for more information about checking conditional configuration diff --git a/tests/ui/check-cfg/raw-keywords.edition2021.stderr b/tests/ui/check-cfg/raw-keywords.edition2021.stderr index cc3702685fd2c..5859b7592941a 100644 --- a/tests/ui/check-cfg/raw-keywords.edition2021.stderr +++ b/tests/ui/check-cfg/raw-keywords.edition2021.stderr @@ -14,7 +14,7 @@ warning: unexpected `cfg` condition name: `r#false` LL | #[cfg(r#false)] | ^^^^^^^ | - = help: expected names are: `r#async`, `edition2015`, `edition2021`, and `r#true` and 31 more + = help: expected names are: `r#async`, `edition2015`, `edition2021`, and `r#true` and 32 more = help: to expect this configuration use `--check-cfg=cfg(r#false)` = note: see for more information about checking conditional configuration diff --git a/tests/ui/check-cfg/report-in-external-macros.cargo.stderr b/tests/ui/check-cfg/report-in-external-macros.cargo.stderr index 4b5fc91c7eb91..b474322d6afaf 100644 --- a/tests/ui/check-cfg/report-in-external-macros.cargo.stderr +++ b/tests/ui/check-cfg/report-in-external-macros.cargo.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `my_lib_cfg` LL | cfg_macro::my_lib_macro!(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `feature` and 31 more + = help: expected names are: `feature` and 32 more = note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate = help: try referring to `cfg_macro::my_lib_macro` crate for guidance on how handle this unexpected cfg = help: the macro `cfg_macro::my_lib_macro` may come from an old version of the `cfg_macro` crate, try updating your dependency with `cargo update -p cfg_macro` diff --git a/tests/ui/check-cfg/report-in-external-macros.rustc.stderr b/tests/ui/check-cfg/report-in-external-macros.rustc.stderr index 0d99d061d28df..860610baa9719 100644 --- a/tests/ui/check-cfg/report-in-external-macros.rustc.stderr +++ b/tests/ui/check-cfg/report-in-external-macros.rustc.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `my_lib_cfg` LL | cfg_macro::my_lib_macro!(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `feature` and 31 more + = help: expected names are: `feature` and 32 more = note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate = help: try referring to `cfg_macro::my_lib_macro` crate for guidance on how handle this unexpected cfg = help: to expect this configuration use `--check-cfg=cfg(my_lib_cfg)` diff --git a/tests/ui/check-cfg/well-known-names.stderr b/tests/ui/check-cfg/well-known-names.stderr index 4edf608589d5c..d946377f2616b 100644 --- a/tests/ui/check-cfg/well-known-names.stderr +++ b/tests/ui/check-cfg/well-known-names.stderr @@ -28,6 +28,7 @@ LL | #[cfg(list_all_well_known_cfgs)] `target_has_atomic` `target_has_atomic_equal_alignment` `target_has_atomic_load_store` +`target_object_format` `target_os` `target_pointer_width` `target_thread_local` diff --git a/tests/ui/check-cfg/well-known-values.rs b/tests/ui/check-cfg/well-known-values.rs index 0eb749b55a7bf..f48438d142467 100644 --- a/tests/ui/check-cfg/well-known-values.rs +++ b/tests/ui/check-cfg/well-known-values.rs @@ -15,6 +15,7 @@ #![feature(cfg_target_has_atomic)] #![feature(cfg_target_has_atomic_equal_alignment)] #![feature(cfg_target_thread_local)] +#![feature(cfg_target_object_format)] #![feature(cfg_ub_checks)] #![feature(fmt_debug)] @@ -68,6 +69,8 @@ //~^ WARN unexpected `cfg` condition value target_has_atomic_load_store = "_UNEXPECTED_VALUE", //~^ WARN unexpected `cfg` condition value + target_object_format = "_UNEXPECTED_VALUE", + //~^ WARN unexpected `cfg` condition value target_os = "_UNEXPECTED_VALUE", //~^ WARN unexpected `cfg` condition value target_pointer_width = "_UNEXPECTED_VALUE", diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index 0ba2f0b0f2096..dd1b696b76cb2 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -1,5 +1,5 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:29:5 + --> $DIR/well-known-values.rs:30:5 | LL | clippy = "_UNEXPECTED_VALUE", | ^^^^^^---------------------- @@ -11,7 +11,7 @@ LL | clippy = "_UNEXPECTED_VALUE", = note: `#[warn(unexpected_cfgs)]` on by default warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:31:5 + --> $DIR/well-known-values.rs:32:5 | LL | debug_assertions = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^---------------------- @@ -22,7 +22,7 @@ LL | debug_assertions = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:33:5 + --> $DIR/well-known-values.rs:34:5 | LL | doc = "_UNEXPECTED_VALUE", | ^^^---------------------- @@ -33,7 +33,7 @@ LL | doc = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:35:5 + --> $DIR/well-known-values.rs:36:5 | LL | doctest = "_UNEXPECTED_VALUE", | ^^^^^^^---------------------- @@ -44,7 +44,7 @@ LL | doctest = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:37:5 + --> $DIR/well-known-values.rs:38:5 | LL | fmt_debug = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -53,7 +53,7 @@ LL | fmt_debug = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:39:5 + --> $DIR/well-known-values.rs:40:5 | LL | miri = "_UNEXPECTED_VALUE", | ^^^^---------------------- @@ -64,7 +64,7 @@ LL | miri = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:41:5 + --> $DIR/well-known-values.rs:42:5 | LL | overflow_checks = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^---------------------- @@ -75,7 +75,7 @@ LL | overflow_checks = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:43:5 + --> $DIR/well-known-values.rs:44:5 | LL | panic = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -84,7 +84,7 @@ LL | panic = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:45:5 + --> $DIR/well-known-values.rs:46:5 | LL | proc_macro = "_UNEXPECTED_VALUE", | ^^^^^^^^^^---------------------- @@ -95,7 +95,7 @@ LL | proc_macro = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:47:5 + --> $DIR/well-known-values.rs:48:5 | LL | relocation_model = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -104,7 +104,7 @@ LL | relocation_model = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:49:5 + --> $DIR/well-known-values.rs:50:5 | LL | rustfmt = "_UNEXPECTED_VALUE", | ^^^^^^^---------------------- @@ -115,7 +115,7 @@ LL | rustfmt = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:51:5 + --> $DIR/well-known-values.rs:52:5 | LL | sanitize = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -124,7 +124,7 @@ LL | sanitize = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:53:5 + --> $DIR/well-known-values.rs:54:5 | LL | target_abi = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -133,7 +133,7 @@ LL | target_abi = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:55:5 + --> $DIR/well-known-values.rs:56:5 | LL | target_arch = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -142,7 +142,7 @@ LL | target_arch = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:57:5 + --> $DIR/well-known-values.rs:58:5 | LL | target_endian = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -151,7 +151,7 @@ LL | target_endian = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:59:5 + --> $DIR/well-known-values.rs:60:5 | LL | target_env = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -160,7 +160,7 @@ LL | target_env = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:61:5 + --> $DIR/well-known-values.rs:62:5 | LL | target_family = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -169,7 +169,7 @@ LL | target_family = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:65:5 + --> $DIR/well-known-values.rs:66:5 | LL | target_has_atomic = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -178,7 +178,7 @@ LL | target_has_atomic = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:67:5 + --> $DIR/well-known-values.rs:68:5 | LL | target_has_atomic_equal_alignment = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -187,7 +187,7 @@ LL | target_has_atomic_equal_alignment = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:69:5 + --> $DIR/well-known-values.rs:70:5 | LL | target_has_atomic_load_store = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -196,7 +196,16 @@ LL | target_has_atomic_load_store = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:71:5 + --> $DIR/well-known-values.rs:72:5 + | +LL | target_object_format = "_UNEXPECTED_VALUE", + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: expected values for `target_object_format` are: `coff`, `elf`, `mach-o`, `wasm`, and `xcoff` + = note: see for more information about checking conditional configuration + +warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` + --> $DIR/well-known-values.rs:74:5 | LL | target_os = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -205,7 +214,7 @@ LL | target_os = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:73:5 + --> $DIR/well-known-values.rs:76:5 | LL | target_pointer_width = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -214,7 +223,7 @@ LL | target_pointer_width = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:75:5 + --> $DIR/well-known-values.rs:78:5 | LL | target_thread_local = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^---------------------- @@ -225,7 +234,7 @@ LL | target_thread_local = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:77:5 + --> $DIR/well-known-values.rs:80:5 | LL | target_vendor = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -234,7 +243,7 @@ LL | target_vendor = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:79:5 + --> $DIR/well-known-values.rs:82:5 | LL | ub_checks = "_UNEXPECTED_VALUE", | ^^^^^^^^^---------------------- @@ -245,7 +254,7 @@ LL | ub_checks = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:81:5 + --> $DIR/well-known-values.rs:84:5 | LL | unix = "_UNEXPECTED_VALUE", | ^^^^---------------------- @@ -256,7 +265,7 @@ LL | unix = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` - --> $DIR/well-known-values.rs:83:5 + --> $DIR/well-known-values.rs:86:5 | LL | windows = "_UNEXPECTED_VALUE", | ^^^^^^^---------------------- @@ -267,7 +276,7 @@ LL | windows = "_UNEXPECTED_VALUE", = note: see for more information about checking conditional configuration warning: unexpected `cfg` condition value: `linuz` - --> $DIR/well-known-values.rs:89:7 + --> $DIR/well-known-values.rs:92:7 | LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux` | ^^^^^^^^^^^^------- @@ -277,5 +286,5 @@ LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux` = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qurt`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` = note: see for more information about checking conditional configuration -warning: 28 warnings emitted +warning: 29 warnings emitted diff --git a/tests/ui/feature-gates/feature-gate-cfg_target_object_format.rs b/tests/ui/feature-gates/feature-gate-cfg_target_object_format.rs new file mode 100644 index 0000000000000..6cb16a4d036c4 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg_target_object_format.rs @@ -0,0 +1,6 @@ +#[allow(unused)] +#[cfg(target_object_format = "elf")] +//~^ ERROR `cfg(target_object_format)` is experimental +const X: () = (); + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-cfg_target_object_format.stderr b/tests/ui/feature-gates/feature-gate-cfg_target_object_format.stderr new file mode 100644 index 0000000000000..bd65d9c175cd3 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg_target_object_format.stderr @@ -0,0 +1,13 @@ +error[E0658]: `cfg(target_object_format)` is experimental and subject to change + --> $DIR/feature-gate-cfg_target_object_format.rs:2:7 + | +LL | #[cfg(target_object_format = "elf")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #152586 for more information + = help: add `#![feature(cfg_target_object_format)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/macros/cfg.stderr b/tests/ui/macros/cfg.stderr index 06529a5b7a61f..681c647def686 100644 --- a/tests/ui/macros/cfg.stderr +++ b/tests/ui/macros/cfg.stderr @@ -38,7 +38,7 @@ warning: unexpected `cfg` condition name: `foo` LL | cfg!(foo); | ^^^ | - = help: expected names are: `FALSE` and `test` and 31 more + = help: expected names are: `FALSE` and `test` and 32 more = help: to expect this configuration use `--check-cfg=cfg(foo)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/macros/cfg_select.stderr b/tests/ui/macros/cfg_select.stderr index d2803964e00c2..e20028a29d527 100644 --- a/tests/ui/macros/cfg_select.stderr +++ b/tests/ui/macros/cfg_select.stderr @@ -101,7 +101,7 @@ warning: unexpected `cfg` condition name: `a` LL | a + 1 => {} | ^ help: found config with similar value: `target_feature = "a"` | - = help: expected names are: `FALSE` and `test` and 31 more + = help: expected names are: `FALSE` and `test` and 32 more = help: to expect this configuration use `--check-cfg=cfg(a)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default From 9371fea6e6f31a3c1ab23ae7be48120130c31533 Mon Sep 17 00:00:00 2001 From: Mattia Pitossi Date: Sat, 11 Apr 2026 14:31:53 +0000 Subject: [PATCH 15/20] fix spurious test failure in `metadata_access_times` * remove time assertion on SystemTime * skip test only if when a time change occurs --- library/std/src/fs/tests.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index 42f3ccc340b27..b4cfbe4ff5f15 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -1731,6 +1731,8 @@ fn create_dir_all_with_junctions() { #[test] fn metadata_access_times() { + let start_time = SystemTime::now(); + let tmpdir = tmpdir(); let b = tmpdir.join("b"); @@ -1751,7 +1753,14 @@ fn metadata_access_times() { if cfg!(target_os = "linux") { // Not always available match (a.created(), b.created()) { - (Ok(t1), Ok(t2)) => assert!(t1 <= t2), + // It could be that, when the system clock goes backwards (e.g., due time change) + // b, that gets created after a, has a greater creation date than a. + // When such rare case occurs we skip the test, since the test to check that b + // should be created after a would fail. + (Ok(t1), Ok(t2)) => match start_time.elapsed() { + Ok(_) => assert!(t1 <= t2), + Err(_) => {} + }, (Err(e1), Err(e2)) if e1.kind() == ErrorKind::Uncategorized && e2.kind() == ErrorKind::Uncategorized From 8998c11244b5ea0132871601336f62e0d23ae8aa Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Sun, 12 Apr 2026 00:03:26 +0900 Subject: [PATCH 16/20] add next-solver min-specialization region-resolution regression test --- .../next-solver-region-resolution.rs | 26 +++++++ .../next-solver-region-resolution.stderr | 69 +++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 tests/ui/specialization/min_specialization/next-solver-region-resolution.rs create mode 100644 tests/ui/specialization/min_specialization/next-solver-region-resolution.stderr diff --git a/tests/ui/specialization/min_specialization/next-solver-region-resolution.rs b/tests/ui/specialization/min_specialization/next-solver-region-resolution.rs new file mode 100644 index 0000000000000..d4b74802c2df7 --- /dev/null +++ b/tests/ui/specialization/min_specialization/next-solver-region-resolution.rs @@ -0,0 +1,26 @@ +//@ compile-flags: -Znext-solver=globally +// Regression test for https://github.com/rust-lang/rust/issues/151327 + +#![feature(min_specialization)] + +trait Foo { + type Item; +} + +trait Baz {} + +impl<'a, T> Foo for &'a T //~ ERROR not all trait items implemented, missing: `Item` +//~| ERROR the trait bound `&'a T: Foo` is not satisfied +where + Self::Item: 'a, //~ ERROR the trait bound `&'a T: Foo` is not satisfied +{ +} + +impl<'a, T> Foo for &T //~ ERROR not all trait items implemented, missing: `Item` +//~| ERROR cannot normalize `<&_ as Foo>::Item: '_` +where + Self::Item: Baz, +{ +} + +fn main() {} diff --git a/tests/ui/specialization/min_specialization/next-solver-region-resolution.stderr b/tests/ui/specialization/min_specialization/next-solver-region-resolution.stderr new file mode 100644 index 0000000000000..df0e8fefaa848 --- /dev/null +++ b/tests/ui/specialization/min_specialization/next-solver-region-resolution.stderr @@ -0,0 +1,69 @@ +error[E0046]: not all trait items implemented, missing: `Item` + --> $DIR/next-solver-region-resolution.rs:12:1 + | +LL | type Item; + | --------- `Item` from trait +... +LL | / impl<'a, T> Foo for &'a T +LL | | +LL | | where +LL | | Self::Item: 'a, + | |___________________^ missing `Item` in implementation + +error[E0277]: the trait bound `&'a T: Foo` is not satisfied + --> $DIR/next-solver-region-resolution.rs:12:21 + | +LL | impl<'a, T> Foo for &'a T + | ^^^^^ the trait `Foo` is not implemented for `&'a T` + | +help: the trait `Foo` is not implemented for `&'a _` + but it is implemented for `&_` + --> $DIR/next-solver-region-resolution.rs:12:1 + | +LL | / impl<'a, T> Foo for &'a T +LL | | +LL | | where +LL | | Self::Item: 'a, + | |___________________^ + +error[E0277]: the trait bound `&'a T: Foo` is not satisfied + --> $DIR/next-solver-region-resolution.rs:15:17 + | +LL | Self::Item: 'a, + | ^^ the trait `Foo` is not implemented for `&'a T` + | +help: the trait `Foo` is not implemented for `&'a _` + but it is implemented for `&_` + --> $DIR/next-solver-region-resolution.rs:12:1 + | +LL | / impl<'a, T> Foo for &'a T +LL | | +LL | | where +LL | | Self::Item: 'a, + | |___________________^ + +error[E0046]: not all trait items implemented, missing: `Item` + --> $DIR/next-solver-region-resolution.rs:19:1 + | +LL | type Item; + | --------- `Item` from trait +... +LL | / impl<'a, T> Foo for &T +LL | | +LL | | where +LL | | Self::Item: Baz, + | |____________________^ missing `Item` in implementation + +error: cannot normalize `<&_ as Foo>::Item: '_` + --> $DIR/next-solver-region-resolution.rs:19:1 + | +LL | / impl<'a, T> Foo for &T +LL | | +LL | | where +LL | | Self::Item: Baz, + | |____________________^ + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0046, E0277. +For more information about an error, try `rustc --explain E0046`. From 40a3ed1e1407ebbe892ce1a74128482ea1dadf7a Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Sun, 12 Apr 2026 00:03:46 +0900 Subject: [PATCH 17/20] propagate region resolution failures --- .../rustc_hir_analysis/src/impl_wf_check/min_specialization.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs index 41af59388f798..47bd2fd37dff5 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs @@ -190,7 +190,7 @@ fn get_impl_args( } let assumed_wf_types = ocx.assumed_wf_types_and_report_errors(param_env, impl1_def_id)?; - let _ = ocx.resolve_regions_and_report_errors(impl1_def_id, param_env, assumed_wf_types); + ocx.resolve_regions_and_report_errors(impl1_def_id, param_env, assumed_wf_types)?; let Ok(impl2_args) = infcx.fully_resolve(impl2_args) else { let span = tcx.def_span(impl1_def_id); let guar = tcx.dcx().emit_err(GenericArgsOnOverriddenImpl { span }); From 0557e3478104037c76c2e5be7ea21e56ebbaff6e Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Sat, 11 Apr 2026 17:13:30 +0200 Subject: [PATCH 18/20] Add `f16` vector support (#513) * Add `f16` vector support * run `cargo update` * disable `f16` tests on wasm32 with simd128 llvm hangs in that case, see https://github.com/llvm/llvm-project/issues/189251 * Add reference to LLVM issue causing f16 wasm ICE --------- Co-authored-by: Caleb Zulawski --- Cargo.lock | 338 +++++++++++++++---------- Cargo.toml | 5 + crates/core_simd/Cargo.toml | 4 +- crates/core_simd/src/alias.rs | 10 + crates/core_simd/src/cast.rs | 3 + crates/core_simd/src/lib.rs | 1 + crates/core_simd/src/ops.rs | 2 +- crates/core_simd/src/ops/unary.rs | 2 + crates/core_simd/src/simd/cmp/eq.rs | 2 +- crates/core_simd/src/simd/cmp/ord.rs | 2 +- crates/core_simd/src/simd/num/float.rs | 2 +- crates/core_simd/src/vector.rs | 7 + crates/core_simd/tests/f16_ops.rs | 10 + crates/std_float/src/lib.rs | 9 + crates/test_helpers/Cargo.toml | 2 +- crates/test_helpers/src/biteq.rs | 2 +- crates/test_helpers/src/lib.rs | 2 + crates/test_helpers/src/subnormals.rs | 2 +- 18 files changed, 261 insertions(+), 144 deletions(-) create mode 100644 crates/core_simd/tests/f16_ops.rs diff --git a/Cargo.lock b/Cargo.lock index 754a93653ee7f..c3b950bd5069c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,17 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "async-trait" +version = "0.1.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "autocfg" version = "1.5.0" @@ -16,24 +27,31 @@ checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" [[package]] name = "bumpalo" -version = "3.19.0" +version = "3.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.33" +version = "1.2.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ee0f8803222ba5a7e2777dd72ca451868909b1ac410621b676adf07280e9b5f" +checksum = "e1e928d4b69e3077709075a938a05ffbedfa53a84c8f766efbf8220bb1ff60e1" dependencies = [ + "find-msvc-tools", "shlex", ] [[package]] name = "cfg-if" -version = "1.0.1" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "core_simd" @@ -47,6 +65,12 @@ dependencies = [ "wasm-bindgen-test", ] +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + [[package]] name = "float-cmp" version = "0.10.0" @@ -56,6 +80,30 @@ dependencies = [ "num-traits", ] +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + [[package]] name = "getrandom" version = "0.3.4" @@ -70,12 +118,20 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + [[package]] name = "js-sys" -version = "0.3.77" +version = "0.3.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +checksum = "cc4c90f45aa2e6eacbe8645f77fdea542ac97a494bcd117a67df9ff4d611f995" dependencies = [ + "cfg-if", + "futures-util", "once_cell", "wasm-bindgen", ] @@ -87,21 +143,36 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" [[package]] -name = "log" -version = "0.4.27" +name = "libm" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] name = "minicov" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f27fe9f1cc3c22e1687f9446c2083c4c5fc7f0bcf1c7a86bdbded14985895b4b" +checksum = "4869b6a491569605d66d3952bcdf03df789e5b536e5f0cf7758a7f08a55ae24d" dependencies = [ "cc", "walkdir", ] +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -109,13 +180,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", + "libm", ] [[package]] name = "once_cell" -version = "1.21.3" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "oorandom" +version = "11.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" + +[[package]] +name = "pin-project-lite" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "ppv-lite86" @@ -128,18 +212,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.101" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] [[package]] name = "proptest" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37566cb3fdacef14c0737f9546df7cfeadbfbc9fef10991038bf5015d0c80532" +checksum = "4b45fcc2344c680f5025fe57779faef368840d0bd1f42f216291f0dc4ace4744" dependencies = [ "bitflags", "num-traits", @@ -152,9 +236,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.40" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" dependencies = [ "proc-macro2", ] @@ -224,12 +308,61 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + [[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + [[package]] name = "std_float" version = "0.1.0" @@ -242,9 +375,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.106" +version = "2.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" dependencies = [ "proc-macro2", "quote", @@ -267,9 +400,9 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "walkdir" @@ -292,48 +425,32 @@ dependencies = [ [[package]] name = "wasm-bindgen" -version = "0.2.100" +version = "0.2.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +checksum = "6523d69017b7633e396a89c5efab138161ed5aafcbc8d3e5c5a42ae38f50495a" dependencies = [ "cfg-if", "once_cell", "rustversion", "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" -dependencies = [ - "bumpalo", - "log", - "proc-macro2", - "quote", - "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.50" +version = "0.4.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +checksum = "2d1faf851e778dfa54db7cd438b70758eba9755cb47403f3496edd7c8fc212f0" dependencies = [ - "cfg-if", "js-sys", - "once_cell", "wasm-bindgen", - "web-sys", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.100" +version = "0.2.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +checksum = "4e3a6c758eb2f701ed3d052ff5737f5bfe6614326ea7f3bbac7156192dc32e67" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -341,44 +458,53 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.100" +version = "0.2.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +checksum = "921de2737904886b52bcbb237301552d05969a6f9c40d261eb0533c8b055fedf" dependencies = [ + "bumpalo", "proc-macro2", "quote", "syn", - "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.100" +version = "0.2.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +checksum = "a93e946af942b58934c604527337bad9ae33ba1d5c6900bbb41c2c07c2364a93" dependencies = [ "unicode-ident", ] [[package]] name = "wasm-bindgen-test" -version = "0.3.50" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66c8d5e33ca3b6d9fa3b4676d774c5778031d27a578c2b007f905acf816152c3" +checksum = "1138411301a026d6662dc44e7076a74dbaa76a369312275eea5dee4d7dc68c7c" dependencies = [ + "async-trait", + "cast", "js-sys", + "libm", "minicov", + "nu-ansi-term", + "num-traits", + "oorandom", + "serde", + "serde_json", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test-macro", + "wasm-bindgen-test-shared", ] [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.50" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17d5042cc5fa009658f9a7333ef24291b1291a25b6382dd68862a7f3b969f69b" +checksum = "186ddfe8383ba7ae7927bae3bb7343fd1f03ba2dbaf1474410f0d831131c269b" dependencies = [ "proc-macro2", "quote", @@ -386,97 +512,35 @@ dependencies = [ ] [[package]] -name = "web-sys" -version = "0.3.77" +name = "wasm-bindgen-test-shared" +version = "0.2.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" -dependencies = [ - "js-sys", - "wasm-bindgen", -] +checksum = "f032e076ceb8d36d5921c6cef5bf447f2ca2bbd5439ce1683d68d1c99cc2be16" [[package]] name = "winapi-util" -version = "0.1.9" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ "windows-sys", ] [[package]] -name = "windows-sys" -version = "0.59.0" +name = "windows-link" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" -dependencies = [ - "windows-targets", -] +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] -name = "windows-targets" -version = "0.52.6" +name = "windows-sys" +version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows-link", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - [[package]] name = "wit-bindgen" version = "0.51.0" @@ -485,20 +549,26 @@ checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" [[package]] name = "zerocopy" -version = "0.8.26" +version = "0.8.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" +checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.26" +version = "0.8.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" +checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" dependencies = [ "proc-macro2", "quote", "syn", ] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml index 21d4584a9f4d9..883140bae3f62 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,3 +11,8 @@ opt-level = 2 [profile.test.package.test_helpers] opt-level = 2 + +[workspace.dependencies.proptest] +version = "1.11" +default-features = false +features = ["alloc", "f16"] diff --git a/crates/core_simd/Cargo.toml b/crates/core_simd/Cargo.toml index b388aaae86660..6e576084ecfba 100644 --- a/crates/core_simd/Cargo.toml +++ b/crates/core_simd/Cargo.toml @@ -18,9 +18,7 @@ wasm-bindgen = "0.2" wasm-bindgen-test = "0.3" [dev-dependencies.proptest] -version = "1.0" -default-features = false -features = ["alloc"] +workspace = true # Enable the `wasm_js` feature so that getrandom works on wasm32-unknown-unknown. [dev-dependencies.getrandom] diff --git a/crates/core_simd/src/alias.rs b/crates/core_simd/src/alias.rs index 23f121c46197c..6dcfcb660c26a 100644 --- a/crates/core_simd/src/alias.rs +++ b/crates/core_simd/src/alias.rs @@ -153,6 +153,16 @@ alias! { usizex64 64 } + f16 = { + f16x1 1 + f16x2 2 + f16x4 4 + f16x8 8 + f16x16 16 + f16x32 32 + f16x64 64 + } + f32 = { f32x1 1 f32x2 2 diff --git a/crates/core_simd/src/cast.rs b/crates/core_simd/src/cast.rs index 1c3592f807578..69dc7ba50d58d 100644 --- a/crates/core_simd/src/cast.rs +++ b/crates/core_simd/src/cast.rs @@ -44,6 +44,9 @@ impl SimdCast for u64 {} unsafe impl Sealed for usize {} impl SimdCast for usize {} // Safety: primitive number types can be cast to other primitive number types +unsafe impl Sealed for f16 {} +impl SimdCast for f16 {} +// Safety: primitive number types can be cast to other primitive number types unsafe impl Sealed for f32 {} impl SimdCast for f32 {} // Safety: primitive number types can be cast to other primitive number types diff --git a/crates/core_simd/src/lib.rs b/crates/core_simd/src/lib.rs index 115be44661c3a..413a886f6c5b8 100644 --- a/crates/core_simd/src/lib.rs +++ b/crates/core_simd/src/lib.rs @@ -1,6 +1,7 @@ #![no_std] #![feature( convert_float_to_int, + f16, core_intrinsics, decl_macro, repr_simd, diff --git a/crates/core_simd/src/ops.rs b/crates/core_simd/src/ops.rs index eb6601f734831..c0a06ed465129 100644 --- a/crates/core_simd/src/ops.rs +++ b/crates/core_simd/src/ops.rs @@ -245,7 +245,7 @@ for_base_ops! { // We don't need any special precautions here: // Floats always accept arithmetic ops, but may become NaN. for_base_ops! { - T = (f32, f64); + T = (f16, f32, f64); type Lhs = Simd; type Rhs = Simd; type Output = Self; diff --git a/crates/core_simd/src/ops/unary.rs b/crates/core_simd/src/ops/unary.rs index e1c06167f9790..af7aa8a823d99 100644 --- a/crates/core_simd/src/ops/unary.rs +++ b/crates/core_simd/src/ops/unary.rs @@ -19,6 +19,8 @@ macro_rules! neg { } neg! { + impl Neg for Simd + impl Neg for Simd impl Neg for Simd diff --git a/crates/core_simd/src/simd/cmp/eq.rs b/crates/core_simd/src/simd/cmp/eq.rs index d553d6c040c91..76836404cbc4e 100644 --- a/crates/core_simd/src/simd/cmp/eq.rs +++ b/crates/core_simd/src/simd/cmp/eq.rs @@ -42,7 +42,7 @@ macro_rules! impl_number { } } -impl_number! { f32, f64, u8, u16, u32, u64, usize, i8, i16, i32, i64, isize } +impl_number! { f16, f32, f64, u8, u16, u32, u64, usize, i8, i16, i32, i64, isize } macro_rules! impl_mask { { $($integer:ty),* } => { diff --git a/crates/core_simd/src/simd/cmp/ord.rs b/crates/core_simd/src/simd/cmp/ord.rs index 5672fbbf54caa..5a4e74c753b5a 100644 --- a/crates/core_simd/src/simd/cmp/ord.rs +++ b/crates/core_simd/src/simd/cmp/ord.rs @@ -144,7 +144,7 @@ macro_rules! impl_float { } } -impl_float! { f32, f64 } +impl_float! { f16, f32, f64 } macro_rules! impl_mask { { $($integer:ty),* } => { diff --git a/crates/core_simd/src/simd/num/float.rs b/crates/core_simd/src/simd/num/float.rs index efd7c2469512b..9f27e527f00fc 100644 --- a/crates/core_simd/src/simd/num/float.rs +++ b/crates/core_simd/src/simd/num/float.rs @@ -444,4 +444,4 @@ macro_rules! impl_trait { } } -impl_trait! { f32 { bits: u32, mask: i32 }, f64 { bits: u64, mask: i64 } } +impl_trait! { f16 { bits: u16, mask: i16 }, f32 { bits: u32, mask: i32 }, f64 { bits: u64, mask: i64 } } diff --git a/crates/core_simd/src/vector.rs b/crates/core_simd/src/vector.rs index c8e0b8c7eb9b3..fbef69f267aa5 100644 --- a/crates/core_simd/src/vector.rs +++ b/crates/core_simd/src/vector.rs @@ -1146,6 +1146,13 @@ unsafe impl SimdElement for isize { type Mask = isize; } +impl Sealed for f16 {} + +// Safety: f16 is a valid SIMD element type, and is supported by this API +unsafe impl SimdElement for f16 { + type Mask = i16; +} + impl Sealed for f32 {} // Safety: f32 is a valid SIMD element type, and is supported by this API diff --git a/crates/core_simd/tests/f16_ops.rs b/crates/core_simd/tests/f16_ops.rs new file mode 100644 index 0000000000000..f89bdf4738f8b --- /dev/null +++ b/crates/core_simd/tests/f16_ops.rs @@ -0,0 +1,10 @@ +#![feature(portable_simd)] +#![feature(f16)] + +#[macro_use] +mod ops_macros; + +// FIXME: some f16 operations cause rustc to hang on wasm simd +// https://github.com/llvm/llvm-project/issues/189251 +#[cfg(not(all(target_arch = "wasm32", target_feature = "simd128")))] +impl_float_tests! { f16, i16 } diff --git a/crates/std_float/src/lib.rs b/crates/std_float/src/lib.rs index acc1bfc19501a..ff3525452231a 100644 --- a/crates/std_float/src/lib.rs +++ b/crates/std_float/src/lib.rs @@ -2,6 +2,7 @@ feature = "as_crate", feature(core_intrinsics), feature(portable_simd), + feature(f16), allow(internal_features) )] #[cfg(not(feature = "as_crate"))] @@ -169,9 +170,17 @@ pub trait StdFloat: Sealed + Sized { fn fract(self) -> Self; } +impl Sealed for Simd {} impl Sealed for Simd {} impl Sealed for Simd {} +impl StdFloat for Simd { + #[inline] + fn fract(self) -> Self { + self - self.trunc() + } +} + impl StdFloat for Simd { #[inline] fn fract(self) -> Self { diff --git a/crates/test_helpers/Cargo.toml b/crates/test_helpers/Cargo.toml index f1e0a9b29a962..da7ef7bd9945c 100644 --- a/crates/test_helpers/Cargo.toml +++ b/crates/test_helpers/Cargo.toml @@ -5,5 +5,5 @@ edition = "2021" publish = false [dependencies] -proptest = { version = "1.0", default-features = false, features = ["alloc", "std"] } +proptest = { workspace = true, features = ["alloc", "std"] } float-cmp = "0.10" diff --git a/crates/test_helpers/src/biteq.rs b/crates/test_helpers/src/biteq.rs index cbc20cda0d626..36761e37dea76 100644 --- a/crates/test_helpers/src/biteq.rs +++ b/crates/test_helpers/src/biteq.rs @@ -53,7 +53,7 @@ macro_rules! impl_float_biteq { }; } -impl_float_biteq! { f32, f64 } +impl_float_biteq! { f16, f32, f64 } impl BitEq for *const T { fn biteq(&self, other: &Self) -> bool { diff --git a/crates/test_helpers/src/lib.rs b/crates/test_helpers/src/lib.rs index 4b036740af418..82adb06d8a9d4 100644 --- a/crates/test_helpers/src/lib.rs +++ b/crates/test_helpers/src/lib.rs @@ -1,3 +1,4 @@ +#![feature(f16)] #![cfg_attr( any(target_arch = "powerpc", target_arch = "powerpc64"), feature(powerpc_target_feature, stdarch_powerpc) @@ -46,6 +47,7 @@ impl_num! { u16 } impl_num! { u32 } impl_num! { u64 } impl_num! { usize } +impl_num! { f16 } impl_num! { f32 } impl_num! { f64 } diff --git a/crates/test_helpers/src/subnormals.rs b/crates/test_helpers/src/subnormals.rs index b5f19ba47b819..44dfbb3d6c955 100644 --- a/crates/test_helpers/src/subnormals.rs +++ b/crates/test_helpers/src/subnormals.rs @@ -39,7 +39,7 @@ macro_rules! impl_else { } } -impl_float! { f32, f64 } +impl_float! { f16, f32, f64 } impl_else! { i8, i16, i32, i64, isize, u8, u16, u32, u64, usize } /// AltiVec should flush subnormal inputs to zero, but QEMU seems to only flush outputs. From a133bb8f27b3e1f1a9fc8e4ac09ecd0f2a52c438 Mon Sep 17 00:00:00 2001 From: WilliamTakeshi Date: Sat, 11 Apr 2026 18:00:32 +0000 Subject: [PATCH 19/20] replace @ ty::AliasTy matches with just args --- .../rustc_borrowck/src/diagnostics/opaque_types.rs | 8 ++++---- compiler/rustc_hir_analysis/src/check/check.rs | 4 ++-- .../src/check/compare_impl_item.rs | 13 +++++++------ .../src/check/compare_impl_item/refine.rs | 8 ++++---- compiler/rustc_hir_analysis/src/check/wfcheck.rs | 4 ++-- .../rustc_hir_analysis/src/collect/item_bounds.rs | 13 ++++++------- .../rustc_hir_analysis/src/collect/predicates_of.rs | 12 ++++++------ compiler/rustc_lint/src/impl_trait_overcaptures.rs | 11 +++++------ compiler/rustc_pattern_analysis/src/rustc.rs | 6 +++--- compiler/rustc_ty_utils/src/opaque_types.rs | 4 ++-- 10 files changed, 41 insertions(+), 42 deletions(-) diff --git a/compiler/rustc_borrowck/src/diagnostics/opaque_types.rs b/compiler/rustc_borrowck/src/diagnostics/opaque_types.rs index 31890381fd5e3..94767ebdd693a 100644 --- a/compiler/rustc_borrowck/src/diagnostics/opaque_types.rs +++ b/compiler/rustc_borrowck/src/diagnostics/opaque_types.rs @@ -219,12 +219,12 @@ impl<'tcx> TypeVisitor> for FindOpaqueRegion<'_, 'tcx> { fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result { // If we find an opaque in a local ty, then for each of its captured regions, // try to find a path between that captured regions and our borrow region... - if let ty::Alias(opaque @ ty::AliasTy { kind: ty::Opaque { def_id }, .. }) = *ty.kind() + if let ty::Alias(ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) = *ty.kind() && let hir::OpaqueTyOrigin::FnReturn { parent, in_trait_or_impl: None } = self.tcx.opaque_ty_origin(def_id) { let variances = self.tcx.variances_of(def_id); - for (idx, (arg, variance)) in std::iter::zip(opaque.args, variances).enumerate() { + for (idx, (arg, variance)) in std::iter::zip(args, variances).enumerate() { // Skip uncaptured args. if *variance == ty::Bivariant { continue; @@ -276,12 +276,12 @@ impl<'tcx> TypeVisitor> for CheckExplicitRegionMentionAndCollectGen fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result { match *ty.kind() { - ty::Alias(opaque @ ty::AliasTy { kind: ty::Opaque { def_id }, .. }) => { + ty::Alias(ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) => { if self.seen_opaques.insert(def_id) { for (bound, _) in self .tcx .explicit_item_bounds(def_id) - .iter_instantiated_copied(self.tcx, opaque.args) + .iter_instantiated_copied(self.tcx, args) { bound.visit_with(self)?; } diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index b55506117c1dc..2dcd4ed24df4b 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -523,8 +523,8 @@ fn sanity_check_found_hidden_type<'tcx>( // Nothing was actually constrained. return Ok(()); } - if let &ty::Alias(alias @ ty::AliasTy { kind: ty::Opaque { def_id }, .. }) = ty.ty.kind() { - if def_id == key.def_id.to_def_id() && alias.args == key.args { + if let &ty::Alias(ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) = ty.ty.kind() { + if def_id == key.def_id.to_def_id() && args == key.args { // Nothing was actually constrained, this is an opaque usage that was // only discovered to be opaque after inference vars resolved. return Ok(()); diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index c4ec27e07124f..20ee6e34e5982 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -820,24 +820,25 @@ where } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { - if let &ty::Alias(proj @ ty::AliasTy { kind: ty::Projection { def_id }, .. }) = ty.kind() + if let &ty::Alias(ty::AliasTy { kind: ty::Projection { def_id }, args: proj_args, .. }) = + ty.kind() && self.cx().is_impl_trait_in_trait(def_id) { if let Some((ty, _)) = self.types.get(&def_id) { return *ty; } //FIXME(RPITIT): Deny nested RPITIT in args too - if proj.args.has_escaping_bound_vars() { + if proj_args.has_escaping_bound_vars() { bug!("FIXME(RPITIT): error here"); } // Replace with infer var let infer_ty = self.ocx.infcx.next_ty_var(self.span); - self.types.insert(def_id, (infer_ty, proj.args)); + self.types.insert(def_id, (infer_ty, proj_args)); // Recurse into bounds for (pred, pred_span) in self .cx() .explicit_item_bounds(def_id) - .iter_instantiated_copied(self.cx(), proj.args) + .iter_instantiated_copied(self.cx(), proj_args) { let pred = pred.fold_with(self); let pred = self.ocx.normalize( @@ -2707,8 +2708,8 @@ fn param_env_with_gat_bounds<'tcx>( let bound_vars = tcx.mk_bound_variable_kinds(&bound_vars); match normalize_impl_ty.kind() { - &ty::Alias(proj @ ty::AliasTy { kind: ty::Projection { def_id }, .. }) - if def_id == trait_ty.def_id && proj.args == rebased_args => + &ty::Alias(ty::AliasTy { kind: ty::Projection { def_id }, args, .. }) + if def_id == trait_ty.def_id && args == rebased_args => { // Don't include this predicate if the projected type is // exactly the same as the projection. This can occur in diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs index f0f15f5e98e8f..01e8a8c4b1934 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs @@ -308,9 +308,9 @@ fn report_mismatched_rpitit_signature<'tcx>( let mut return_ty = trait_m_sig.output().fold_with(&mut super::RemapLateParam { tcx, mapping }); if tcx.asyncness(impl_m_def_id).is_async() && tcx.asyncness(trait_m_def_id).is_async() { - let &ty::Alias( - future_ty @ ty::AliasTy { kind: ty::Projection { def_id: future_ty_def_id }, .. }, - ) = return_ty.kind() + let &ty::Alias(ty::AliasTy { + kind: ty::Projection { def_id: future_ty_def_id }, args, .. + }) = return_ty.kind() else { span_bug!( tcx.def_span(trait_m_def_id), @@ -319,7 +319,7 @@ fn report_mismatched_rpitit_signature<'tcx>( }; let Some(future_output_ty) = tcx .explicit_item_bounds(future_ty_def_id) - .iter_instantiated_copied(tcx, future_ty.args) + .iter_instantiated_copied(tcx, args) .find_map(|(clause, _)| match clause.kind().no_bound_vars()? { ty::ClauseKind::Projection(proj) => proj.term.as_type(), _ => None, diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index c7b87db5971fa..424a75bd4dcb3 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -773,10 +773,10 @@ impl<'tcx> GATArgsCollector<'tcx> { impl<'tcx> TypeVisitor> for GATArgsCollector<'tcx> { fn visit_ty(&mut self, t: Ty<'tcx>) { match t.kind() { - &ty::Alias(p @ ty::AliasTy { kind: ty::Projection { def_id }, .. }) + &ty::Alias(ty::AliasTy { kind: ty::Projection { def_id }, args, .. }) if def_id == self.gat => { - for (idx, arg) in p.args.iter().enumerate() { + for (idx, arg) in args.iter().enumerate() { match arg.kind() { GenericArgKind::Lifetime(lt) if !lt.is_bound() => { self.regions.insert((lt, idx)); diff --git a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs index eb005881245ce..98ac52e959297 100644 --- a/compiler/rustc_hir_analysis/src/collect/item_bounds.rs +++ b/compiler/rustc_hir_analysis/src/collect/item_bounds.rs @@ -549,17 +549,16 @@ impl<'tcx> TypeFolder> for AssocTyToOpaque<'tcx> { } fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { - if let &ty::Alias( - projection_ty @ ty::AliasTy { - kind: ty::Projection { def_id: projection_ty_def_id }, - .. - }, - ) = ty.kind() + if let &ty::Alias(ty::AliasTy { + kind: ty::Projection { def_id: projection_ty_def_id }, + args, + .. + }) = ty.kind() && let Some(ty::ImplTraitInTraitData::Trait { fn_def_id, .. }) = self.tcx.opt_rpitit_info(projection_ty_def_id) && fn_def_id == self.fn_def_id { - self.tcx.type_of(projection_ty_def_id).instantiate(self.tcx, projection_ty.args) + self.tcx.type_of(projection_ty_def_id).instantiate(self.tcx, args) } else { ty.super_fold_with(self) } diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 3c021416ace0b..89fca8e89a200 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -513,13 +513,13 @@ pub(super) fn explicit_predicates_of<'tcx>( // identity args of the trait. // * It must be an associated type for this trait (*not* a // supertrait). - if let &ty::Alias( - projection @ ty::AliasTy { - kind: ty::Projection { def_id: projection_def_id }, .. - }, - ) = ty.kind() + if let &ty::Alias(ty::AliasTy { + kind: ty::Projection { def_id: projection_def_id }, + args, + .. + }) = ty.kind() { - projection.args == trait_identity_args + args == trait_identity_args // FIXME(return_type_notation): This check should be more robust && !tcx.is_impl_trait_in_trait(projection_def_id) && tcx.parent(projection_def_id) == def_id.to_def_id() diff --git a/compiler/rustc_lint/src/impl_trait_overcaptures.rs b/compiler/rustc_lint/src/impl_trait_overcaptures.rs index 6edf2e9436650..e3a7be02fca51 100644 --- a/compiler/rustc_lint/src/impl_trait_overcaptures.rs +++ b/compiler/rustc_lint/src/impl_trait_overcaptures.rs @@ -242,13 +242,12 @@ where return; } - if let ty::Alias(opaque_ty @ ty::AliasTy { kind: ty::Projection { def_id }, .. }) = - *t.kind() + if let ty::Alias(ty::AliasTy { kind: ty::Projection { def_id }, args, .. }) = *t.kind() && self.tcx.is_impl_trait_in_trait(def_id) { // visit the opaque of the RPITIT - self.tcx.type_of(def_id).instantiate(self.tcx, opaque_ty.args).visit_with(self) - } else if let ty::Alias(opaque_ty @ ty::AliasTy { kind: ty::Opaque { def_id}, .. }) = *t.kind() + self.tcx.type_of(def_id).instantiate(self.tcx, args).visit_with(self) + } else if let ty::Alias(ty::AliasTy { kind: ty::Opaque { def_id }, args: opaque_ty_args, .. }) = *t.kind() && let Some(opaque_def_id) = def_id.as_local() // Don't recurse infinitely on an opaque && self.seen.insert(opaque_def_id) @@ -280,7 +279,7 @@ where continue; } - let arg = opaque_ty.args[param.index as usize]; + let arg = opaque_ty_args[param.index as usize]; // We need to turn all `ty::Param`/`ConstKind::Param` and // `ReEarlyParam`/`ReBound` into def ids. captured.insert(extract_def_id_from_arg(self.tcx, generics, arg)); @@ -413,7 +412,7 @@ where // in this lint as well. Interestingly, one place that I expect this lint to fire // is for `impl for<'a> Bound`, since `impl Other` will begin // to capture `'a` in e2024 (even though late-bound vars in opaques are not allowed). - for clause in self.tcx.item_bounds(def_id).iter_instantiated(self.tcx, opaque_ty.args) { + for clause in self.tcx.item_bounds(def_id).iter_instantiated(self.tcx, opaque_ty_args) { clause.visit_with(self) } } diff --git a/compiler/rustc_pattern_analysis/src/rustc.rs b/compiler/rustc_pattern_analysis/src/rustc.rs index 2ec434de61c1f..b0f589955124d 100644 --- a/compiler/rustc_pattern_analysis/src/rustc.rs +++ b/compiler/rustc_pattern_analysis/src/rustc.rs @@ -126,12 +126,12 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> { #[inline] pub fn reveal_opaque_ty(&self, ty: Ty<'tcx>) -> RevealedTy<'tcx> { fn reveal_inner<'tcx>(cx: &RustcPatCtxt<'_, 'tcx>, ty: Ty<'tcx>) -> RevealedTy<'tcx> { - let ty::Alias(alias_ty @ ty::AliasTy { kind: ty::Opaque { .. }, .. }) = *ty.kind() + let ty::Alias(ty::AliasTy { kind: ty::Opaque { def_id }, args, .. }) = *ty.kind() else { bug!() }; - if let Some(local_def_id) = alias_ty.kind.def_id().as_local() { - let key = ty::OpaqueTypeKey { def_id: local_def_id, args: alias_ty.args }; + if let Some(local_def_id) = def_id.as_local() { + let key = ty::OpaqueTypeKey { def_id: local_def_id, args }; if let Some(ty) = cx.reveal_opaque_key(key) { return RevealedTy(ty); } diff --git a/compiler/rustc_ty_utils/src/opaque_types.rs b/compiler/rustc_ty_utils/src/opaque_types.rs index b5fa54d42ffb5..f27ab51278d3e 100644 --- a/compiler/rustc_ty_utils/src/opaque_types.rs +++ b/compiler/rustc_ty_utils/src/opaque_types.rs @@ -210,13 +210,13 @@ impl<'tcx> TypeVisitor> for OpaqueTypeCollector<'tcx> { } // Skips type aliases, as they are meant to be transparent. // FIXME(type_alias_impl_trait): can we require mentioning nested type aliases explicitly? - ty::Alias(alias_ty @ ty::AliasTy { kind: ty::Free { def_id }, .. }) + ty::Alias(ty::AliasTy { kind: ty::Free { def_id }, args, .. }) if let Some(def_id) = def_id.as_local() => { if !self.seen.insert(def_id) { return; } - self.tcx.type_of(def_id).instantiate(self.tcx, alias_ty.args).visit_with(self); + self.tcx.type_of(def_id).instantiate(self.tcx, args).visit_with(self); } ty::Alias( alias_ty @ ty::AliasTy { kind: ty::Projection { def_id: alias_def_id }, .. }, From c4e41560379aaa477cb6711cd52c5708ba4192b2 Mon Sep 17 00:00:00 2001 From: mejrs <59372212+mejrs@users.noreply.github.com> Date: Sat, 11 Apr 2026 21:14:45 +0200 Subject: [PATCH 20/20] Reduce size of `ImportData` --- compiler/rustc_resolve/src/imports.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 18db60167c27c..e24e65d55c00f 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -146,7 +146,7 @@ impl<'ra> std::fmt::Debug for ImportKind<'ra> { #[derive(Debug, Clone, Default)] pub(crate) struct OnUnknownData { - directive: Directive, + directive: Box, } impl OnUnknownData { @@ -161,7 +161,7 @@ impl OnUnknownData { Some(tcx.features()), ) { - Some(Self { directive: *directive? }) + Some(Self { directive: Box::new(*directive?) }) } else { None }