From ca1104f81fe18c065c3747766b29f0f7e654a1ba Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 5 Sep 2026 17:00:56 +0200 Subject: [PATCH 01/27] Revert "Reimplement _mm_mulhi_epi16, _mm_mulhi_epu16, _mm256_mulhi_epi16 and _mm256_mulhi_epu16 without LLVM intrinsics" This reverts commit 7abc64d599fcc93719f17ee08a03390d81424800. --- .../stdarch/crates/core_arch/src/x86/avx2.rs | 24 +++++++------------ .../stdarch/crates/core_arch/src/x86/sse2.rs | 24 +++++++------------ 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx2.rs b/library/stdarch/crates/core_arch/src/x86/avx2.rs index eb636a4fa0397..cb9ff94c5d74e 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx2.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx2.rs @@ -2231,14 +2231,8 @@ pub const fn _mm256_mul_epu32(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmulhw))] #[stable(feature = "simd_x86", since = "1.27.0")] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm256_mulhi_epi16(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = simd_cast::<_, i32x16>(a.as_i16x16()); - let b = simd_cast::<_, i32x16>(b.as_i16x16()); - let r = simd_shr(simd_mul(a, b), i32x16::splat(16)); - transmute(simd_cast::(r)) - } +pub fn _mm256_mulhi_epi16(a: __m256i, b: __m256i) -> __m256i { + unsafe { transmute(pmulhw(a.as_i16x16(), b.as_i16x16())) } } /// Multiplies the packed unsigned 16-bit integers in `a` and `b`, producing @@ -2250,14 +2244,8 @@ pub const fn _mm256_mulhi_epi16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpmulhuw))] #[stable(feature = "simd_x86", since = "1.27.0")] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm256_mulhi_epu16(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = simd_cast::<_, u32x16>(a.as_u16x16()); - let b = simd_cast::<_, u32x16>(b.as_u16x16()); - let r = simd_shr(simd_mul(a, b), u32x16::splat(16)); - transmute(simd_cast::(r)) - } +pub fn _mm256_mulhi_epu16(a: __m256i, b: __m256i) -> __m256i { + unsafe { transmute(pmulhuw(a.as_u16x16(), b.as_u16x16())) } } /// Multiplies the packed 16-bit integers in `a` and `b`, producing @@ -3825,6 +3813,10 @@ unsafe extern "llvm-intrinsic" { fn pmaddubsw(a: u8x32, b: i8x32) -> i16x16; #[link_name = "llvm.x86.avx2.mpsadbw"] fn mpsadbw(a: u8x32, b: u8x32, imm8: i8) -> u16x16; + #[link_name = "llvm.x86.avx2.pmulhu.w"] + fn pmulhuw(a: u16x16, b: u16x16) -> u16x16; + #[link_name = "llvm.x86.avx2.pmulh.w"] + fn pmulhw(a: i16x16, b: i16x16) -> i16x16; #[link_name = "llvm.x86.avx2.pmul.hr.sw"] fn pmulhrsw(a: i16x16, b: i16x16) -> i16x16; #[link_name = "llvm.x86.avx2.packsswb"] diff --git a/library/stdarch/crates/core_arch/src/x86/sse2.rs b/library/stdarch/crates/core_arch/src/x86/sse2.rs index 2c61b095c6b24..108d7510adf1a 100644 --- a/library/stdarch/crates/core_arch/src/x86/sse2.rs +++ b/library/stdarch/crates/core_arch/src/x86/sse2.rs @@ -294,14 +294,8 @@ pub const fn _mm_min_epu8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pmulhw))] #[stable(feature = "simd_x86", since = "1.27.0")] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm_mulhi_epi16(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = simd_cast::<_, i32x8>(a.as_i16x8()); - let b = simd_cast::<_, i32x8>(b.as_i16x8()); - let r = simd_shr(simd_mul(a, b), i32x8::splat(16)); - transmute(simd_cast::(r)) - } +pub fn _mm_mulhi_epi16(a: __m128i, b: __m128i) -> __m128i { + unsafe { transmute(pmulhw(a.as_i16x8(), b.as_i16x8())) } } /// Multiplies the packed unsigned 16-bit integers in `a` and `b`. @@ -314,14 +308,8 @@ pub const fn _mm_mulhi_epi16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pmulhuw))] #[stable(feature = "simd_x86", since = "1.27.0")] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm_mulhi_epu16(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = simd_cast::<_, u32x8>(a.as_u16x8()); - let b = simd_cast::<_, u32x8>(b.as_u16x8()); - let r = simd_shr(simd_mul(a, b), u32x8::splat(16)); - transmute(simd_cast::(r)) - } +pub fn _mm_mulhi_epu16(a: __m128i, b: __m128i) -> __m128i { + unsafe { transmute(pmulhuw(a.as_u16x8(), b.as_u16x8())) } } /// Multiplies the packed 16-bit integers in `a` and `b`. @@ -3202,6 +3190,10 @@ unsafe extern "llvm-intrinsic" { fn mfence(); #[link_name = "llvm.x86.sse2.pmadd.wd"] fn pmaddwd(a: i16x8, b: i16x8) -> i32x4; + #[link_name = "llvm.x86.sse2.pmulh.w"] + fn pmulhw(a: i16x8, b: i16x8) -> i16x8; + #[link_name = "llvm.x86.sse2.pmulhu.w"] + fn pmulhuw(a: u16x8, b: u16x8) -> u16x8; #[link_name = "llvm.x86.sse2.psad.bw"] fn psadbw(a: u8x16, b: u8x16) -> u64x2; #[link_name = "llvm.x86.sse2.psll.w"] From be4e27142a34e3e44750f7e1cc1badf34ecae6b7 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 5 Sep 2026 17:01:07 +0200 Subject: [PATCH 02/27] de-constify dependent intrinsics and tests --- .../stdarch/crates/core_arch/src/x86/avx2.rs | 4 +- .../crates/core_arch/src/x86/avx512bw.rs | 40 ++++++++----------- .../stdarch/crates/core_arch/src/x86/sse2.rs | 4 +- 3 files changed, 20 insertions(+), 28 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx2.rs b/library/stdarch/crates/core_arch/src/x86/avx2.rs index cb9ff94c5d74e..ead44f29f6a74 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx2.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx2.rs @@ -4927,7 +4927,7 @@ mod tests { } #[simd_test(enable = "avx2")] - const fn test_mm256_mulhi_epi16() { + fn test_mm256_mulhi_epi16() { let a = _mm256_set1_epi16(6535); let b = _mm256_set1_epi16(6535); let r = _mm256_mulhi_epi16(a, b); @@ -4936,7 +4936,7 @@ mod tests { } #[simd_test(enable = "avx2")] - const fn test_mm256_mulhi_epu16() { + fn test_mm256_mulhi_epu16() { let a = _mm256_set1_epi16(6535); let b = _mm256_set1_epi16(6535); let r = _mm256_mulhi_epu16(a, b); diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs index cda2fad4ef2de..0000b9ebdceb7 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs @@ -1502,8 +1502,7 @@ pub const fn _mm512_maskz_mulhi_epu16(k: __mmask32, a: __m512i, b: __m512i) -> _ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhuw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm256_mask_mulhi_epu16( +pub fn _mm256_mask_mulhi_epu16( src: __m256i, k: __mmask16, a: __m256i, @@ -1522,8 +1521,7 @@ pub const fn _mm256_mask_mulhi_epu16( #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhuw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm256_maskz_mulhi_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +pub fn _mm256_maskz_mulhi_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let mul = _mm256_mulhi_epu16(a, b).as_u16x16(); transmute(simd_select_bitmask(k, mul, u16x16::ZERO)) @@ -1537,8 +1535,7 @@ pub const fn _mm256_maskz_mulhi_epu16(k: __mmask16, a: __m256i, b: __m256i) -> _ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhuw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm_mask_mulhi_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +pub fn _mm_mask_mulhi_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let mul = _mm_mulhi_epu16(a, b).as_u16x8(); transmute(simd_select_bitmask(k, mul, src.as_u16x8())) @@ -1552,8 +1549,7 @@ pub const fn _mm_mask_mulhi_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m1 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhuw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm_maskz_mulhi_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +pub fn _mm_maskz_mulhi_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let mul = _mm_mulhi_epu16(a, b).as_u16x8(); transmute(simd_select_bitmask(k, mul, u16x8::ZERO)) @@ -1619,8 +1615,7 @@ pub const fn _mm512_maskz_mulhi_epi16(k: __mmask32, a: __m512i, b: __m512i) -> _ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm256_mask_mulhi_epi16( +pub fn _mm256_mask_mulhi_epi16( src: __m256i, k: __mmask16, a: __m256i, @@ -1639,8 +1634,7 @@ pub const fn _mm256_mask_mulhi_epi16( #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm256_maskz_mulhi_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +pub fn _mm256_maskz_mulhi_epi16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let mul = _mm256_mulhi_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, mul, i16x16::ZERO)) @@ -1654,8 +1648,7 @@ pub const fn _mm256_maskz_mulhi_epi16(k: __mmask16, a: __m256i, b: __m256i) -> _ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm_mask_mulhi_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +pub fn _mm_mask_mulhi_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let mul = _mm_mulhi_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, mul, src.as_i16x8())) @@ -1669,8 +1662,7 @@ pub const fn _mm_mask_mulhi_epi16(src: __m128i, k: __mmask8, a: __m128i, b: __m1 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm_maskz_mulhi_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +pub fn _mm_maskz_mulhi_epi16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let mul = _mm_mulhi_epi16(a, b).as_i16x8(); transmute(simd_select_bitmask(k, mul, i16x8::ZERO)) @@ -13934,7 +13926,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - const fn test_mm256_mask_mulhi_epu16() { + fn test_mm256_mask_mulhi_epu16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let r = _mm256_mask_mulhi_epu16(a, 0, a, b); @@ -13945,7 +13937,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - const fn test_mm256_maskz_mulhi_epu16() { + fn test_mm256_maskz_mulhi_epu16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let r = _mm256_maskz_mulhi_epu16(0, a, b); @@ -13956,7 +13948,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - const fn test_mm_mask_mulhi_epu16() { + fn test_mm_mask_mulhi_epu16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let r = _mm_mask_mulhi_epu16(a, 0, a, b); @@ -13967,7 +13959,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - const fn test_mm_maskz_mulhi_epu16() { + fn test_mm_maskz_mulhi_epu16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let r = _mm_maskz_mulhi_epu16(0, a, b); @@ -14013,7 +14005,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - const fn test_mm256_mask_mulhi_epi16() { + fn test_mm256_mask_mulhi_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let r = _mm256_mask_mulhi_epi16(a, 0, a, b); @@ -14024,7 +14016,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - const fn test_mm256_maskz_mulhi_epi16() { + fn test_mm256_maskz_mulhi_epi16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let r = _mm256_maskz_mulhi_epi16(0, a, b); @@ -14035,7 +14027,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - const fn test_mm_mask_mulhi_epi16() { + fn test_mm_mask_mulhi_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let r = _mm_mask_mulhi_epi16(a, 0, a, b); @@ -14046,7 +14038,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - const fn test_mm_maskz_mulhi_epi16() { + fn test_mm_maskz_mulhi_epi16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let r = _mm_maskz_mulhi_epi16(0, a, b); diff --git a/library/stdarch/crates/core_arch/src/x86/sse2.rs b/library/stdarch/crates/core_arch/src/x86/sse2.rs index 108d7510adf1a..4d5b23dc7225b 100644 --- a/library/stdarch/crates/core_arch/src/x86/sse2.rs +++ b/library/stdarch/crates/core_arch/src/x86/sse2.rs @@ -3539,14 +3539,14 @@ mod tests { } #[simd_test(enable = "sse2")] - const fn test_mm_mulhi_epi16() { + fn test_mm_mulhi_epi16() { let (a, b) = (_mm_set1_epi16(1000), _mm_set1_epi16(-1001)); let r = _mm_mulhi_epi16(a, b); assert_eq_m128i(r, _mm_set1_epi16(-16)); } #[simd_test(enable = "sse2")] - const fn test_mm_mulhi_epu16() { + fn test_mm_mulhi_epu16() { let (a, b) = (_mm_set1_epi16(1000), _mm_set1_epi16(1001)); let r = _mm_mulhi_epu16(a, b); assert_eq_m128i(r, _mm_set1_epi16(15)); From 33d0f2633c9e72a93ae8984a737d3c2613c6fe86 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 5 Sep 2026 17:01:13 +0200 Subject: [PATCH 03/27] fmt --- .../stdarch/crates/core_arch/src/x86/avx512bw.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs index 0000b9ebdceb7..f4406f05958a8 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs @@ -1502,12 +1502,7 @@ pub const fn _mm512_maskz_mulhi_epu16(k: __mmask32, a: __m512i, b: __m512i) -> _ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhuw))] -pub fn _mm256_mask_mulhi_epu16( - src: __m256i, - k: __mmask16, - a: __m256i, - b: __m256i, -) -> __m256i { +pub fn _mm256_mask_mulhi_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let mul = _mm256_mulhi_epu16(a, b).as_u16x16(); transmute(simd_select_bitmask(k, mul, src.as_u16x16())) @@ -1615,12 +1610,7 @@ pub const fn _mm512_maskz_mulhi_epi16(k: __mmask32, a: __m512i, b: __m512i) -> _ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhw))] -pub fn _mm256_mask_mulhi_epi16( - src: __m256i, - k: __mmask16, - a: __m256i, - b: __m256i, -) -> __m256i { +pub fn _mm256_mask_mulhi_epi16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let mul = _mm256_mulhi_epi16(a, b).as_i16x16(); transmute(simd_select_bitmask(k, mul, src.as_i16x16())) From 38dff1e9e17b4577fe427937a7fd97d040fa9897 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 5 Sep 2026 21:29:17 +0200 Subject: [PATCH 04/27] also adjust AVX512 intrinsics --- .../crates/core_arch/src/x86/avx512bw.rs | 59 ++++++------------- 1 file changed, 19 insertions(+), 40 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs index f4406f05958a8..349b46d562592 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs @@ -1450,14 +1450,8 @@ pub const fn _mm_maskz_subs_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128 #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhuw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm512_mulhi_epu16(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = simd_cast::<_, u32x32>(a.as_u16x32()); - let b = simd_cast::<_, u32x32>(b.as_u16x32()); - let r = simd_shr(simd_mul(a, b), u32x32::splat(16)); - transmute(simd_cast::(r)) - } +pub fn _mm512_mulhi_epu16(a: __m512i, b: __m512i) -> __m512i { + unsafe { transmute(vpmulhuw(a.as_u16x32(), b.as_u16x32())) } } /// Multiply the packed unsigned 16-bit integers in a and b, producing intermediate 32-bit integers, and store the high 16 bits of the intermediate integers in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -1467,13 +1461,7 @@ pub const fn _mm512_mulhi_epu16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhuw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm512_mask_mulhi_epu16( - src: __m512i, - k: __mmask32, - a: __m512i, - b: __m512i, -) -> __m512i { +pub fn _mm512_mask_mulhi_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let mul = _mm512_mulhi_epu16(a, b).as_u16x32(); transmute(simd_select_bitmask(k, mul, src.as_u16x32())) @@ -1487,8 +1475,7 @@ pub const fn _mm512_mask_mulhi_epu16( #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhuw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm512_maskz_mulhi_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +pub fn _mm512_maskz_mulhi_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let mul = _mm512_mulhi_epu16(a, b).as_u16x32(); transmute(simd_select_bitmask(k, mul, u16x32::ZERO)) @@ -1558,14 +1545,8 @@ pub fn _mm_maskz_mulhi_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm512_mulhi_epi16(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = simd_cast::<_, i32x32>(a.as_i16x32()); - let b = simd_cast::<_, i32x32>(b.as_i16x32()); - let r = simd_shr(simd_mul(a, b), i32x32::splat(16)); - transmute(simd_cast::(r)) - } +pub fn _mm512_mulhi_epi16(a: __m512i, b: __m512i) -> __m512i { + unsafe { transmute(vpmulhw(a.as_i16x32(), b.as_i16x32())) } } /// Multiply the packed signed 16-bit integers in a and b, producing intermediate 32-bit integers, and store the high 16 bits of the intermediate integers in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -1575,13 +1556,7 @@ pub const fn _mm512_mulhi_epi16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm512_mask_mulhi_epi16( - src: __m512i, - k: __mmask32, - a: __m512i, - b: __m512i, -) -> __m512i { +pub fn _mm512_mask_mulhi_epi16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let mul = _mm512_mulhi_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, mul, src.as_i16x32())) @@ -1595,8 +1570,7 @@ pub const fn _mm512_mask_mulhi_epi16( #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpmulhw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm512_maskz_mulhi_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +pub fn _mm512_maskz_mulhi_epi16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let mul = _mm512_mulhi_epi16(a, b).as_i16x32(); transmute(simd_select_bitmask(k, mul, i16x32::ZERO)) @@ -12583,6 +12557,11 @@ unsafe extern "llvm-intrinsic" { #[link_name = "llvm.x86.avx512.pmul.hr.sw.512"] fn vpmulhrsw(a: i16x32, b: i16x32) -> i16x32; + #[link_name = "llvm.x86.avx512.pmulhu.w.512"] + fn vpmulhuw(a: u16x32, b: u16x32) -> u16x32; + #[link_name = "llvm.x86.avx512.pmulh.w.512"] + fn vpmulhw(a: i16x32, b: i16x32) -> i16x32; + #[link_name = "llvm.x86.avx512.pmaddw.d.512"] fn vpmaddwd(a: i16x32, b: i16x32) -> i32x16; #[link_name = "llvm.x86.avx512.pmaddubs.w.512"] @@ -13881,7 +13860,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - const fn test_mm512_mulhi_epu16() { + fn test_mm512_mulhi_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_mulhi_epu16(a, b); @@ -13890,7 +13869,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - const fn test_mm512_mask_mulhi_epu16() { + fn test_mm512_mask_mulhi_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_mask_mulhi_epu16(a, 0, a, b); @@ -13903,7 +13882,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - const fn test_mm512_maskz_mulhi_epu16() { + fn test_mm512_maskz_mulhi_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_maskz_mulhi_epu16(0, a, b); @@ -13960,7 +13939,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - const fn test_mm512_mulhi_epi16() { + fn test_mm512_mulhi_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_mulhi_epi16(a, b); @@ -13969,7 +13948,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - const fn test_mm512_mask_mulhi_epi16() { + fn test_mm512_mask_mulhi_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_mask_mulhi_epi16(a, 0, a, b); @@ -13982,7 +13961,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - const fn test_mm512_maskz_mulhi_epi16() { + fn test_mm512_maskz_mulhi_epi16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_maskz_mulhi_epi16(0, a, b); From c76d283d24c7f8812d4440e3c593e5774083f7f3 Mon Sep 17 00:00:00 2001 From: WANG Rui Date: Fri, 18 Sep 2026 13:43:45 +0800 Subject: [PATCH 05/27] loongarch: Use LLVM intrinsics for vdiv/vmod Miri reports UB on division by zero with the LSX vdiv/vmod intrinsics when implemented via the portable simd_div/simd_rem helpers. [^1] Per clarification from the LoongArch ISA developers, the hardware defines that vdiv/vmod return 0 when the divisor is zero (this will be documented in the SIMD reference). This differs from the earlier assumption in PR #2078, so the portable helpers are not a correct match. Switch back to the corresponding LLVM intrinsics so the Rust wrappers preserve the defined ISA behavior. [^1]: https://github.com/rust-lang/stdarch/pull/2221#issuecomment-5688403926 --- .../src/loongarch64/lasx/generated.rs | 144 ++++++++++++++++++ .../src/loongarch64/lasx/portable.rs | 16 -- .../src/loongarch64/lsx/generated.rs | 144 ++++++++++++++++++ .../core_arch/src/loongarch64/lsx/portable.rs | 16 -- .../crates/stdarch-gen-loongarch/lasx.spec | 16 -- .../crates/stdarch-gen-loongarch/lsx.spec | 16 -- .../src/portable-intrinsics.txt | 32 ---- 7 files changed, 288 insertions(+), 96 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/loongarch64/lasx/generated.rs b/library/stdarch/crates/core_arch/src/loongarch64/lasx/generated.rs index cfc4aced34173..70560f8b5a68d 100644 --- a/library/stdarch/crates/core_arch/src/loongarch64/lasx/generated.rs +++ b/library/stdarch/crates/core_arch/src/loongarch64/lasx/generated.rs @@ -91,6 +91,22 @@ unsafe extern "llvm-intrinsic" { fn __lasx_xvsat_wu(a: __v8u32, b: u32) -> __v8u32; #[link_name = "llvm.loongarch.lasx.xvsat.du"] fn __lasx_xvsat_du(a: __v4u64, b: u32) -> __v4u64; + #[link_name = "llvm.loongarch.lasx.xvdiv.b"] + fn __lasx_xvdiv_b(a: __v32i8, b: __v32i8) -> __v32i8; + #[link_name = "llvm.loongarch.lasx.xvdiv.h"] + fn __lasx_xvdiv_h(a: __v16i16, b: __v16i16) -> __v16i16; + #[link_name = "llvm.loongarch.lasx.xvdiv.w"] + fn __lasx_xvdiv_w(a: __v8i32, b: __v8i32) -> __v8i32; + #[link_name = "llvm.loongarch.lasx.xvdiv.d"] + fn __lasx_xvdiv_d(a: __v4i64, b: __v4i64) -> __v4i64; + #[link_name = "llvm.loongarch.lasx.xvdiv.bu"] + fn __lasx_xvdiv_bu(a: __v32u8, b: __v32u8) -> __v32u8; + #[link_name = "llvm.loongarch.lasx.xvdiv.hu"] + fn __lasx_xvdiv_hu(a: __v16u16, b: __v16u16) -> __v16u16; + #[link_name = "llvm.loongarch.lasx.xvdiv.wu"] + fn __lasx_xvdiv_wu(a: __v8u32, b: __v8u32) -> __v8u32; + #[link_name = "llvm.loongarch.lasx.xvdiv.du"] + fn __lasx_xvdiv_du(a: __v4u64, b: __v4u64) -> __v4u64; #[link_name = "llvm.loongarch.lasx.xvhaddw.h.b"] fn __lasx_xvhaddw_h_b(a: __v32i8, b: __v32i8) -> __v16i16; #[link_name = "llvm.loongarch.lasx.xvhaddw.w.h"] @@ -115,6 +131,22 @@ unsafe extern "llvm-intrinsic" { fn __lasx_xvhsubw_wu_hu(a: __v16u16, b: __v16u16) -> __v8i32; #[link_name = "llvm.loongarch.lasx.xvhsubw.du.wu"] fn __lasx_xvhsubw_du_wu(a: __v8u32, b: __v8u32) -> __v4i64; + #[link_name = "llvm.loongarch.lasx.xvmod.b"] + fn __lasx_xvmod_b(a: __v32i8, b: __v32i8) -> __v32i8; + #[link_name = "llvm.loongarch.lasx.xvmod.h"] + fn __lasx_xvmod_h(a: __v16i16, b: __v16i16) -> __v16i16; + #[link_name = "llvm.loongarch.lasx.xvmod.w"] + fn __lasx_xvmod_w(a: __v8i32, b: __v8i32) -> __v8i32; + #[link_name = "llvm.loongarch.lasx.xvmod.d"] + fn __lasx_xvmod_d(a: __v4i64, b: __v4i64) -> __v4i64; + #[link_name = "llvm.loongarch.lasx.xvmod.bu"] + fn __lasx_xvmod_bu(a: __v32u8, b: __v32u8) -> __v32u8; + #[link_name = "llvm.loongarch.lasx.xvmod.hu"] + fn __lasx_xvmod_hu(a: __v16u16, b: __v16u16) -> __v16u16; + #[link_name = "llvm.loongarch.lasx.xvmod.wu"] + fn __lasx_xvmod_wu(a: __v8u32, b: __v8u32) -> __v8u32; + #[link_name = "llvm.loongarch.lasx.xvmod.du"] + fn __lasx_xvmod_du(a: __v4u64, b: __v4u64) -> __v4u64; #[link_name = "llvm.loongarch.lasx.xvshuf.b"] fn __lasx_xvshuf_b(a: __v32i8, b: __v32i8, c: __v32i8) -> __v32i8; #[link_name = "llvm.loongarch.lasx.xvshuf.h"] @@ -1251,6 +1283,62 @@ pub fn lasx_xvsat_du(a: m256i) -> m256i { unsafe { transmute(__lasx_xvsat_du(transmute(a), IMM6)) } } +#[inline] +#[target_feature(enable = "lasx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lasx_xvdiv_b(a: m256i, b: m256i) -> m256i { + unsafe { transmute(__lasx_xvdiv_b(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lasx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lasx_xvdiv_h(a: m256i, b: m256i) -> m256i { + unsafe { transmute(__lasx_xvdiv_h(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lasx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lasx_xvdiv_w(a: m256i, b: m256i) -> m256i { + unsafe { transmute(__lasx_xvdiv_w(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lasx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lasx_xvdiv_d(a: m256i, b: m256i) -> m256i { + unsafe { transmute(__lasx_xvdiv_d(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lasx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lasx_xvdiv_bu(a: m256i, b: m256i) -> m256i { + unsafe { transmute(__lasx_xvdiv_bu(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lasx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lasx_xvdiv_hu(a: m256i, b: m256i) -> m256i { + unsafe { transmute(__lasx_xvdiv_hu(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lasx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lasx_xvdiv_wu(a: m256i, b: m256i) -> m256i { + unsafe { transmute(__lasx_xvdiv_wu(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lasx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lasx_xvdiv_du(a: m256i, b: m256i) -> m256i { + unsafe { transmute(__lasx_xvdiv_du(transmute(a), transmute(b))) } +} + #[inline] #[target_feature(enable = "lasx")] #[unstable(feature = "stdarch_loongarch", issue = "117427")] @@ -1335,6 +1423,62 @@ pub fn lasx_xvhsubw_du_wu(a: m256i, b: m256i) -> m256i { unsafe { transmute(__lasx_xvhsubw_du_wu(transmute(a), transmute(b))) } } +#[inline] +#[target_feature(enable = "lasx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lasx_xvmod_b(a: m256i, b: m256i) -> m256i { + unsafe { transmute(__lasx_xvmod_b(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lasx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lasx_xvmod_h(a: m256i, b: m256i) -> m256i { + unsafe { transmute(__lasx_xvmod_h(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lasx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lasx_xvmod_w(a: m256i, b: m256i) -> m256i { + unsafe { transmute(__lasx_xvmod_w(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lasx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lasx_xvmod_d(a: m256i, b: m256i) -> m256i { + unsafe { transmute(__lasx_xvmod_d(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lasx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lasx_xvmod_bu(a: m256i, b: m256i) -> m256i { + unsafe { transmute(__lasx_xvmod_bu(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lasx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lasx_xvmod_hu(a: m256i, b: m256i) -> m256i { + unsafe { transmute(__lasx_xvmod_hu(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lasx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lasx_xvmod_wu(a: m256i, b: m256i) -> m256i { + unsafe { transmute(__lasx_xvmod_wu(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lasx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lasx_xvmod_du(a: m256i, b: m256i) -> m256i { + unsafe { transmute(__lasx_xvmod_du(transmute(a), transmute(b))) } +} + #[inline] #[target_feature(enable = "lasx")] #[unstable(feature = "stdarch_loongarch", issue = "117427")] diff --git a/library/stdarch/crates/core_arch/src/loongarch64/lasx/portable.rs b/library/stdarch/crates/core_arch/src/loongarch64/lasx/portable.rs index d53f21c792626..fe45ed6543dfb 100644 --- a/library/stdarch/crates/core_arch/src/loongarch64/lasx/portable.rs +++ b/library/stdarch/crates/core_arch/src/loongarch64/lasx/portable.rs @@ -681,22 +681,6 @@ impl_vvv!("lasx", lasx_xvmul_b, simd_mul, m256i, i8x32); impl_vvv!("lasx", lasx_xvmul_h, simd_mul, m256i, i16x16); impl_vvv!("lasx", lasx_xvmul_w, simd_mul, m256i, i32x8); impl_vvv!("lasx", lasx_xvmul_d, simd_mul, m256i, i64x4); -impl_vvv!("lasx", lasx_xvdiv_b, simd_div, m256i, i8x32); -impl_vvv!("lasx", lasx_xvdiv_h, simd_div, m256i, i16x16); -impl_vvv!("lasx", lasx_xvdiv_w, simd_div, m256i, i32x8); -impl_vvv!("lasx", lasx_xvdiv_d, simd_div, m256i, i64x4); -impl_vvv!("lasx", lasx_xvdiv_bu, simd_div, m256i, u8x32); -impl_vvv!("lasx", lasx_xvdiv_hu, simd_div, m256i, u16x16); -impl_vvv!("lasx", lasx_xvdiv_wu, simd_div, m256i, u32x8); -impl_vvv!("lasx", lasx_xvdiv_du, simd_div, m256i, u64x4); -impl_vvv!("lasx", lasx_xvmod_b, simd_rem, m256i, i8x32); -impl_vvv!("lasx", lasx_xvmod_h, simd_rem, m256i, i16x16); -impl_vvv!("lasx", lasx_xvmod_w, simd_rem, m256i, i32x8); -impl_vvv!("lasx", lasx_xvmod_d, simd_rem, m256i, i64x4); -impl_vvv!("lasx", lasx_xvmod_bu, simd_rem, m256i, u8x32); -impl_vvv!("lasx", lasx_xvmod_hu, simd_rem, m256i, u16x16); -impl_vvv!("lasx", lasx_xvmod_wu, simd_rem, m256i, u32x8); -impl_vvv!("lasx", lasx_xvmod_du, simd_rem, m256i, u64x4); impl_vvv!("lasx", lasx_xvand_v, simd_and, m256i, u8x32); impl_vvv!("lasx", lasx_xvandn_v, simd_ext_andn, m256i, u8x32); impl_vvv!("lasx", lasx_xvor_v, simd_or, m256i, u8x32); diff --git a/library/stdarch/crates/core_arch/src/loongarch64/lsx/generated.rs b/library/stdarch/crates/core_arch/src/loongarch64/lsx/generated.rs index aa4e31ce8da6c..601b40467c6b2 100644 --- a/library/stdarch/crates/core_arch/src/loongarch64/lsx/generated.rs +++ b/library/stdarch/crates/core_arch/src/loongarch64/lsx/generated.rs @@ -91,6 +91,22 @@ unsafe extern "llvm-intrinsic" { fn __lsx_vsat_wu(a: __v4u32, b: u32) -> __v4u32; #[link_name = "llvm.loongarch.lsx.vsat.du"] fn __lsx_vsat_du(a: __v2u64, b: u32) -> __v2u64; + #[link_name = "llvm.loongarch.lsx.vdiv.b"] + fn __lsx_vdiv_b(a: __v16i8, b: __v16i8) -> __v16i8; + #[link_name = "llvm.loongarch.lsx.vdiv.h"] + fn __lsx_vdiv_h(a: __v8i16, b: __v8i16) -> __v8i16; + #[link_name = "llvm.loongarch.lsx.vdiv.w"] + fn __lsx_vdiv_w(a: __v4i32, b: __v4i32) -> __v4i32; + #[link_name = "llvm.loongarch.lsx.vdiv.d"] + fn __lsx_vdiv_d(a: __v2i64, b: __v2i64) -> __v2i64; + #[link_name = "llvm.loongarch.lsx.vdiv.bu"] + fn __lsx_vdiv_bu(a: __v16u8, b: __v16u8) -> __v16u8; + #[link_name = "llvm.loongarch.lsx.vdiv.hu"] + fn __lsx_vdiv_hu(a: __v8u16, b: __v8u16) -> __v8u16; + #[link_name = "llvm.loongarch.lsx.vdiv.wu"] + fn __lsx_vdiv_wu(a: __v4u32, b: __v4u32) -> __v4u32; + #[link_name = "llvm.loongarch.lsx.vdiv.du"] + fn __lsx_vdiv_du(a: __v2u64, b: __v2u64) -> __v2u64; #[link_name = "llvm.loongarch.lsx.vhaddw.h.b"] fn __lsx_vhaddw_h_b(a: __v16i8, b: __v16i8) -> __v8i16; #[link_name = "llvm.loongarch.lsx.vhaddw.w.h"] @@ -115,6 +131,22 @@ unsafe extern "llvm-intrinsic" { fn __lsx_vhsubw_wu_hu(a: __v8u16, b: __v8u16) -> __v4i32; #[link_name = "llvm.loongarch.lsx.vhsubw.du.wu"] fn __lsx_vhsubw_du_wu(a: __v4u32, b: __v4u32) -> __v2i64; + #[link_name = "llvm.loongarch.lsx.vmod.b"] + fn __lsx_vmod_b(a: __v16i8, b: __v16i8) -> __v16i8; + #[link_name = "llvm.loongarch.lsx.vmod.h"] + fn __lsx_vmod_h(a: __v8i16, b: __v8i16) -> __v8i16; + #[link_name = "llvm.loongarch.lsx.vmod.w"] + fn __lsx_vmod_w(a: __v4i32, b: __v4i32) -> __v4i32; + #[link_name = "llvm.loongarch.lsx.vmod.d"] + fn __lsx_vmod_d(a: __v2i64, b: __v2i64) -> __v2i64; + #[link_name = "llvm.loongarch.lsx.vmod.bu"] + fn __lsx_vmod_bu(a: __v16u8, b: __v16u8) -> __v16u8; + #[link_name = "llvm.loongarch.lsx.vmod.hu"] + fn __lsx_vmod_hu(a: __v8u16, b: __v8u16) -> __v8u16; + #[link_name = "llvm.loongarch.lsx.vmod.wu"] + fn __lsx_vmod_wu(a: __v4u32, b: __v4u32) -> __v4u32; + #[link_name = "llvm.loongarch.lsx.vmod.du"] + fn __lsx_vmod_du(a: __v2u64, b: __v2u64) -> __v2u64; #[link_name = "llvm.loongarch.lsx.vreplve.b"] fn __lsx_vreplve_b(a: __v16i8, b: i32) -> __v16i8; #[link_name = "llvm.loongarch.lsx.vreplve.h"] @@ -1171,6 +1203,62 @@ pub fn lsx_vsat_du(a: m128i) -> m128i { unsafe { transmute(__lsx_vsat_du(transmute(a), IMM6)) } } +#[inline] +#[target_feature(enable = "lsx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lsx_vdiv_b(a: m128i, b: m128i) -> m128i { + unsafe { transmute(__lsx_vdiv_b(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lsx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lsx_vdiv_h(a: m128i, b: m128i) -> m128i { + unsafe { transmute(__lsx_vdiv_h(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lsx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lsx_vdiv_w(a: m128i, b: m128i) -> m128i { + unsafe { transmute(__lsx_vdiv_w(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lsx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lsx_vdiv_d(a: m128i, b: m128i) -> m128i { + unsafe { transmute(__lsx_vdiv_d(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lsx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lsx_vdiv_bu(a: m128i, b: m128i) -> m128i { + unsafe { transmute(__lsx_vdiv_bu(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lsx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lsx_vdiv_hu(a: m128i, b: m128i) -> m128i { + unsafe { transmute(__lsx_vdiv_hu(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lsx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lsx_vdiv_wu(a: m128i, b: m128i) -> m128i { + unsafe { transmute(__lsx_vdiv_wu(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lsx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lsx_vdiv_du(a: m128i, b: m128i) -> m128i { + unsafe { transmute(__lsx_vdiv_du(transmute(a), transmute(b))) } +} + #[inline] #[target_feature(enable = "lsx")] #[unstable(feature = "stdarch_loongarch", issue = "117427")] @@ -1255,6 +1343,62 @@ pub fn lsx_vhsubw_du_wu(a: m128i, b: m128i) -> m128i { unsafe { transmute(__lsx_vhsubw_du_wu(transmute(a), transmute(b))) } } +#[inline] +#[target_feature(enable = "lsx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lsx_vmod_b(a: m128i, b: m128i) -> m128i { + unsafe { transmute(__lsx_vmod_b(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lsx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lsx_vmod_h(a: m128i, b: m128i) -> m128i { + unsafe { transmute(__lsx_vmod_h(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lsx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lsx_vmod_w(a: m128i, b: m128i) -> m128i { + unsafe { transmute(__lsx_vmod_w(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lsx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lsx_vmod_d(a: m128i, b: m128i) -> m128i { + unsafe { transmute(__lsx_vmod_d(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lsx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lsx_vmod_bu(a: m128i, b: m128i) -> m128i { + unsafe { transmute(__lsx_vmod_bu(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lsx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lsx_vmod_hu(a: m128i, b: m128i) -> m128i { + unsafe { transmute(__lsx_vmod_hu(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lsx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lsx_vmod_wu(a: m128i, b: m128i) -> m128i { + unsafe { transmute(__lsx_vmod_wu(transmute(a), transmute(b))) } +} + +#[inline] +#[target_feature(enable = "lsx")] +#[unstable(feature = "stdarch_loongarch", issue = "117427")] +pub fn lsx_vmod_du(a: m128i, b: m128i) -> m128i { + unsafe { transmute(__lsx_vmod_du(transmute(a), transmute(b))) } +} + #[inline] #[target_feature(enable = "lsx")] #[unstable(feature = "stdarch_loongarch", issue = "117427")] diff --git a/library/stdarch/crates/core_arch/src/loongarch64/lsx/portable.rs b/library/stdarch/crates/core_arch/src/loongarch64/lsx/portable.rs index 2b5bfe1ab4d2b..f2b86dae00af8 100644 --- a/library/stdarch/crates/core_arch/src/loongarch64/lsx/portable.rs +++ b/library/stdarch/crates/core_arch/src/loongarch64/lsx/portable.rs @@ -351,22 +351,6 @@ impl_vvv!("lsx", lsx_vmul_b, simd_mul, m128i, i8x16); impl_vvv!("lsx", lsx_vmul_h, simd_mul, m128i, i16x8); impl_vvv!("lsx", lsx_vmul_w, simd_mul, m128i, i32x4); impl_vvv!("lsx", lsx_vmul_d, simd_mul, m128i, i64x2); -impl_vvv!("lsx", lsx_vdiv_b, simd_div, m128i, i8x16); -impl_vvv!("lsx", lsx_vdiv_h, simd_div, m128i, i16x8); -impl_vvv!("lsx", lsx_vdiv_w, simd_div, m128i, i32x4); -impl_vvv!("lsx", lsx_vdiv_d, simd_div, m128i, i64x2); -impl_vvv!("lsx", lsx_vdiv_bu, simd_div, m128i, u8x16); -impl_vvv!("lsx", lsx_vdiv_hu, simd_div, m128i, u16x8); -impl_vvv!("lsx", lsx_vdiv_wu, simd_div, m128i, u32x4); -impl_vvv!("lsx", lsx_vdiv_du, simd_div, m128i, u64x2); -impl_vvv!("lsx", lsx_vmod_b, simd_rem, m128i, i8x16); -impl_vvv!("lsx", lsx_vmod_h, simd_rem, m128i, i16x8); -impl_vvv!("lsx", lsx_vmod_w, simd_rem, m128i, i32x4); -impl_vvv!("lsx", lsx_vmod_d, simd_rem, m128i, i64x2); -impl_vvv!("lsx", lsx_vmod_bu, simd_rem, m128i, u8x16); -impl_vvv!("lsx", lsx_vmod_hu, simd_rem, m128i, u16x8); -impl_vvv!("lsx", lsx_vmod_wu, simd_rem, m128i, u32x4); -impl_vvv!("lsx", lsx_vmod_du, simd_rem, m128i, u64x2); impl_vvv!("lsx", lsx_vand_v, simd_and, m128i, u8x16); impl_vvv!("lsx", lsx_vandn_v, simd_ext_andn, m128i, u8x16); impl_vvv!("lsx", lsx_vor_v, simd_or, m128i, u8x16); diff --git a/library/stdarch/crates/stdarch-gen-loongarch/lasx.spec b/library/stdarch/crates/stdarch-gen-loongarch/lasx.spec index eb3ff074a3978..63895945948f8 100644 --- a/library/stdarch/crates/stdarch-gen-loongarch/lasx.spec +++ b/library/stdarch/crates/stdarch-gen-loongarch/lasx.spec @@ -1260,49 +1260,41 @@ asm-fmts = xd, xj, xk data-types = V4DI, V4DI, V4DI, V4DI /// lasx_xvdiv_b -impl = portable name = lasx_xvdiv_b asm-fmts = xd, xj, xk data-types = V32QI, V32QI, V32QI /// lasx_xvdiv_h -impl = portable name = lasx_xvdiv_h asm-fmts = xd, xj, xk data-types = V16HI, V16HI, V16HI /// lasx_xvdiv_w -impl = portable name = lasx_xvdiv_w asm-fmts = xd, xj, xk data-types = V8SI, V8SI, V8SI /// lasx_xvdiv_d -impl = portable name = lasx_xvdiv_d asm-fmts = xd, xj, xk data-types = V4DI, V4DI, V4DI /// lasx_xvdiv_bu -impl = portable name = lasx_xvdiv_bu asm-fmts = xd, xj, xk data-types = UV32QI, UV32QI, UV32QI /// lasx_xvdiv_hu -impl = portable name = lasx_xvdiv_hu asm-fmts = xd, xj, xk data-types = UV16HI, UV16HI, UV16HI /// lasx_xvdiv_wu -impl = portable name = lasx_xvdiv_wu asm-fmts = xd, xj, xk data-types = UV8SI, UV8SI, UV8SI /// lasx_xvdiv_du -impl = portable name = lasx_xvdiv_du asm-fmts = xd, xj, xk data-types = UV4DI, UV4DI, UV4DI @@ -1368,49 +1360,41 @@ asm-fmts = xd, xj, xk data-types = V4DI, UV8SI, UV8SI /// lasx_xvmod_b -impl = portable name = lasx_xvmod_b asm-fmts = xd, xj, xk data-types = V32QI, V32QI, V32QI /// lasx_xvmod_h -impl = portable name = lasx_xvmod_h asm-fmts = xd, xj, xk data-types = V16HI, V16HI, V16HI /// lasx_xvmod_w -impl = portable name = lasx_xvmod_w asm-fmts = xd, xj, xk data-types = V8SI, V8SI, V8SI /// lasx_xvmod_d -impl = portable name = lasx_xvmod_d asm-fmts = xd, xj, xk data-types = V4DI, V4DI, V4DI /// lasx_xvmod_bu -impl = portable name = lasx_xvmod_bu asm-fmts = xd, xj, xk data-types = UV32QI, UV32QI, UV32QI /// lasx_xvmod_hu -impl = portable name = lasx_xvmod_hu asm-fmts = xd, xj, xk data-types = UV16HI, UV16HI, UV16HI /// lasx_xvmod_wu -impl = portable name = lasx_xvmod_wu asm-fmts = xd, xj, xk data-types = UV8SI, UV8SI, UV8SI /// lasx_xvmod_du -impl = portable name = lasx_xvmod_du asm-fmts = xd, xj, xk data-types = UV4DI, UV4DI, UV4DI diff --git a/library/stdarch/crates/stdarch-gen-loongarch/lsx.spec b/library/stdarch/crates/stdarch-gen-loongarch/lsx.spec index 89970c3657048..e1fb72c7901c9 100644 --- a/library/stdarch/crates/stdarch-gen-loongarch/lsx.spec +++ b/library/stdarch/crates/stdarch-gen-loongarch/lsx.spec @@ -1260,49 +1260,41 @@ asm-fmts = vd, vj, vk data-types = V2DI, V2DI, V2DI, V2DI /// lsx_vdiv_b -impl = portable name = lsx_vdiv_b asm-fmts = vd, vj, vk data-types = V16QI, V16QI, V16QI /// lsx_vdiv_h -impl = portable name = lsx_vdiv_h asm-fmts = vd, vj, vk data-types = V8HI, V8HI, V8HI /// lsx_vdiv_w -impl = portable name = lsx_vdiv_w asm-fmts = vd, vj, vk data-types = V4SI, V4SI, V4SI /// lsx_vdiv_d -impl = portable name = lsx_vdiv_d asm-fmts = vd, vj, vk data-types = V2DI, V2DI, V2DI /// lsx_vdiv_bu -impl = portable name = lsx_vdiv_bu asm-fmts = vd, vj, vk data-types = UV16QI, UV16QI, UV16QI /// lsx_vdiv_hu -impl = portable name = lsx_vdiv_hu asm-fmts = vd, vj, vk data-types = UV8HI, UV8HI, UV8HI /// lsx_vdiv_wu -impl = portable name = lsx_vdiv_wu asm-fmts = vd, vj, vk data-types = UV4SI, UV4SI, UV4SI /// lsx_vdiv_du -impl = portable name = lsx_vdiv_du asm-fmts = vd, vj, vk data-types = UV2DI, UV2DI, UV2DI @@ -1368,49 +1360,41 @@ asm-fmts = vd, vj, vk data-types = V2DI, UV4SI, UV4SI /// lsx_vmod_b -impl = portable name = lsx_vmod_b asm-fmts = vd, vj, vk data-types = V16QI, V16QI, V16QI /// lsx_vmod_h -impl = portable name = lsx_vmod_h asm-fmts = vd, vj, vk data-types = V8HI, V8HI, V8HI /// lsx_vmod_w -impl = portable name = lsx_vmod_w asm-fmts = vd, vj, vk data-types = V4SI, V4SI, V4SI /// lsx_vmod_d -impl = portable name = lsx_vmod_d asm-fmts = vd, vj, vk data-types = V2DI, V2DI, V2DI /// lsx_vmod_bu -impl = portable name = lsx_vmod_bu asm-fmts = vd, vj, vk data-types = UV16QI, UV16QI, UV16QI /// lsx_vmod_hu -impl = portable name = lsx_vmod_hu asm-fmts = vd, vj, vk data-types = UV8HI, UV8HI, UV8HI /// lsx_vmod_wu -impl = portable name = lsx_vmod_wu asm-fmts = vd, vj, vk data-types = UV4SI, UV4SI, UV4SI /// lsx_vmod_du -impl = portable name = lsx_vmod_du asm-fmts = vd, vj, vk data-types = UV2DI, UV2DI, UV2DI diff --git a/library/stdarch/crates/stdarch-gen-loongarch/src/portable-intrinsics.txt b/library/stdarch/crates/stdarch-gen-loongarch/src/portable-intrinsics.txt index f47c17b23adea..4005385b75198 100644 --- a/library/stdarch/crates/stdarch-gen-loongarch/src/portable-intrinsics.txt +++ b/library/stdarch/crates/stdarch-gen-loongarch/src/portable-intrinsics.txt @@ -111,22 +111,6 @@ lsx_vmul_b lsx_vmul_h lsx_vmul_w lsx_vmul_d -lsx_vdiv_b -lsx_vdiv_h -lsx_vdiv_w -lsx_vdiv_d -lsx_vdiv_bu -lsx_vdiv_hu -lsx_vdiv_wu -lsx_vdiv_du -lsx_vmod_b -lsx_vmod_h -lsx_vmod_w -lsx_vmod_d -lsx_vmod_bu -lsx_vmod_hu -lsx_vmod_wu -lsx_vmod_du lsx_vmadd_b lsx_vmadd_h lsx_vmadd_w @@ -426,22 +410,6 @@ lasx_xvmul_b lasx_xvmul_h lasx_xvmul_w lasx_xvmul_d -lasx_xvdiv_b -lasx_xvdiv_h -lasx_xvdiv_w -lasx_xvdiv_d -lasx_xvdiv_bu -lasx_xvdiv_hu -lasx_xvdiv_wu -lasx_xvdiv_du -lasx_xvmod_b -lasx_xvmod_h -lasx_xvmod_w -lasx_xvmod_d -lasx_xvmod_bu -lasx_xvmod_hu -lasx_xvmod_wu -lasx_xvmod_du lasx_xvmadd_b lasx_xvmadd_h lasx_xvmadd_w From 84ed32a32588de2398d21737ee9e4544c82c0698 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 29 Sep 2026 08:27:32 +0200 Subject: [PATCH 06/27] Revert "Reimplement _mm_avg_epu8, _mm_avg_epu16, _mm256_avg_epu8 and _mm256_avg_epu16 without LLVM intrinsics" This reverts commit 87e6703ba1a2c44d27f9e4f55dfcf145bca2834a. --- .../stdarch/crates/core_arch/src/x86/avx2.rs | 28 +++++-------- .../crates/core_arch/src/x86/avx512bw.rs | 40 ++++++++----------- .../stdarch/crates/core_arch/src/x86/sse2.rs | 28 +++++-------- 3 files changed, 36 insertions(+), 60 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx2.rs b/library/stdarch/crates/core_arch/src/x86/avx2.rs index 56dacd1f0970c..168871188868b 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx2.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx2.rs @@ -290,14 +290,8 @@ pub const fn _mm256_andnot_si256(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpavgw))] #[stable(feature = "simd_x86", since = "1.27.0")] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm256_avg_epu16(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = simd_cast::<_, u32x16>(a.as_u16x16()); - let b = simd_cast::<_, u32x16>(b.as_u16x16()); - let r = simd_shr(simd_add(simd_add(a, b), u32x16::splat(1)), u32x16::splat(1)); - transmute(simd_cast::<_, u16x16>(r)) - } +pub fn _mm256_avg_epu16(a: __m256i, b: __m256i) -> __m256i { + unsafe { transmute(pavgw(a.as_u16x16(), b.as_u16x16())) } } /// Averages packed unsigned 8-bit integers in `a` and `b`. @@ -307,14 +301,8 @@ pub const fn _mm256_avg_epu16(a: __m256i, b: __m256i) -> __m256i { #[target_feature(enable = "avx2")] #[cfg_attr(test, assert_instr(vpavgb))] #[stable(feature = "simd_x86", since = "1.27.0")] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm256_avg_epu8(a: __m256i, b: __m256i) -> __m256i { - unsafe { - let a = simd_cast::<_, u16x32>(a.as_u8x32()); - let b = simd_cast::<_, u16x32>(b.as_u8x32()); - let r = simd_shr(simd_add(simd_add(a, b), u16x32::splat(1)), u16x32::splat(1)); - transmute(simd_cast::<_, u8x32>(r)) - } +pub fn _mm256_avg_epu8(a: __m256i, b: __m256i) -> __m256i { + unsafe { transmute(pavgb(a.as_u8x32(), b.as_u8x32())) } } /// Blends packed 32-bit integers from `a` and `b` using control mask `IMM4`. @@ -3747,6 +3735,10 @@ pub const fn _mm256_extract_epi16(a: __m256i) -> i32 { #[allow(improper_ctypes)] unsafe extern "llvm-intrinsic" { + #[link_name = "llvm.x86.avx2.pavg.b"] + fn pavgb(a: u8x32, b: u8x32) -> u8x32; + #[link_name = "llvm.x86.avx2.pavg.w"] + fn pavgw(a: u16x16, b: u16x16) -> u16x16; #[link_name = "llvm.x86.avx2.pmadd.wd"] fn pmaddwd(a: i16x16, b: i16x16) -> i32x8; #[link_name = "llvm.x86.avx2.pmadd.ub.sw"] @@ -4178,14 +4170,14 @@ mod tests { } #[simd_test(enable = "avx2")] - const fn test_mm256_avg_epu8() { + fn test_mm256_avg_epu8() { let (a, b) = (_mm256_set1_epi8(3), _mm256_set1_epi8(9)); let r = _mm256_avg_epu8(a, b); assert_eq_m256i(r, _mm256_set1_epi8(6)); } #[simd_test(enable = "avx2")] - const fn test_mm256_avg_epu16() { + fn test_mm256_avg_epu16() { let (a, b) = (_mm256_set1_epi16(3), _mm256_set1_epi16(9)); let r = _mm256_avg_epu16(a, b); assert_eq_m256i(r, _mm256_set1_epi16(6)); diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs index 46aeaaadbfe33..1d91ccfc0785d 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs @@ -6906,8 +6906,7 @@ pub const fn _mm512_maskz_avg_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm256_mask_avg_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +pub fn _mm256_mask_avg_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let avg = _mm256_avg_epu16(a, b).as_u16x16(); transmute(simd_select_bitmask(k, avg, src.as_u16x16())) @@ -6921,8 +6920,7 @@ pub const fn _mm256_mask_avg_epu16(src: __m256i, k: __mmask16, a: __m256i, b: __ #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm256_maskz_avg_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { +pub fn _mm256_maskz_avg_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m256i { unsafe { let avg = _mm256_avg_epu16(a, b).as_u16x16(); transmute(simd_select_bitmask(k, avg, u16x16::ZERO)) @@ -6936,8 +6934,7 @@ pub const fn _mm256_maskz_avg_epu16(k: __mmask16, a: __m256i, b: __m256i) -> __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm_mask_avg_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +pub fn _mm_mask_avg_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let avg = _mm_avg_epu16(a, b).as_u16x8(); transmute(simd_select_bitmask(k, avg, src.as_u16x8())) @@ -6951,8 +6948,7 @@ pub const fn _mm_mask_avg_epu16(src: __m128i, k: __mmask8, a: __m128i, b: __m128 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm_maskz_avg_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { +pub fn _mm_maskz_avg_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { unsafe { let avg = _mm_avg_epu16(a, b).as_u16x8(); transmute(simd_select_bitmask(k, avg, u16x8::ZERO)) @@ -7013,8 +7009,7 @@ pub const fn _mm512_maskz_avg_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m5 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgb))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm256_mask_avg_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +pub fn _mm256_mask_avg_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let avg = _mm256_avg_epu8(a, b).as_u8x32(); transmute(simd_select_bitmask(k, avg, src.as_u8x32())) @@ -7028,8 +7023,7 @@ pub const fn _mm256_mask_avg_epu8(src: __m256i, k: __mmask32, a: __m256i, b: __m #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgb))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm256_maskz_avg_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { +pub fn _mm256_maskz_avg_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i { unsafe { let avg = _mm256_avg_epu8(a, b).as_u8x32(); transmute(simd_select_bitmask(k, avg, u8x32::ZERO)) @@ -7043,8 +7037,7 @@ pub const fn _mm256_maskz_avg_epu8(k: __mmask32, a: __m256i, b: __m256i) -> __m2 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgb))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm_mask_avg_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +pub fn _mm_mask_avg_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let avg = _mm_avg_epu8(a, b).as_u8x16(); transmute(simd_select_bitmask(k, avg, src.as_u8x16())) @@ -7058,8 +7051,7 @@ pub const fn _mm_mask_avg_epu8(src: __m128i, k: __mmask16, a: __m128i, b: __m128 #[target_feature(enable = "avx512bw,avx512vl")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgb))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm_maskz_avg_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { +pub fn _mm_maskz_avg_epu8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { unsafe { let avg = _mm_avg_epu8(a, b).as_u8x16(); transmute(simd_select_bitmask(k, avg, u8x16::ZERO)) @@ -17983,7 +17975,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - const fn test_mm256_mask_avg_epu16() { + fn test_mm256_mask_avg_epu16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let r = _mm256_mask_avg_epu16(a, 0, a, b); @@ -17994,7 +17986,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - const fn test_mm256_maskz_avg_epu16() { + fn test_mm256_maskz_avg_epu16() { let a = _mm256_set1_epi16(1); let b = _mm256_set1_epi16(1); let r = _mm256_maskz_avg_epu16(0, a, b); @@ -18005,7 +17997,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - const fn test_mm_mask_avg_epu16() { + fn test_mm_mask_avg_epu16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let r = _mm_mask_avg_epu16(a, 0, a, b); @@ -18016,7 +18008,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - const fn test_mm_maskz_avg_epu16() { + fn test_mm_maskz_avg_epu16() { let a = _mm_set1_epi16(1); let b = _mm_set1_epi16(1); let r = _mm_maskz_avg_epu16(0, a, b); @@ -18075,7 +18067,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - const fn test_mm256_mask_avg_epu8() { + fn test_mm256_mask_avg_epu8() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(1); let r = _mm256_mask_avg_epu8(a, 0, a, b); @@ -18088,7 +18080,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - const fn test_mm256_maskz_avg_epu8() { + fn test_mm256_maskz_avg_epu8() { let a = _mm256_set1_epi8(1); let b = _mm256_set1_epi8(1); let r = _mm256_maskz_avg_epu8(0, a, b); @@ -18101,7 +18093,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - const fn test_mm_mask_avg_epu8() { + fn test_mm_mask_avg_epu8() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(1); let r = _mm_mask_avg_epu8(a, 0, a, b); @@ -18112,7 +18104,7 @@ mod tests { } #[simd_test(enable = "avx512bw,avx512vl")] - const fn test_mm_maskz_avg_epu8() { + fn test_mm_maskz_avg_epu8() { let a = _mm_set1_epi8(1); let b = _mm_set1_epi8(1); let r = _mm_maskz_avg_epu8(0, a, b); diff --git a/library/stdarch/crates/core_arch/src/x86/sse2.rs b/library/stdarch/crates/core_arch/src/x86/sse2.rs index 4d5b23dc7225b..b52fce6765a00 100644 --- a/library/stdarch/crates/core_arch/src/x86/sse2.rs +++ b/library/stdarch/crates/core_arch/src/x86/sse2.rs @@ -178,14 +178,8 @@ pub const fn _mm_adds_epu16(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pavgb))] #[stable(feature = "simd_x86", since = "1.27.0")] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm_avg_epu8(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = simd_cast::<_, u16x16>(a.as_u8x16()); - let b = simd_cast::<_, u16x16>(b.as_u8x16()); - let r = simd_shr(simd_add(simd_add(a, b), u16x16::splat(1)), u16x16::splat(1)); - transmute(simd_cast::<_, u8x16>(r)) - } +pub fn _mm_avg_epu8(a: __m128i, b: __m128i) -> __m128i { + unsafe { transmute(pavgb(a.as_u8x16(), b.as_u8x16())) } } /// Averages packed unsigned 16-bit integers in `a` and `b`. @@ -195,14 +189,8 @@ pub const fn _mm_avg_epu8(a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "sse2")] #[cfg_attr(test, assert_instr(pavgw))] #[stable(feature = "simd_x86", since = "1.27.0")] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm_avg_epu16(a: __m128i, b: __m128i) -> __m128i { - unsafe { - let a = simd_cast::<_, u32x8>(a.as_u16x8()); - let b = simd_cast::<_, u32x8>(b.as_u16x8()); - let r = simd_shr(simd_add(simd_add(a, b), u32x8::splat(1)), u32x8::splat(1)); - transmute(simd_cast::<_, u16x8>(r)) - } +pub fn _mm_avg_epu16(a: __m128i, b: __m128i) -> __m128i { + unsafe { transmute(pavgw(a.as_u16x8(), b.as_u16x8())) } } /// Multiplies and then horizontally add signed 16 bit integers in `a` and `b`. @@ -3188,6 +3176,10 @@ unsafe extern "llvm-intrinsic" { fn lfence(); #[link_name = "llvm.x86.sse2.mfence"] fn mfence(); + #[link_name = "llvm.x86.sse2.pavg.b"] + fn pavgb(a: u8x16, b: u8x16) -> u8x16; + #[link_name = "llvm.x86.sse2.pavg.w"] + fn pavgw(a: u16x8, b: u16x8) -> u16x8; #[link_name = "llvm.x86.sse2.pmadd.wd"] fn pmaddwd(a: i16x8, b: i16x8) -> i32x4; #[link_name = "llvm.x86.sse2.pmulh.w"] @@ -3458,14 +3450,14 @@ mod tests { } #[simd_test(enable = "sse2")] - const fn test_mm_avg_epu8() { + fn test_mm_avg_epu8() { let (a, b) = (_mm_set1_epi8(3), _mm_set1_epi8(9)); let r = _mm_avg_epu8(a, b); assert_eq_m128i(r, _mm_set1_epi8(6)); } #[simd_test(enable = "sse2")] - const fn test_mm_avg_epu16() { + fn test_mm_avg_epu16() { let (a, b) = (_mm_set1_epi16(3), _mm_set1_epi16(9)); let r = _mm_avg_epu16(a, b); assert_eq_m128i(r, _mm_set1_epi16(6)); From 9bdda899160e34ccb7ac8a21845c11489b8bee4c Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 29 Sep 2026 08:39:26 +0200 Subject: [PATCH 07/27] also adjust AVX512 intrinsics --- .../crates/core_arch/src/x86/avx512bw.rs | 49 +++++++------------ 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs index 1d91ccfc0785d..bc119870fa99a 100644 --- a/library/stdarch/crates/core_arch/src/x86/avx512bw.rs +++ b/library/stdarch/crates/core_arch/src/x86/avx512bw.rs @@ -6859,14 +6859,8 @@ pub fn _mm_maskz_packus_epi16(k: __mmask16, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm512_avg_epu16(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = simd_cast::<_, u32x32>(a.as_u16x32()); - let b = simd_cast::<_, u32x32>(b.as_u16x32()); - let r = simd_shr(simd_add(simd_add(a, b), u32x32::splat(1)), u32x32::splat(1)); - transmute(simd_cast::<_, u16x32>(r)) - } +pub fn _mm512_avg_epu16(a: __m512i, b: __m512i) -> __m512i { + unsafe { transmute(vpavgw(a.as_u16x32(), b.as_u16x32())) } } /// Average packed unsigned 16-bit integers in a and b, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -6876,8 +6870,7 @@ pub const fn _mm512_avg_epu16(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm512_mask_avg_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +pub fn _mm512_mask_avg_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let avg = _mm512_avg_epu16(a, b).as_u16x32(); transmute(simd_select_bitmask(k, avg, src.as_u16x32())) @@ -6891,8 +6884,7 @@ pub const fn _mm512_mask_avg_epu16(src: __m512i, k: __mmask32, a: __m512i, b: __ #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgw))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm512_maskz_avg_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { +pub fn _mm512_maskz_avg_epu16(k: __mmask32, a: __m512i, b: __m512i) -> __m512i { unsafe { let avg = _mm512_avg_epu16(a, b).as_u16x32(); transmute(simd_select_bitmask(k, avg, u16x32::ZERO)) @@ -6962,14 +6954,8 @@ pub fn _mm_maskz_avg_epu16(k: __mmask8, a: __m128i, b: __m128i) -> __m128i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgb))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm512_avg_epu8(a: __m512i, b: __m512i) -> __m512i { - unsafe { - let a = simd_cast::<_, u16x64>(a.as_u8x64()); - let b = simd_cast::<_, u16x64>(b.as_u8x64()); - let r = simd_shr(simd_add(simd_add(a, b), u16x64::splat(1)), u16x64::splat(1)); - transmute(simd_cast::<_, u8x64>(r)) - } +pub fn _mm512_avg_epu8(a: __m512i, b: __m512i) -> __m512i { + unsafe { transmute(vpavgb(a.as_u8x64(), b.as_u8x64())) } } /// Average packed unsigned 8-bit integers in a and b, and store the results in dst using writemask k (elements are copied from src when the corresponding mask bit is not set). @@ -6979,8 +6965,7 @@ pub const fn _mm512_avg_epu8(a: __m512i, b: __m512i) -> __m512i { #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgb))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm512_mask_avg_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +pub fn _mm512_mask_avg_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let avg = _mm512_avg_epu8(a, b).as_u8x64(); transmute(simd_select_bitmask(k, avg, src.as_u8x64())) @@ -6994,8 +6979,7 @@ pub const fn _mm512_mask_avg_epu8(src: __m512i, k: __mmask64, a: __m512i, b: __m #[target_feature(enable = "avx512bw")] #[stable(feature = "stdarch_x86_avx512", since = "1.89")] #[cfg_attr(test, assert_instr(vpavgb))] -#[rustc_const_unstable(feature = "stdarch_const_x86", issue = "149298")] -pub const fn _mm512_maskz_avg_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { +pub fn _mm512_maskz_avg_epu8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i { unsafe { let avg = _mm512_avg_epu8(a, b).as_u8x64(); transmute(simd_select_bitmask(k, avg, u8x64::ZERO)) @@ -12534,6 +12518,11 @@ unsafe extern "llvm-intrinsic" { #[link_name = "llvm.x86.avx512.mask.pmovus.wb.mem.512"] fn vpmovuswbmem(mem_addr: *mut i8, a: i16x32, mask: u32); + + #[link_name = "llvm.x86.avx512.pavg.b.512"] + fn vpavgb(a: u8x64, b: u8x64) -> u8x64; + #[link_name = "llvm.x86.avx512.pavg.w.512"] + fn vpavgw(a: u16x32, b: u16x32) -> u16x32; } #[cfg(test)] @@ -17940,7 +17929,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - const fn test_mm512_avg_epu16() { + fn test_mm512_avg_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_avg_epu16(a, b); @@ -17949,7 +17938,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - const fn test_mm512_mask_avg_epu16() { + fn test_mm512_mask_avg_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_mask_avg_epu16(a, 0, a, b); @@ -17962,7 +17951,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - const fn test_mm512_maskz_avg_epu16() { + fn test_mm512_maskz_avg_epu16() { let a = _mm512_set1_epi16(1); let b = _mm512_set1_epi16(1); let r = _mm512_maskz_avg_epu16(0, a, b); @@ -18019,7 +18008,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - const fn test_mm512_avg_epu8() { + fn test_mm512_avg_epu8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(1); let r = _mm512_avg_epu8(a, b); @@ -18028,7 +18017,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - const fn test_mm512_mask_avg_epu8() { + fn test_mm512_mask_avg_epu8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(1); let r = _mm512_mask_avg_epu8(a, 0, a, b); @@ -18048,7 +18037,7 @@ mod tests { } #[simd_test(enable = "avx512bw")] - const fn test_mm512_maskz_avg_epu8() { + fn test_mm512_maskz_avg_epu8() { let a = _mm512_set1_epi8(1); let b = _mm512_set1_epi8(1); let r = _mm512_maskz_avg_epu8(0, a, b); From bd9f2cfc45cb219197ef083a41fb7d91478282a6 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Wed, 30 Sep 2026 21:34:34 +0200 Subject: [PATCH 08/27] Prepare for merging from rust-lang/rust This updates the rust-version file to 21b707e3f97e0b522ebd2f277a862339625ad83f. --- library/stdarch/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/stdarch/rust-version b/library/stdarch/rust-version index 368cecc0b82f9..e7e9921e4903b 100644 --- a/library/stdarch/rust-version +++ b/library/stdarch/rust-version @@ -1 +1 @@ -220b36c420c49c59923f54cd4a76634fac98a067 +21b707e3f97e0b522ebd2f277a862339625ad83f From 98af1795afb3634f91b4c310fa0d352a31367688 Mon Sep 17 00:00:00 2001 From: ltdk Date: Wed, 30 Sep 2026 10:07:35 -0400 Subject: [PATCH 09/27] Add libs-nominated triagebot config --- library/stdarch/triagebot.toml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/library/stdarch/triagebot.toml b/library/stdarch/triagebot.toml index 149646aa65f01..ea711630662a5 100644 --- a/library/stdarch/triagebot.toml +++ b/library/stdarch/triagebot.toml @@ -88,3 +88,13 @@ Thanks! # Documentation at: https://forge.rust-lang.org/triagebot/issue-links.html [issue-links] check-commits = false + +[notify-zulip."I-libs-nominated"] +zulip_stream = 639962 # #t-libs/nominated +topic = "stdarch#{number}: {title}" +message_on_add = """\ +@*T-libs-ping* [stdarch#{number} "{title}"](https://github.com/rust-lang/stdarch/pull/{number}) has been nominated for discussion. +""" +message_on_remove = """\ +stdarch#{number} is no longer nominated. +""" From 42f00d9d67cdfc17e72bfe22607b5cb85bc1c43e Mon Sep 17 00:00:00 2001 From: ltdk Date: Wed, 30 Sep 2026 19:08:22 -0400 Subject: [PATCH 10/27] Don't ping --- library/stdarch/triagebot.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/stdarch/triagebot.toml b/library/stdarch/triagebot.toml index ea711630662a5..45005bafad314 100644 --- a/library/stdarch/triagebot.toml +++ b/library/stdarch/triagebot.toml @@ -93,7 +93,7 @@ check-commits = false zulip_stream = 639962 # #t-libs/nominated topic = "stdarch#{number}: {title}" message_on_add = """\ -@*T-libs-ping* [stdarch#{number} "{title}"](https://github.com/rust-lang/stdarch/pull/{number}) has been nominated for discussion. +[stdarch#{number} "{title}"](https://github.com/rust-lang/stdarch/pull/{number}) has been nominated for discussion. """ message_on_remove = """\ stdarch#{number} is no longer nominated. From 5a396834f9186fdb999069a1a5b413bd008f5d36 Mon Sep 17 00:00:00 2001 From: Liber Date: Fri, 2 Oct 2026 09:47:57 +0800 Subject: [PATCH 11/27] Fix the nvptx f16x2 intrinsic annotations The add expectation reads add.rn.f16x22, which is no PTX instruction. LLVM's own NVPTX codegen test, llvm/test/CodeGen/NVPTX/f16x2-instructions.ll, expects add.rn.f16x2 for fadd <2 x half>, and the sub, mul, fma and neg expectations in this file already match what it emits. Nothing caught the typo because assert_instr never runs on nvptx: CI builds that target with NORUN=1 and NOSTD=1. The neg docs name __hmin2 and the fma docs name __fma2 and __fma2_rn. cuda_fp16.h (CUDA 12.4) declares __hneg2 and __hfma2, and none of the other three names exist; the fma link already resolved to __hfma2. --- library/stdarch/crates/core_arch/src/nvptx/packed.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/library/stdarch/crates/core_arch/src/nvptx/packed.rs b/library/stdarch/crates/core_arch/src/nvptx/packed.rs index 4933a601231f5..99220038e23a2 100644 --- a/library/stdarch/crates/core_arch/src/nvptx/packed.rs +++ b/library/stdarch/crates/core_arch/src/nvptx/packed.rs @@ -30,7 +30,7 @@ types! { /// - [`__hadd2`](https://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH____HALF2__ARITHMETIC.html#group__CUDA__MATH____HALF2__ARITHMETIC_1g921c795176eaa31265bd80ef4fe4b8e6) /// - [`__hadd2_rn`](https://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH____HALF2__ARITHMETIC.html#group__CUDA__MATH____HALF2__ARITHMETIC_1g6cd8ddb2c3d670e1a10c3eb2e7644f82) #[inline] -#[cfg_attr(test, assert_instr(add.rn.f16x22))] +#[cfg_attr(test, assert_instr(add.rn.f16x2))] #[unstable(feature = "stdarch_nvptx", issue = "111199")] pub unsafe fn f16x2_add(a: f16x2, b: f16x2) -> f16x2 { simd_add(a, b) @@ -68,9 +68,7 @@ pub unsafe fn f16x2_mul(a: f16x2, b: f16x2) -> f16x2 { /// /// /// -/// Corresponds to the CUDA C intrinsics: -/// - [`__fma2`](https://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH____HALF2__ARITHMETIC.html#group__CUDA__MATH____HALF2__ARITHMETIC_1g43628ba21ded8b1e188a367348008dab) -/// - [`__fma2_rn`](https://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH____HALF2__ARITHMETIC.html#group__CUDA__MATH____HALF2__ARITHMETIC_1g43628ba21ded8b1e188a367348008dab) +/// Corresponds to the CUDA C intrinsic [`__hfma2`](https://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH____HALF2__ARITHMETIC.html#group__CUDA__MATH____HALF2__ARITHMETIC_1g43628ba21ded8b1e188a367348008dab) #[inline] #[cfg_attr(test, assert_instr(fma.rn.f16x2))] #[unstable(feature = "stdarch_nvptx", issue = "111199")] @@ -82,7 +80,7 @@ pub unsafe fn f16x2_fma(a: f16x2, b: f16x2, c: f16x2) -> f16x2 { /// /// /// -/// Corresponds to the CUDA C intrinsic [`__hmin2`](https://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH____HALF2__COMPARISON.html#group__CUDA__MATH____HALF2__COMPARISON_1g9e17a33f96061804166f3fbd395422b6) +/// Corresponds to the CUDA C intrinsic [`__hneg2`](https://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH____HALF2__ARITHMETIC.html#group__CUDA__MATH____HALF2__ARITHMETIC_1g90e216094729014f541fa1e5a5aaeaf7) #[inline] #[cfg_attr(test, assert_instr(neg.f16x2))] #[unstable(feature = "stdarch_nvptx", issue = "111199")] From edcf15aabe2421eedd6dd1a01496b4a0de793069 Mon Sep 17 00:00:00 2001 From: The rustc-josh-sync Cronjob Bot Date: Mon, 5 Oct 2026 04:24:12 +0000 Subject: [PATCH 12/27] Prepare for merging from rust-lang/rust This updates the rust-version file to 260f1acad9d7f70b5b56a636a9dc5a7f76150417. --- library/stdarch/rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/stdarch/rust-version b/library/stdarch/rust-version index e7e9921e4903b..271b3a644cfb8 100644 --- a/library/stdarch/rust-version +++ b/library/stdarch/rust-version @@ -1 +1 @@ -21b707e3f97e0b522ebd2f277a862339625ad83f +260f1acad9d7f70b5b56a636a9dc5a7f76150417 From 6b36af2fde0dba320b1268953585b62e8cf75df9 Mon Sep 17 00:00:00 2001 From: hashcatHitman <155700084+hashcatHitman@users.noreply.github.com> Date: Wed, 7 Oct 2026 18:41:24 +0000 Subject: [PATCH 13/27] ci: Ignore `unpinned-uses` for `josh-sync/rustc-pull` See: https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/josh-sync.20pull.20workflow.20version.20pinning/near/629742031 Signed-off-by: hashcatHitman <155700084+hashcatHitman@users.noreply.github.com> --- library/stdarch/.github/workflows/rustc-pull.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/library/stdarch/.github/workflows/rustc-pull.yml b/library/stdarch/.github/workflows/rustc-pull.yml index d2feb1add6344..96cf9285ec10b 100644 --- a/library/stdarch/.github/workflows/rustc-pull.yml +++ b/library/stdarch/.github/workflows/rustc-pull.yml @@ -10,6 +10,7 @@ on: jobs: pull: if: github.repository == 'rust-lang/stdarch' + # zizmor: ignore[unpinned-uses] We explicitly want to track the main branch. uses: rust-lang/josh-sync/.github/workflows/rustc-pull.yml@main with: github-app-id: ${{ vars.APP_CLIENT_ID }} From 7345c38e9c0f4ab4e862ec778750a56cbf21598c Mon Sep 17 00:00:00 2001 From: hashcatHitman <155700084+hashcatHitman@users.noreply.github.com> Date: Wed, 7 Oct 2026 18:43:19 +0000 Subject: [PATCH 14/27] ci: Pin `actions/checkout` to 6.1.0 hash See: https://github.com/actions/checkout/releases/tag/v6.1.0 This is the same version we were already using as of writing this. Signed-off-by: hashcatHitman <155700084+hashcatHitman@users.noreply.github.com> --- library/stdarch/.github/workflows/main.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/library/stdarch/.github/workflows/main.yml b/library/stdarch/.github/workflows/main.yml index d7539fe2e8ebd..bf8ad2e293e7f 100644 --- a/library/stdarch/.github/workflows/main.yml +++ b/library/stdarch/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: name: Check Style runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - name: Install Rust run: rustup update nightly --no-self-update && rustup default nightly - run: ci/style.sh @@ -18,7 +18,7 @@ jobs: needs: [ style ] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - name: Install Rust run: rustup update nightly --no-self-update && rustup default nightly - run: ci/dox.sh @@ -30,7 +30,7 @@ jobs: needs: [ style ] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - name: Install Rust run: rustup update nightly --no-self-update && rustup default nightly - run: cargo test --manifest-path crates/stdarch-verify/Cargo.toml @@ -218,7 +218,7 @@ jobs: # build_std: true steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - name: Install Rust run: | rustup update nightly --no-self-update @@ -298,7 +298,7 @@ jobs: - target: armv7-unknown-linux-gnueabihf cc: gcc steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - name: Install Rust run: | rustup update nightly --no-self-update @@ -326,7 +326,7 @@ jobs: env: STDARCH_GEN_MODE: check steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - name: Install Rust run: rustup update nightly && rustup default nightly && rustup component add rustfmt - name: Check arm spec @@ -352,7 +352,7 @@ jobs: name: Run some tests with miri runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0 - name: Install Rust run: rustup update nightly && rustup default nightly && rustup component add miri - name: Run miri tests From 2f1130c1cb8da27034bfa449c439b817d5e89846 Mon Sep 17 00:00:00 2001 From: Sayantan Chakraborty <142906350+sayantn@users.noreply.github.com> Date: Tue, 13 Oct 2026 13:17:41 +0530 Subject: [PATCH 15/27] Remove myself from the review rotation --- library/stdarch/triagebot.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/stdarch/triagebot.toml b/library/stdarch/triagebot.toml index 45005bafad314..c4a4b02b0179e 100644 --- a/library/stdarch/triagebot.toml +++ b/library/stdarch/triagebot.toml @@ -33,7 +33,7 @@ allow-unauthenticated = [ [assign] [assign.owners] -"*" = ["@Amanieu", "@folkertdev", "@sayantn", "@davidtwco", "@adamgemmell"] +"*" = ["@Amanieu", "@folkertdev", "@davidtwco", "@adamgemmell"] [ping.windows] message = """\ From 8a61540bd67f6f1a21f061801ee3f7f34de9bebb Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 3 Oct 2026 10:51:36 +0200 Subject: [PATCH 16/27] breakpoint: more explicit guidance regarding SIGTRAP handling --- library/core/src/arch.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/core/src/arch.rs b/library/core/src/arch.rs index 04fc16f50085b..d6871690e710d 100644 --- a/library/core/src/arch.rs +++ b/library/core/src/arch.rs @@ -68,7 +68,11 @@ pub macro global_asm("assembly template", $(operands,)* $(options($(option),*))? /// The precise behavior is not guaranteed, it depends on the architecture and operating system. /// Not all architectures guarantee that a breakpoint instruction interrupts execution in the absence /// of a debugger, and not all operating systems and execution environments guarantee that such an -/// interrupt aborts the current process. +/// interrupt aborts the current process. On operating systems where the behavior of the interrupt +/// can be overwritten by the application (e.g. via a SIGTRAP signal handler), the application +/// *should* make sure to still abort the process, but we recommend not relying on that for +/// soundness unless you actually know for sure that the application running your code keeps the +/// default (or equivalent) behavior. /// /// The precise instruction is guaranteed only on the following targets: /// - On x86 targets, this produces an `int3` instruction. From 99af6957aa57ab0de65bdfddc47e84cdc04a40ab Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 14 Oct 2026 17:38:26 +0200 Subject: [PATCH 17/27] edits by Josh Co-authored-by: Josh Triplett --- library/core/src/arch.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/core/src/arch.rs b/library/core/src/arch.rs index d6871690e710d..92ff55ecc75c0 100644 --- a/library/core/src/arch.rs +++ b/library/core/src/arch.rs @@ -70,9 +70,10 @@ pub macro global_asm("assembly template", $(operands,)* $(options($(option),*))? /// of a debugger, and not all operating systems and execution environments guarantee that such an /// interrupt aborts the current process. On operating systems where the behavior of the interrupt /// can be overwritten by the application (e.g. via a SIGTRAP signal handler), the application -/// *should* make sure to still abort the process, but we recommend not relying on that for -/// soundness unless you actually know for sure that the application running your code keeps the -/// default (or equivalent) behavior. +/// *should* make sure to still abort the process. However, code not fully in control of that +/// application state (e.g. signal handlers) cannot always rely on that for soundness. +/// If you do rely on this, such that your code's soundness requires applications to not continue +/// from your breakpoints, please document that for your users. /// /// The precise instruction is guaranteed only on the following targets: /// - On x86 targets, this produces an `int3` instruction. From c7ea602b621fc26f34d44b2ec713c4787be9679d Mon Sep 17 00:00:00 2001 From: annieversary Date: Sat, 17 Oct 2026 23:23:40 +0200 Subject: [PATCH 18/27] add test for literals in lint attributes --- tests/ui/lint/lint-attribute-literals.rs | 7 +++++++ tests/ui/lint/lint-attribute-literals.stderr | 9 +++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/ui/lint/lint-attribute-literals.rs create mode 100644 tests/ui/lint/lint-attribute-literals.stderr diff --git a/tests/ui/lint/lint-attribute-literals.rs b/tests/ui/lint/lint-attribute-literals.rs new file mode 100644 index 0000000000000..6cbae8e1e9fcf --- /dev/null +++ b/tests/ui/lint/lint-attribute-literals.rs @@ -0,0 +1,7 @@ +// Checks that lint attributes with literals have an explanatory error + +//@ compile-flags: -Zdeduplicate-diagnostics=yes + +#[allow("literal")] +//~^ ERROR malformed lint attribute input [E0452] +fn main() {} diff --git a/tests/ui/lint/lint-attribute-literals.stderr b/tests/ui/lint/lint-attribute-literals.stderr new file mode 100644 index 0000000000000..34d7fbfc9b968 --- /dev/null +++ b/tests/ui/lint/lint-attribute-literals.stderr @@ -0,0 +1,9 @@ +error[E0452]: malformed lint attribute input + --> $DIR/lint-attribute-literals.rs:5:9 + | +LL | #[allow("literal")] + | ^^^^^^^^^ bad attribute argument + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0452`. From 7142f9a635a049f1248d860062d86df2cbf159af Mon Sep 17 00:00:00 2001 From: annieversary Date: Sat, 17 Oct 2026 21:19:21 +0200 Subject: [PATCH 19/27] improve diagnostic for literals in lint attributes --- .../rustc_attr_parsing/src/attributes/lint.rs | 112 ++++++++++-------- .../rustc_attr_parsing/src/diagnostics.rs | 18 +++ ...deduplicate-diagnostics.deduplicate.stderr | 7 +- .../deduplicate-diagnostics.duplicate.stderr | 17 +-- .../deduplicate-diagnostics.rs | 6 +- tests/ui/lint/lint-attribute-literals.rs | 2 +- tests/ui/lint/lint-attribute-literals.stderr | 7 +- 7 files changed, 102 insertions(+), 67 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/lint.rs b/compiler/rustc_attr_parsing/src/attributes/lint.rs index e1221ecbb96d8..51b0578d83688 100644 --- a/compiler/rustc_attr_parsing/src/attributes/lint.rs +++ b/compiler/rustc_attr_parsing/src/attributes/lint.rs @@ -7,7 +7,7 @@ use thin_vec::ThinVec; use crate::attributes::{AcceptMapping, AttributeParser, AttributeStability}; use crate::context::{AcceptContext, ExpectStringLiteral, FinalizeContext}; -use crate::parser::ArgParser; +use crate::parser::{ArgParser, MetaItemOrLitParser}; use crate::target_checking::AllowedTargets; use crate::target_checking::Policy::{Allow, Warn}; use crate::{AttributeTemplate, diagnostics, template}; @@ -48,58 +48,70 @@ impl LintParser { }; for item in parsers { - if let Some(p) = item.meta_item() { - match p.args() { - ArgParser::NoArgs => { - let (tool, lint_name, rest) = match &*p.path().0.segments { - [] => unreachable!(), - [lint_name] => (None, lint_name.ident.name, None), - [tool, lint_name] => (Some(tool.ident), lint_name.ident.name, None), - [tool, lint_name, rest @ ..] => { - let rest = rest - .iter() - .map(|s| s.ident.name) - .collect::>() - .into(); - (Some(tool.ident), lint_name.ident.name, Some(rest)) - } - }; + match item { + MetaItemOrLitParser::MetaItemParser(p) => { + match p.args() { + ArgParser::NoArgs => { + let (tool, lint_name, rest) = match &*p.path().0.segments { + [] => unreachable!(), + [lint_name] => (None, lint_name.ident.name, None), + [tool, lint_name] => { + (Some(tool.ident), lint_name.ident.name, None) + } + [tool, lint_name, rest @ ..] => { + let rest = rest + .iter() + .map(|s| s.ident.name) + .collect::>() + .into(); + (Some(tool.ident), lint_name.ident.name, Some(rest)) + } + }; - self.lints.push(LintCheck { - tool, - lint_name, - lint_span: p.span(), - kind, - attr_id, - reason, - attr_span, - rest, - }) - } - // We're found a `reason = "reason"` but we're not the last element. - ArgParser::NameValue(nv) if p.path().word_is(sym::reason) => { - cx.emit_err(diagnostics::MalformedAttribute { - span: p.span(), - sub: diagnostics::MalformedAttributeSub::ReasonMustComeLast( - item.span(), - ), - }); - nv.expect_string_literal(cx); - } - ArgParser::NameValue(_) | ArgParser::List(_) => { - cx.emit_err(diagnostics::MalformedAttribute { - span: p.span(), - sub: diagnostics::MalformedAttributeSub::BadAttributeArgument( - item.span(), - ), - }); + self.lints.push(LintCheck { + tool, + lint_name, + lint_span: p.span(), + kind, + attr_id, + reason, + attr_span, + rest, + }) + } + // We've found a `reason = "reason"` but we're not the last element. + ArgParser::NameValue(nv) if p.path().word_is(sym::reason) => { + cx.emit_err(diagnostics::MalformedAttribute { + span: p.span(), + sub: diagnostics::MalformedAttributeSub::ReasonMustComeLast( + item.span(), + ), + }); + nv.expect_string_literal(cx); + } + ArgParser::NameValue(_) | ArgParser::List(_) => { + cx.emit_err(diagnostics::MalformedAttribute { + span: p.span(), + sub: diagnostics::MalformedAttributeSub::BadAttributeArgument( + item.span(), + ), + }); + } } } - } else { - cx.emit_err(diagnostics::MalformedAttribute { - span: item.span(), - sub: diagnostics::MalformedAttributeSub::BadAttributeArgument(item.span()), - }); + MetaItemOrLitParser::Lit(lit) => { + cx.emit_err(diagnostics::BadAttributeLit { + span: item.span(), + sub: if lit.kind.is_str() { + diagnostics::BadAttributeLitHelp::StrLit { + sym: lit.symbol, + kind: kind.sym(), + } + } else { + diagnostics::BadAttributeLitHelp::Other { kind: kind.sym() } + }, + }); + } } } if parsers.is_empty() { diff --git a/compiler/rustc_attr_parsing/src/diagnostics.rs b/compiler/rustc_attr_parsing/src/diagnostics.rs index b55d7e476896b..6e517b3f7085a 100644 --- a/compiler/rustc_attr_parsing/src/diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/diagnostics.rs @@ -2150,6 +2150,24 @@ pub(crate) enum MalformedAttributeSub { ReasonMustComeLast(#[primary_span] Span), } +#[derive(Diagnostic)] +#[diag("expected path to a lint, found literal")] +pub(crate) struct BadAttributeLit { + #[primary_span] + #[label("not a lint")] + pub span: Span, + #[subdiagnostic] + pub sub: BadAttributeLitHelp, +} + +#[derive(Subdiagnostic)] +pub(crate) enum BadAttributeLitHelp { + #[help("try using `#[{$kind}({$sym})]`")] + StrLit { sym: Symbol, kind: Symbol }, + #[help("for example, write `#[{$kind}(dead_code)]` for `dead_code`")] + Other { kind: Symbol }, +} + #[derive(Subdiagnostic)] pub(crate) enum UnusedNote { #[note("attribute `{$name}` with an empty list has no effect")] diff --git a/tests/ui/diagnostic-flags/deduplicate-diagnostics.deduplicate.stderr b/tests/ui/diagnostic-flags/deduplicate-diagnostics.deduplicate.stderr index c0d568eb5384e..7e962b20a63f6 100644 --- a/tests/ui/diagnostic-flags/deduplicate-diagnostics.deduplicate.stderr +++ b/tests/ui/diagnostic-flags/deduplicate-diagnostics.deduplicate.stderr @@ -1,8 +1,10 @@ -error[E0452]: malformed lint attribute input +error: expected path to a lint, found literal --> $DIR/deduplicate-diagnostics.rs:10:8 | LL | #[deny("literal")] - | ^^^^^^^^^ bad attribute argument + | ^^^^^^^^^ not a lint + | + = help: try using `#[deny(literal)]` error: cannot find derive macro `Unresolved` in this scope --> $DIR/deduplicate-diagnostics.rs:6:10 @@ -12,4 +14,3 @@ LL | #[derive(Unresolved)] error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0452`. diff --git a/tests/ui/diagnostic-flags/deduplicate-diagnostics.duplicate.stderr b/tests/ui/diagnostic-flags/deduplicate-diagnostics.duplicate.stderr index 74d7066293f30..142333d750b4c 100644 --- a/tests/ui/diagnostic-flags/deduplicate-diagnostics.duplicate.stderr +++ b/tests/ui/diagnostic-flags/deduplicate-diagnostics.duplicate.stderr @@ -1,8 +1,10 @@ -error[E0452]: malformed lint attribute input +error: expected path to a lint, found literal --> $DIR/deduplicate-diagnostics.rs:10:8 | LL | #[deny("literal")] - | ^^^^^^^^^ bad attribute argument + | ^^^^^^^^^ not a lint + | + = help: try using `#[deny(literal)]` error: cannot find derive macro `Unresolved` in this scope --> $DIR/deduplicate-diagnostics.rs:6:10 @@ -18,22 +20,23 @@ LL | #[derive(Unresolved)] | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0452]: malformed lint attribute input +error: expected path to a lint, found literal --> $DIR/deduplicate-diagnostics.rs:10:8 | LL | #[deny("literal")] - | ^^^^^^^^^ bad attribute argument + | ^^^^^^^^^ not a lint | + = help: try using `#[deny(literal)]` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0452]: malformed lint attribute input +error: expected path to a lint, found literal --> $DIR/deduplicate-diagnostics.rs:10:8 | LL | #[deny("literal")] - | ^^^^^^^^^ bad attribute argument + | ^^^^^^^^^ not a lint | + = help: try using `#[deny(literal)]` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0452`. diff --git a/tests/ui/diagnostic-flags/deduplicate-diagnostics.rs b/tests/ui/diagnostic-flags/deduplicate-diagnostics.rs index 48705266e3584..27b033b346307 100644 --- a/tests/ui/diagnostic-flags/deduplicate-diagnostics.rs +++ b/tests/ui/diagnostic-flags/deduplicate-diagnostics.rs @@ -7,7 +7,7 @@ //[duplicate]~| ERROR cannot find derive macro `Unresolved` in this scope struct S; -#[deny("literal")] //~ ERROR malformed lint attribute input - //[duplicate]~| ERROR malformed lint attribute input - //[duplicate]~| ERROR malformed lint attribute input +#[deny("literal")] //~ ERROR expected path to a lint, found literal + //[duplicate]~| ERROR expected path to a lint, found literal + //[duplicate]~| ERROR expected path to a lint, found literal fn main() {} diff --git a/tests/ui/lint/lint-attribute-literals.rs b/tests/ui/lint/lint-attribute-literals.rs index 6cbae8e1e9fcf..1d104644c71bc 100644 --- a/tests/ui/lint/lint-attribute-literals.rs +++ b/tests/ui/lint/lint-attribute-literals.rs @@ -3,5 +3,5 @@ //@ compile-flags: -Zdeduplicate-diagnostics=yes #[allow("literal")] -//~^ ERROR malformed lint attribute input [E0452] +//~^ ERROR expected path to a lint, found literal fn main() {} diff --git a/tests/ui/lint/lint-attribute-literals.stderr b/tests/ui/lint/lint-attribute-literals.stderr index 34d7fbfc9b968..ca6832a0cdad8 100644 --- a/tests/ui/lint/lint-attribute-literals.stderr +++ b/tests/ui/lint/lint-attribute-literals.stderr @@ -1,9 +1,10 @@ -error[E0452]: malformed lint attribute input +error: expected path to a lint, found literal --> $DIR/lint-attribute-literals.rs:5:9 | LL | #[allow("literal")] - | ^^^^^^^^^ bad attribute argument + | ^^^^^^^^^ not a lint + | + = help: try using `#[allow(literal)]` error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0452`. From 1cb7727098ec3c8aa9758e2a18718a3532f0e3d3 Mon Sep 17 00:00:00 2001 From: annieversary Date: Sat, 17 Oct 2026 23:35:39 +0200 Subject: [PATCH 20/27] rename sub to kind in attribute diagnostics --- compiler/rustc_attr_parsing/src/attributes/lint.rs | 8 ++++---- compiler/rustc_attr_parsing/src/diagnostics.rs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/lint.rs b/compiler/rustc_attr_parsing/src/attributes/lint.rs index 51b0578d83688..0c603faa4b5f9 100644 --- a/compiler/rustc_attr_parsing/src/attributes/lint.rs +++ b/compiler/rustc_attr_parsing/src/attributes/lint.rs @@ -37,7 +37,7 @@ impl LintParser { if !p.path().word_is(sym::reason) { cx.emit_err(diagnostics::MalformedAttribute { span: p.span(), - sub: diagnostics::MalformedAttributeSub::BadAttributeArgument(p.span()), + kind: diagnostics::MalformedAttributeKind::BadAttributeArgument(p.span()), }); } else { parsers = &parsers[..(parsers.len() - 1)]; @@ -83,7 +83,7 @@ impl LintParser { ArgParser::NameValue(nv) if p.path().word_is(sym::reason) => { cx.emit_err(diagnostics::MalformedAttribute { span: p.span(), - sub: diagnostics::MalformedAttributeSub::ReasonMustComeLast( + kind: diagnostics::MalformedAttributeKind::ReasonMustComeLast( item.span(), ), }); @@ -92,7 +92,7 @@ impl LintParser { ArgParser::NameValue(_) | ArgParser::List(_) => { cx.emit_err(diagnostics::MalformedAttribute { span: p.span(), - sub: diagnostics::MalformedAttributeSub::BadAttributeArgument( + kind: diagnostics::MalformedAttributeKind::BadAttributeArgument( item.span(), ), }); @@ -102,7 +102,7 @@ impl LintParser { MetaItemOrLitParser::Lit(lit) => { cx.emit_err(diagnostics::BadAttributeLit { span: item.span(), - sub: if lit.kind.is_str() { + help: if lit.kind.is_str() { diagnostics::BadAttributeLitHelp::StrLit { sym: lit.symbol, kind: kind.sym(), diff --git a/compiler/rustc_attr_parsing/src/diagnostics.rs b/compiler/rustc_attr_parsing/src/diagnostics.rs index 6e517b3f7085a..259b2e5d8425f 100644 --- a/compiler/rustc_attr_parsing/src/diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/diagnostics.rs @@ -2139,11 +2139,11 @@ pub(crate) struct MalformedAttribute { #[primary_span] pub span: Span, #[subdiagnostic] - pub sub: MalformedAttributeSub, + pub kind: MalformedAttributeKind, } #[derive(Subdiagnostic)] -pub(crate) enum MalformedAttributeSub { +pub(crate) enum MalformedAttributeKind { #[label("bad attribute argument")] BadAttributeArgument(#[primary_span] Span), #[label("reason in lint attribute must come last")] @@ -2157,7 +2157,7 @@ pub(crate) struct BadAttributeLit { #[label("not a lint")] pub span: Span, #[subdiagnostic] - pub sub: BadAttributeLitHelp, + pub help: BadAttributeLitHelp, } #[derive(Subdiagnostic)] From 3c7ed77b5e4e4a9d464233dd3ad27d39a80ccfa8 Mon Sep 17 00:00:00 2001 From: SabrinaJewson Date: Sun, 18 Oct 2026 01:24:09 +0100 Subject: [PATCH 21/27] Add more syscall doc aliases to std docs --- library/alloc/src/io/copy.rs | 1 + library/std/src/fs.rs | 7 +++++-- library/std/src/os/windows/fs.rs | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/library/alloc/src/io/copy.rs b/library/alloc/src/io/copy.rs index 798bd2c1ec0a0..f414078d3a0b5 100644 --- a/library/alloc/src/io/copy.rs +++ b/library/alloc/src/io/copy.rs @@ -75,6 +75,7 @@ pub enum CopyState { /// descriptors if possible. /// /// Note that platform-specific behavior may change in the future. +#[doc(alias = "copy_file_range", alias = "sendfile", alias = "splice")] #[stable(feature = "rust1", since = "1.0.0")] pub fn copy(reader: &mut R, writer: &mut W) -> Result where diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index c668e6216fd4b..f922696298fff 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -3039,7 +3039,7 @@ pub fn remove_file>(path: P) -> io::Result<()> { /// Ok(()) /// } /// ``` -#[doc(alias = "stat")] +#[doc(alias = "stat", alias = "GetFileAttributes", alias = "GetFileAttributesEx")] #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "fs_metadata")] pub fn metadata>(path: P) -> io::Result { @@ -3080,7 +3080,7 @@ pub fn metadata>(path: P) -> io::Result { /// Ok(()) /// } /// ``` -#[doc(alias = "lstat")] +#[doc(alias = "lstat", alias = "GetFileAttributes", alias = "GetFileAttributesEx")] #[stable(feature = "symlink_metadata", since = "1.1.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "fs_symlink_metadata")] pub fn symlink_metadata>(path: P) -> io::Result { @@ -3262,6 +3262,7 @@ pub fn rename_noreplace, Q: AsRef>(from: P, to: Q) -> io::R /// } /// ``` #[doc(alias = "cp")] +#[doc(alias = "copy_file_range")] #[doc(alias = "CopyFile", alias = "CopyFileEx")] #[doc(alias = "fclonefileat", alias = "fcopyfile")] #[stable(feature = "rust1", since = "1.0.0")] @@ -3511,6 +3512,7 @@ pub fn create_dir>(path: P) -> io::Result<()> { /// Ok(()) /// } /// ``` +#[doc(alias = "mkdir", alias = "CreateDirectory")] #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "fs_create_dir_all")] pub fn create_dir_all>(path: P) -> io::Result<()> { @@ -3626,6 +3628,7 @@ pub fn remove_dir>(path: P) -> io::Result<()> { /// Ok(()) /// } /// ``` +#[doc(alias = "rm")] #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "fs_remove_dir_all")] pub fn remove_dir_all>(path: P) -> io::Result<()> { diff --git a/library/std/src/os/windows/fs.rs b/library/std/src/os/windows/fs.rs index 4c2506ffae66c..865cc90e83156 100644 --- a/library/std/src/os/windows/fs.rs +++ b/library/std/src/os/windows/fs.rs @@ -908,6 +908,7 @@ impl FileTimesExt for fs::FileTimes { /// the process as an administrator. /// /// [symlink-security]: https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links +#[doc(alias = "CreateSymbolicLink", alias = "CreateSymbolicLinkW")] #[stable(feature = "symlink", since = "1.1.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "fs_symlink_file")] pub fn symlink_file, Q: AsRef>(original: P, link: Q) -> io::Result<()> { @@ -949,6 +950,7 @@ pub fn symlink_file, Q: AsRef>(original: P, link: Q) -> io: /// the process as an administrator. /// /// [symlink-security]: https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/create-symbolic-links +#[doc(alias = "CreateSymbolicLink", alias = "CreateSymbolicLinkW")] #[stable(feature = "symlink", since = "1.1.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "fs_symlink_dir")] pub fn symlink_dir, Q: AsRef>(original: P, link: Q) -> io::Result<()> { From 4245f27b542a0370fecb1691fe931d3d4f7bc6fb Mon Sep 17 00:00:00 2001 From: annieversary Date: Sun, 18 Oct 2026 07:46:15 +0200 Subject: [PATCH 22/27] change label in BadAttributeLit to be more descriptive --- compiler/rustc_attr_parsing/src/diagnostics.rs | 2 +- .../deduplicate-diagnostics.deduplicate.stderr | 2 +- .../deduplicate-diagnostics.duplicate.stderr | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/diagnostics.rs b/compiler/rustc_attr_parsing/src/diagnostics.rs index 259b2e5d8425f..47ea9a2c08517 100644 --- a/compiler/rustc_attr_parsing/src/diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/diagnostics.rs @@ -2154,7 +2154,7 @@ pub(crate) enum MalformedAttributeKind { #[diag("expected path to a lint, found literal")] pub(crate) struct BadAttributeLit { #[primary_span] - #[label("not a lint")] + #[label("not the name of a lint")] pub span: Span, #[subdiagnostic] pub help: BadAttributeLitHelp, diff --git a/tests/ui/diagnostic-flags/deduplicate-diagnostics.deduplicate.stderr b/tests/ui/diagnostic-flags/deduplicate-diagnostics.deduplicate.stderr index 7e962b20a63f6..c35a239f7e062 100644 --- a/tests/ui/diagnostic-flags/deduplicate-diagnostics.deduplicate.stderr +++ b/tests/ui/diagnostic-flags/deduplicate-diagnostics.deduplicate.stderr @@ -2,7 +2,7 @@ error: expected path to a lint, found literal --> $DIR/deduplicate-diagnostics.rs:10:8 | LL | #[deny("literal")] - | ^^^^^^^^^ not a lint + | ^^^^^^^^^ not the name of a lint | = help: try using `#[deny(literal)]` diff --git a/tests/ui/diagnostic-flags/deduplicate-diagnostics.duplicate.stderr b/tests/ui/diagnostic-flags/deduplicate-diagnostics.duplicate.stderr index 142333d750b4c..ff782a8d80cca 100644 --- a/tests/ui/diagnostic-flags/deduplicate-diagnostics.duplicate.stderr +++ b/tests/ui/diagnostic-flags/deduplicate-diagnostics.duplicate.stderr @@ -2,7 +2,7 @@ error: expected path to a lint, found literal --> $DIR/deduplicate-diagnostics.rs:10:8 | LL | #[deny("literal")] - | ^^^^^^^^^ not a lint + | ^^^^^^^^^ not the name of a lint | = help: try using `#[deny(literal)]` @@ -24,7 +24,7 @@ error: expected path to a lint, found literal --> $DIR/deduplicate-diagnostics.rs:10:8 | LL | #[deny("literal")] - | ^^^^^^^^^ not a lint + | ^^^^^^^^^ not the name of a lint | = help: try using `#[deny(literal)]` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` @@ -33,7 +33,7 @@ error: expected path to a lint, found literal --> $DIR/deduplicate-diagnostics.rs:10:8 | LL | #[deny("literal")] - | ^^^^^^^^^ not a lint + | ^^^^^^^^^ not the name of a lint | = help: try using `#[deny(literal)]` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` From 1c9a4b7396042bbc50761be18821fa4d3086c945 Mon Sep 17 00:00:00 2001 From: annieversary Date: Sun, 18 Oct 2026 07:46:49 +0200 Subject: [PATCH 23/27] change t/u/l/lint-attribute-literals to not deduplicate-diagnostics --- tests/ui/lint/lint-attribute-literals.rs | 4 ++-- tests/ui/lint/lint-attribute-literals.stderr | 24 +++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/tests/ui/lint/lint-attribute-literals.rs b/tests/ui/lint/lint-attribute-literals.rs index 1d104644c71bc..137b5b94ea7b7 100644 --- a/tests/ui/lint/lint-attribute-literals.rs +++ b/tests/ui/lint/lint-attribute-literals.rs @@ -1,7 +1,7 @@ // Checks that lint attributes with literals have an explanatory error -//@ compile-flags: -Zdeduplicate-diagnostics=yes - #[allow("literal")] //~^ ERROR expected path to a lint, found literal +//~| ERROR expected path to a lint, found literal +//~| ERROR expected path to a lint, found literal fn main() {} diff --git a/tests/ui/lint/lint-attribute-literals.stderr b/tests/ui/lint/lint-attribute-literals.stderr index ca6832a0cdad8..161800c09a869 100644 --- a/tests/ui/lint/lint-attribute-literals.stderr +++ b/tests/ui/lint/lint-attribute-literals.stderr @@ -1,10 +1,28 @@ error: expected path to a lint, found literal - --> $DIR/lint-attribute-literals.rs:5:9 + --> $DIR/lint-attribute-literals.rs:3:9 | LL | #[allow("literal")] - | ^^^^^^^^^ not a lint + | ^^^^^^^^^ not the name of a lint | = help: try using `#[allow(literal)]` -error: aborting due to 1 previous error +error: expected path to a lint, found literal + --> $DIR/lint-attribute-literals.rs:3:9 + | +LL | #[allow("literal")] + | ^^^^^^^^^ not the name of a lint + | + = help: try using `#[allow(literal)]` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: expected path to a lint, found literal + --> $DIR/lint-attribute-literals.rs:3:9 + | +LL | #[allow("literal")] + | ^^^^^^^^^ not the name of a lint + | + = help: try using `#[allow(literal)]` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 3 previous errors From db8f02fa178c09cd4fd05f8dc12a68c04f2685ba Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sat, 17 Oct 2026 22:04:35 -0700 Subject: [PATCH 24/27] Generate redirect pages for hidden modules This fixes an intra-doc link, shown in the test case, where the private path gets used as the link target. --- src/librustdoc/html/render/context.rs | 14 +++++------- tests/rustdoc-html/file-creation-111249.rs | 5 +++-- .../auxiliary/doc-hidden-reexported.rs | 10 +++++++++ ...-to-item-thats-reexport-from-doc-hidden.rs | 22 +++++++++++++++++++ .../reexport-trait-from-hidden-111064-2.rs | 5 +++-- 5 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 tests/rustdoc-html/intra-doc/auxiliary/doc-hidden-reexported.rs create mode 100644 tests/rustdoc-html/intra-doc/link-to-item-thats-reexport-from-doc-hidden.rs diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index f828327b4b985..96b735b08a894 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -725,14 +725,12 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { info!("Recursing into {}", self.dst.display()); - if !item.is_stripped() { - let buf = self.render_item(item, true); - // buf will be empty if the module is stripped and there is no redirect for it - if !buf.is_empty() { - self.shared.ensure_dir(&self.dst)?; - let joint_dst = self.dst.join("index.html"); - self.shared.fs.write(joint_dst, buf)?; - } + let buf = self.render_item(item, true); + // buf will be empty if the module is stripped and there is no redirect for it + if !buf.is_empty() { + self.shared.ensure_dir(&self.dst)?; + let joint_dst = self.dst.join("index.html"); + self.shared.fs.write(joint_dst, buf)?; } if !self.info.is_inside_inlined_module { if let Some(def_id) = item.def_id() diff --git a/tests/rustdoc-html/file-creation-111249.rs b/tests/rustdoc-html/file-creation-111249.rs index 7a075a1583f30..e745d59b10132 100644 --- a/tests/rustdoc-html/file-creation-111249.rs +++ b/tests/rustdoc-html/file-creation-111249.rs @@ -17,11 +17,12 @@ pub trait Sized: MetaSized {} // 'struct.Bar.html', 'trait.Sized.html', 'trait.MetaSized.html', 'trait.PointeeSized.html']" //@ files "foo/visible" "['trait.Foo.html', 'index.html', 'sidebar-items.js']" //@ files "foo/hidden" "['inner']" -//@ files "foo/hidden/inner" "['trait.Foo.html']" +//@ files "foo/hidden/inner" "['index.html', 'trait.Foo.html']" // The following five should not fail! //@ !has 'foo/hidden/index.html' -//@ !has 'foo/hidden/inner/index.html' +//@ has 'foo/hidden/inner/index.html' +//@ matchesraw - '' // FIXME: Should be `@!has`: https://github.com/rust-lang/rust/issues/111249 //@ has 'foo/hidden/inner/trait.Foo.html' //@ matchesraw - '' diff --git a/tests/rustdoc-html/intra-doc/auxiliary/doc-hidden-reexported.rs b/tests/rustdoc-html/intra-doc/auxiliary/doc-hidden-reexported.rs new file mode 100644 index 0000000000000..096e958395f94 --- /dev/null +++ b/tests/rustdoc-html/intra-doc/auxiliary/doc-hidden-reexported.rs @@ -0,0 +1,10 @@ +#[doc(hidden)] +pub mod docs { + /// Foo + pub mod io_uring_provided_buffers {} + /// Bar + pub struct IoUringProvidedBuffers; +} + +pub use docs::io_uring_provided_buffers; +pub use docs::IoUringProvidedBuffers; diff --git a/tests/rustdoc-html/intra-doc/link-to-item-thats-reexport-from-doc-hidden.rs b/tests/rustdoc-html/intra-doc/link-to-item-thats-reexport-from-doc-hidden.rs new file mode 100644 index 0000000000000..0f9fc3e358ff3 --- /dev/null +++ b/tests/rustdoc-html/intra-doc/link-to-item-thats-reexport-from-doc-hidden.rs @@ -0,0 +1,22 @@ +//@ aux-build:doc-hidden-reexported.rs +//@ build-aux-docs + +//@ has doc_hidden_reexported/docs/io_uring_provided_buffers/index.html +//@ matchesraw - '' +//@ has doc_hidden_reexported/io_uring_provided_buffers/index.html + +//@ has doc_hidden_reexported/docs/struct.IoUringProvidedBuffers.html +//@ matchesraw - '' +//@ has doc_hidden_reexported/struct.IoUringProvidedBuffers.html + +//! Link to [doc_hidden_reexported::io_uring_provided_buffers] and +//! [doc_hidden_reexported::IoUringProvidedBuffers] +//! +//! Because these cross-crate links point at the internal, private path, +//! we need to make sure the redirect gets generated. + +//@ has link_to_item_thats_reexport_from_doc_hidden/index.html +//@ count - '//a[@href="../doc_hidden_reexported/docs/io_uring_provided_buffers/index.html"]' 1 +//@ count - '//a[@href="../doc_hidden_reexported/docs/struct.IoUringProvidedBuffers.html"]' 1 + +extern crate doc_hidden_reexported; diff --git a/tests/rustdoc-html/reexport/reexport-trait-from-hidden-111064-2.rs b/tests/rustdoc-html/reexport/reexport-trait-from-hidden-111064-2.rs index 8f0a5806b0918..e8d96cb19b6bd 100644 --- a/tests/rustdoc-html/reexport/reexport-trait-from-hidden-111064-2.rs +++ b/tests/rustdoc-html/reexport/reexport-trait-from-hidden-111064-2.rs @@ -15,11 +15,12 @@ pub trait Sized: MetaSized {} //@ files "foo" "['sidebar-items.js', 'all.html', 'hidden', 'index.html', 'struct.Bar.html', \ // 'visible', 'trait.Sized.html', 'trait.MetaSized.html', 'trait.PointeeSized.html']" //@ files "foo/hidden" "['inner']" -//@ files "foo/hidden/inner" "['trait.Foo.html']" +//@ files "foo/hidden/inner" "['index.html', 'trait.Foo.html']" //@ files "foo/visible" "['index.html', 'sidebar-items.js', 'trait.Foo.html']" //@ !has 'foo/hidden/index.html' -//@ !has 'foo/hidden/inner/index.html' +//@ has 'foo/hidden/inner/index.html' +//@ matchesraw - '' // FIXME: Should be `@!has`: https://github.com/rust-lang/rust/issues/111249 //@ has 'foo/hidden/inner/trait.Foo.html' //@ matchesraw - '' From 7213e553733a4c1c3a0bf27937f83df0518323dd Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 18 Oct 2026 12:20:47 +0200 Subject: [PATCH 25/27] abort_on_unwind: clarify docs --- library/core/src/panic.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/core/src/panic.rs b/library/core/src/panic.rs index 4fcd5f615e993..52fcfebd1111c 100644 --- a/library/core/src/panic.rs +++ b/library/core/src/panic.rs @@ -97,8 +97,9 @@ pub macro unreachable_2021 { /// Invokes a closure, aborting if the closure unwinds. /// /// When compiled with aborting panics, this function is effectively a no-op. -/// With unwinding panics, an unwind results in another call into the panic -/// hook followed by a process abort. +/// With unwinding panics, an unwind that would leave the closure results in another call into the +/// panic handler / panic hook followed by a process abort. (Locals in the closure get dropped as +/// usual.) Unwinds that get caught inside the closure still behave as normal. /// /// # Notes /// @@ -114,7 +115,7 @@ pub macro unreachable_2021 { /// to prevent unwinds. However, note that `extern "C" fn` will automatically /// convert unwinds to aborts, so using this function isn't necessary for FFI. #[unstable(feature = "abort_unwind", issue = "130338")] -#[rustc_nounwind] +#[rustc_nounwind] // this attribute does all the actual work here pub fn abort_on_unwind R, R>(f: F) -> R { f() } From f9d044c80089a17b746d14173d6c51480813b56f Mon Sep 17 00:00:00 2001 From: annieversary Date: Sun, 18 Oct 2026 15:13:46 +0200 Subject: [PATCH 26/27] simplify BadAttributeLit diagnostic message --- compiler/rustc_attr_parsing/src/diagnostics.rs | 2 +- .../deduplicate-diagnostics.deduplicate.stderr | 2 +- .../deduplicate-diagnostics.duplicate.stderr | 6 +++--- tests/ui/diagnostic-flags/deduplicate-diagnostics.rs | 6 +++--- tests/ui/lint/lint-attribute-literals.rs | 6 +++--- tests/ui/lint/lint-attribute-literals.stderr | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/diagnostics.rs b/compiler/rustc_attr_parsing/src/diagnostics.rs index 47ea9a2c08517..848ab845dc7f6 100644 --- a/compiler/rustc_attr_parsing/src/diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/diagnostics.rs @@ -2151,7 +2151,7 @@ pub(crate) enum MalformedAttributeKind { } #[derive(Diagnostic)] -#[diag("expected path to a lint, found literal")] +#[diag("expected a lint, found literal")] pub(crate) struct BadAttributeLit { #[primary_span] #[label("not the name of a lint")] diff --git a/tests/ui/diagnostic-flags/deduplicate-diagnostics.deduplicate.stderr b/tests/ui/diagnostic-flags/deduplicate-diagnostics.deduplicate.stderr index c35a239f7e062..114c37188a9ef 100644 --- a/tests/ui/diagnostic-flags/deduplicate-diagnostics.deduplicate.stderr +++ b/tests/ui/diagnostic-flags/deduplicate-diagnostics.deduplicate.stderr @@ -1,4 +1,4 @@ -error: expected path to a lint, found literal +error: expected a lint, found literal --> $DIR/deduplicate-diagnostics.rs:10:8 | LL | #[deny("literal")] diff --git a/tests/ui/diagnostic-flags/deduplicate-diagnostics.duplicate.stderr b/tests/ui/diagnostic-flags/deduplicate-diagnostics.duplicate.stderr index ff782a8d80cca..66d0d94c0e815 100644 --- a/tests/ui/diagnostic-flags/deduplicate-diagnostics.duplicate.stderr +++ b/tests/ui/diagnostic-flags/deduplicate-diagnostics.duplicate.stderr @@ -1,4 +1,4 @@ -error: expected path to a lint, found literal +error: expected a lint, found literal --> $DIR/deduplicate-diagnostics.rs:10:8 | LL | #[deny("literal")] @@ -20,7 +20,7 @@ LL | #[derive(Unresolved)] | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: expected path to a lint, found literal +error: expected a lint, found literal --> $DIR/deduplicate-diagnostics.rs:10:8 | LL | #[deny("literal")] @@ -29,7 +29,7 @@ LL | #[deny("literal")] = help: try using `#[deny(literal)]` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: expected path to a lint, found literal +error: expected a lint, found literal --> $DIR/deduplicate-diagnostics.rs:10:8 | LL | #[deny("literal")] diff --git a/tests/ui/diagnostic-flags/deduplicate-diagnostics.rs b/tests/ui/diagnostic-flags/deduplicate-diagnostics.rs index 27b033b346307..b070ec0f7dd93 100644 --- a/tests/ui/diagnostic-flags/deduplicate-diagnostics.rs +++ b/tests/ui/diagnostic-flags/deduplicate-diagnostics.rs @@ -7,7 +7,7 @@ //[duplicate]~| ERROR cannot find derive macro `Unresolved` in this scope struct S; -#[deny("literal")] //~ ERROR expected path to a lint, found literal - //[duplicate]~| ERROR expected path to a lint, found literal - //[duplicate]~| ERROR expected path to a lint, found literal +#[deny("literal")] //~ ERROR expected a lint, found literal + //[duplicate]~| ERROR expected a lint, found literal + //[duplicate]~| ERROR expected a lint, found literal fn main() {} diff --git a/tests/ui/lint/lint-attribute-literals.rs b/tests/ui/lint/lint-attribute-literals.rs index 137b5b94ea7b7..69fb7f76007a0 100644 --- a/tests/ui/lint/lint-attribute-literals.rs +++ b/tests/ui/lint/lint-attribute-literals.rs @@ -1,7 +1,7 @@ // Checks that lint attributes with literals have an explanatory error #[allow("literal")] -//~^ ERROR expected path to a lint, found literal -//~| ERROR expected path to a lint, found literal -//~| ERROR expected path to a lint, found literal +//~^ ERROR expected a lint, found literal +//~| ERROR expected a lint, found literal +//~| ERROR expected a lint, found literal fn main() {} diff --git a/tests/ui/lint/lint-attribute-literals.stderr b/tests/ui/lint/lint-attribute-literals.stderr index 161800c09a869..188a941918c8d 100644 --- a/tests/ui/lint/lint-attribute-literals.stderr +++ b/tests/ui/lint/lint-attribute-literals.stderr @@ -1,4 +1,4 @@ -error: expected path to a lint, found literal +error: expected a lint, found literal --> $DIR/lint-attribute-literals.rs:3:9 | LL | #[allow("literal")] @@ -6,7 +6,7 @@ LL | #[allow("literal")] | = help: try using `#[allow(literal)]` -error: expected path to a lint, found literal +error: expected a lint, found literal --> $DIR/lint-attribute-literals.rs:3:9 | LL | #[allow("literal")] @@ -15,7 +15,7 @@ LL | #[allow("literal")] = help: try using `#[allow(literal)]` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: expected path to a lint, found literal +error: expected a lint, found literal --> $DIR/lint-attribute-literals.rs:3:9 | LL | #[allow("literal")] From 31b27ab32c6a6b09825e3f937661b4e0baceca7f Mon Sep 17 00:00:00 2001 From: annieversary Date: Sun, 18 Oct 2026 14:17:33 +0100 Subject: [PATCH 27/27] add test for the BadAttributeLitHelp::Other case --- tests/ui/lint/lint-attribute-literals.rs | 4 +++ tests/ui/lint/lint-attribute-literals.stderr | 28 +++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/ui/lint/lint-attribute-literals.rs b/tests/ui/lint/lint-attribute-literals.rs index 69fb7f76007a0..34a4757adec3c 100644 --- a/tests/ui/lint/lint-attribute-literals.rs +++ b/tests/ui/lint/lint-attribute-literals.rs @@ -4,4 +4,8 @@ //~^ ERROR expected a lint, found literal //~| ERROR expected a lint, found literal //~| ERROR expected a lint, found literal +#[deny(1.0)] +//~^ ERROR expected a lint, found literal +//~| ERROR expected a lint, found literal +//~| ERROR expected a lint, found literal fn main() {} diff --git a/tests/ui/lint/lint-attribute-literals.stderr b/tests/ui/lint/lint-attribute-literals.stderr index 188a941918c8d..7434f8b5c5d4b 100644 --- a/tests/ui/lint/lint-attribute-literals.stderr +++ b/tests/ui/lint/lint-attribute-literals.stderr @@ -6,6 +6,14 @@ LL | #[allow("literal")] | = help: try using `#[allow(literal)]` +error: expected a lint, found literal + --> $DIR/lint-attribute-literals.rs:7:8 + | +LL | #[deny(1.0)] + | ^^^ not the name of a lint + | + = help: for example, write `#[deny(dead_code)]` for `dead_code` + error: expected a lint, found literal --> $DIR/lint-attribute-literals.rs:3:9 | @@ -15,6 +23,15 @@ LL | #[allow("literal")] = help: try using `#[allow(literal)]` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +error: expected a lint, found literal + --> $DIR/lint-attribute-literals.rs:7:8 + | +LL | #[deny(1.0)] + | ^^^ not the name of a lint + | + = help: for example, write `#[deny(dead_code)]` for `dead_code` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: expected a lint, found literal --> $DIR/lint-attribute-literals.rs:3:9 | @@ -24,5 +41,14 @@ LL | #[allow("literal")] = help: try using `#[allow(literal)]` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 3 previous errors +error: expected a lint, found literal + --> $DIR/lint-attribute-literals.rs:7:8 + | +LL | #[deny(1.0)] + | ^^^ not the name of a lint + | + = help: for example, write `#[deny(dead_code)]` for `dead_code` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 6 previous errors