From db18ecf2637f9994ad2508144bcf4f018ac46315 Mon Sep 17 00:00:00 2001 From: sayantn Date: Wed, 25 Feb 2026 06:17:53 +0530 Subject: [PATCH 1/4] Require avxvnni for avx10.2 --- compiler/rustc_target/src/target_features.rs | 6 +- library/std_detect/src/detect/os/x86.rs | 70 +++++++++++--------- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index c3de7e257662f..aa272ebd4b776 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -392,7 +392,11 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ "avx512vpopcntdq", ], ), - ("avx10.2", Unstable(sym::avx10_target_feature), &["avx10.1"]), + ( + "avx10.2", + Unstable(sym::avx10_target_feature), + &["avx10.1", "avxvnni", "avxvnniint8", "avxvnniint16"], + ), ("avx512bf16", Stable, &["avx512bw"]), ("avx512bitalg", Stable, &["avx512bw"]), ("avx512bw", Stable, &["avx512f"]), diff --git a/library/std_detect/src/detect/os/x86.rs b/library/std_detect/src/detect/os/x86.rs index f2205ba07dd41..b24ef6a37ef55 100644 --- a/library/std_detect/src/detect/os/x86.rs +++ b/library/std_detect/src/detect/os/x86.rs @@ -202,6 +202,28 @@ pub(crate) fn detect_features() -> cache::Initializer { // Test `XCR0.APX[19]` with the mask `0b1000_0000_0000_0000_0000 == 0x80000` let os_apx_support = xcr0 & 0x80000 == 0x80000; + if os_amx_support { + enable(extended_features_edx, 24, Feature::amx_tile); + enable(extended_features_edx, 25, Feature::amx_int8); + enable(extended_features_edx, 22, Feature::amx_bf16); + enable(extended_features_eax_leaf_1, 21, Feature::amx_fp16); + enable(extended_features_edx_leaf_1, 8, Feature::amx_complex); + + if max_basic_leaf >= 0x1e { + let CpuidResult { eax: amx_feature_flags_eax, .. } = + __cpuid_count(0x1e_u32, 1); + + enable(amx_feature_flags_eax, 4, Feature::amx_fp8); + enable(amx_feature_flags_eax, 6, Feature::amx_tf32); + enable(amx_feature_flags_eax, 7, Feature::amx_avx512); + enable(amx_feature_flags_eax, 8, Feature::amx_movrs); + } + } + + if os_apx_support { + enable(extended_features_edx_leaf_1, 21, Feature::apxf); + } + // Only if the OS and the CPU support saving/restoring the AVX // registers we enable `xsave` support: if os_avx_support { @@ -236,9 +258,10 @@ pub(crate) fn detect_features() -> cache::Initializer { enable(extended_features_ebx, 5, Feature::avx2); // "Short" versions of AVX512 instructions - enable(extended_features_eax_leaf_1, 4, Feature::avxvnni); - enable(extended_features_eax_leaf_1, 23, Feature::avxifma); - enable(extended_features_edx_leaf_1, 4, Feature::avxvnniint8); + let avxvnni = enable(extended_features_eax_leaf_1, 4, Feature::avxvnni); + let avxvnniint8 = enable(extended_features_eax_leaf_1, 23, Feature::avxifma); + let avxvnniint16 = + enable(extended_features_edx_leaf_1, 4, Feature::avxvnniint8); enable(extended_features_edx_leaf_1, 5, Feature::avxneconvert); enable(extended_features_edx_leaf_1, 10, Feature::avxvnniint16); @@ -269,37 +292,18 @@ pub(crate) fn detect_features() -> cache::Initializer { enable(extended_features_edx, 8, Feature::avx512vp2intersect); enable(extended_features_edx, 23, Feature::avx512fp16); enable(extended_features_eax_leaf_1, 5, Feature::avx512bf16); - } - } - - if os_amx_support { - enable(extended_features_edx, 24, Feature::amx_tile); - enable(extended_features_edx, 25, Feature::amx_int8); - enable(extended_features_edx, 22, Feature::amx_bf16); - enable(extended_features_eax_leaf_1, 21, Feature::amx_fp16); - enable(extended_features_edx_leaf_1, 8, Feature::amx_complex); - - if max_basic_leaf >= 0x1e { - let CpuidResult { eax: amx_feature_flags_eax, .. } = - __cpuid_count(0x1e_u32, 1); - - enable(amx_feature_flags_eax, 4, Feature::amx_fp8); - enable(amx_feature_flags_eax, 6, Feature::amx_tf32); - enable(amx_feature_flags_eax, 7, Feature::amx_avx512); - enable(amx_feature_flags_eax, 8, Feature::amx_movrs); - } - } - - if os_apx_support { - enable(extended_features_edx_leaf_1, 21, Feature::apxf); - } - let avx10_1 = enable(extended_features_edx_leaf_1, 19, Feature::avx10_1); - if avx10_1 { - let CpuidResult { ebx, .. } = __cpuid(0x24); - let avx10_version = ebx & 0xff; - if avx10_version >= 2 { - value.set(Feature::avx10_2 as u32); + let avx10_1 = enable(extended_features_edx_leaf_1, 19, Feature::avx10_1); + if avx10_1 { + let CpuidResult { ebx, .. } = __cpuid(0x24); + let avx10_version = ebx & 0xff; + + // AVX10.2 supports masked versions of dot-product instructions available in avxvnni etc, + // so it doesn't make sense to have it without the unmasked versions + if avx10_version >= 2 && avxvnni && avxvnniint8 && avxvnniint16 { + value.set(Feature::avx10_2 as u32); + } + } } } } From 08e064a9cb46008d72236dd83737f160afd67e99 Mon Sep 17 00:00:00 2001 From: Takayuki Maeda Date: Wed, 25 Mar 2026 16:48:57 +0900 Subject: [PATCH 2/4] add regression test for 154189 fix ci errors --- .../generalize-associated-type-alias.rs | 22 +++++++++++++++ .../generalize-associated-type-alias.stderr | 28 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 tests/ui/coherence/generalize-associated-type-alias.rs create mode 100644 tests/ui/coherence/generalize-associated-type-alias.stderr diff --git a/tests/ui/coherence/generalize-associated-type-alias.rs b/tests/ui/coherence/generalize-associated-type-alias.rs new file mode 100644 index 0000000000000..f333a0d8ae853 --- /dev/null +++ b/tests/ui/coherence/generalize-associated-type-alias.rs @@ -0,0 +1,22 @@ +// Regression test for https://github.com/rust-lang/rust/issues/154189. +#![feature(unboxed_closures)] + +trait ToUnit<'a> { + type Unit; +} + +impl ToUnit<'_> for *const u32 { + type Unit = (); +} + +trait Overlap {} + +type Assoc<'a, T> = <*const T as ToUnit<'a>>::Unit; + +impl Overlap for T {} + +impl<'a, T> Overlap<(&'a (), Assoc<'a, T>)> for T {} +//~^ ERROR the trait bound `*const T: ToUnit<'a>` is not satisfied +//~| ERROR the trait bound `T: Overlap<(&'a (), _)>` is not satisfied + +fn main() {} diff --git a/tests/ui/coherence/generalize-associated-type-alias.stderr b/tests/ui/coherence/generalize-associated-type-alias.stderr new file mode 100644 index 0000000000000..e65205dbccbd1 --- /dev/null +++ b/tests/ui/coherence/generalize-associated-type-alias.stderr @@ -0,0 +1,28 @@ +error[E0277]: the trait bound `*const T: ToUnit<'a>` is not satisfied + --> $DIR/generalize-associated-type-alias.rs:18:13 + | +LL | impl<'a, T> Overlap<(&'a (), Assoc<'a, T>)> for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `ToUnit<'a>` is not implemented for `*const T` + | +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | impl<'a, T> Overlap<(&'a (), Assoc<'a, T>)> for T where *const T: ToUnit<'a> {} + | ++++++++++++++++++++++++++ + +error[E0277]: the trait bound `T: Overlap<(&'a (), _)>` is not satisfied + --> $DIR/generalize-associated-type-alias.rs:18:49 + | +LL | impl<'a, T> Overlap<(&'a (), Assoc<'a, T>)> for T {} + | ^ the trait `Overlap<(&'a (), _)>` is not implemented for `T` + | +help: the trait `Overlap<(&'a (), _)>` is not implemented for `T` + but trait `Overlap<(&(), ())>` is implemented for `u32` + --> $DIR/generalize-associated-type-alias.rs:18:1 + | +LL | impl<'a, T> Overlap<(&'a (), Assoc<'a, T>)> for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: for that trait implementation, expected `u32`, found `T` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. From f7b3e88947e8d24272622a15b0ea690ef918c3d7 Mon Sep 17 00:00:00 2001 From: ujjwalVishwakarma2006 <2023ucs0116@iitjammu.ac.in> Date: Thu, 26 Mar 2026 01:50:12 +0530 Subject: [PATCH 3/4] Rename two test files --- tests/ui/{issues/issue-17734.rs => codegen/box-str-drop-glue.rs} | 0 .../issue-4735.rs => drop/drop-noncopyable-raw-pointer.rs} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/ui/{issues/issue-17734.rs => codegen/box-str-drop-glue.rs} (100%) rename tests/ui/{issues/issue-4735.rs => drop/drop-noncopyable-raw-pointer.rs} (100%) diff --git a/tests/ui/issues/issue-17734.rs b/tests/ui/codegen/box-str-drop-glue.rs similarity index 100% rename from tests/ui/issues/issue-17734.rs rename to tests/ui/codegen/box-str-drop-glue.rs diff --git a/tests/ui/issues/issue-4735.rs b/tests/ui/drop/drop-noncopyable-raw-pointer.rs similarity index 100% rename from tests/ui/issues/issue-4735.rs rename to tests/ui/drop/drop-noncopyable-raw-pointer.rs From ff29b410544eb6c56cf9ae0fa36125417aa77407 Mon Sep 17 00:00:00 2001 From: ujjwalVishwakarma2006 <2023ucs0116@iitjammu.ac.in> Date: Thu, 26 Mar 2026 03:12:06 +0530 Subject: [PATCH 4/4] Add issue link at the top in files tests/ui/codegen/box-str-drop-glue.rs and tests/ui/drop/drop-noncopyable-raw-pointer.rs --- tests/ui/codegen/box-str-drop-glue.rs | 1 + tests/ui/drop/drop-noncopyable-raw-pointer.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/ui/codegen/box-str-drop-glue.rs b/tests/ui/codegen/box-str-drop-glue.rs index 984adeece6dee..6a25db722af74 100644 --- a/tests/ui/codegen/box-str-drop-glue.rs +++ b/tests/ui/codegen/box-str-drop-glue.rs @@ -1,3 +1,4 @@ +//! regression test for //@ run-pass // Test that generating drop glue for Box doesn't ICE diff --git a/tests/ui/drop/drop-noncopyable-raw-pointer.rs b/tests/ui/drop/drop-noncopyable-raw-pointer.rs index 1ca145bae420d..8e980a23c904b 100644 --- a/tests/ui/drop/drop-noncopyable-raw-pointer.rs +++ b/tests/ui/drop/drop-noncopyable-raw-pointer.rs @@ -1,3 +1,4 @@ +//! regression test for //@ run-pass use std::mem::transmute;