From db3a0e5769a5340b9e9a5c7a6817af335cbe6b67 Mon Sep 17 00:00:00 2001 From: Lucas Sunsi Abreu Date: Fri, 11 Sep 2026 11:10:35 -0300 Subject: [PATCH 1/4] Add regression test for matching associated types on new solver --- .../associated-types-match-despite-generic.rs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/ui/associated-types/associated-types-match-despite-generic.rs diff --git a/tests/ui/associated-types/associated-types-match-despite-generic.rs b/tests/ui/associated-types/associated-types-match-despite-generic.rs new file mode 100644 index 0000000000000..04fc374e59a0c --- /dev/null +++ b/tests/ui/associated-types/associated-types-match-despite-generic.rs @@ -0,0 +1,21 @@ +//! Regression test for . +//@compile-flags: -Znext-solver=globally +//@ check-pass + +struct Outer; +struct Inner; +trait Id { + type This; +} +impl Id for T { + type This = T; +} + +fn free(x: T) -> >::This +where + >::This: Id>::This>, +{ + x +} + +fn main() {} From 0aee3f14b04da05bff4c52f357c415a26c4978d9 Mon Sep 17 00:00:00 2001 From: kulinsky Date: Fri, 11 Sep 2026 23:45:55 +0500 Subject: [PATCH 2/4] Add a UI regression test. A `link_section` attribute is applied to a foreign static. The UI test checks for a warning. --- tests/ui/attributes/positions/link-section.rs | 11 +++++++++++ tests/ui/attributes/positions/link-section.stderr | 12 ++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/ui/attributes/positions/link-section.rs create mode 100644 tests/ui/attributes/positions/link-section.stderr diff --git a/tests/ui/attributes/positions/link-section.rs b/tests/ui/attributes/positions/link-section.rs new file mode 100644 index 0000000000000..a7d39b690664c --- /dev/null +++ b/tests/ui/attributes/positions/link-section.rs @@ -0,0 +1,11 @@ +//! Checks that `link_section` cannot be used on foreign statics. +#![crate_type = "lib"] + +//@ edition:2024 +//@ check-pass +// Regression test for . +unsafe extern "C" { + #[unsafe(link_section = "__DATA,__buffer")] //~ WARN attribute cannot be used on foreign statics + //~| WARN previously accepted + pub static mut a: [u8; 1024]; +} diff --git a/tests/ui/attributes/positions/link-section.stderr b/tests/ui/attributes/positions/link-section.stderr new file mode 100644 index 0000000000000..56aa525e72387 --- /dev/null +++ b/tests/ui/attributes/positions/link-section.stderr @@ -0,0 +1,12 @@ +warning: the `link_section` attribute cannot be used on foreign statics + --> $DIR/link-section.rs:8:14 + | +LL | #[unsafe(link_section = "__DATA,__buffer")] + | ^^^^^^^^^^^^ + | + = help: the `link_section` attribute can be applied to functions and statics + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: requested on the command line with `-W unused-attributes` + +warning: 1 warning emitted + From 75d7c935f6cfb5540b58a6817f359897c3fca76f Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sun, 13 Sep 2026 13:50:23 +1000 Subject: [PATCH 3/4] Make the LLVM version-check bindings safe --- compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs | 4 ++-- compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 10 +++++++--- .../rustc_codegen_llvm/src/llvm/offload_ffi.rs | 4 ++-- compiler/rustc_codegen_llvm/src/llvm_util.rs | 14 ++++++-------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs index 68ec7870811d2..94df0fc270255 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs @@ -97,7 +97,7 @@ pub(crate) mod Enzyme_AD { use rustc_session::filesearch; use super::{CConcreteType, CTypeTreeRef, Context}; - use crate::llvm::{EnzymeTypeTree, LLVMRustVersionMajor}; + use crate::llvm::{self, EnzymeTypeTree}; type EnzymeSetCLBoolFn = unsafe extern "C" fn(*mut c_void, u8); type EnzymeSetCLStringFn = unsafe extern "C" fn(*mut c_void, *const c_char); @@ -434,7 +434,7 @@ pub(crate) mod Enzyme_AD { } fn get_enzyme_path(sysroot: &Sysroot) -> Result { - let llvm_version_major = unsafe { LLVMRustVersionMajor() }; + let llvm_version_major = llvm::LLVMRustVersionMajor(); let path_buf = sysroot .all_paths() diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index c20b4ccd776da..abacef3710f4e 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -894,7 +894,11 @@ unsafe extern "C" { SLen: c_uint, ) -> MetadataKindId; - pub(crate) fn LLVMGetVersion(major: &mut c_uint, minor: &mut c_uint, patch: &mut c_uint); + /// Gets the actual version of LLVM that we are linked to at runtime. + /// + /// # Safety + /// Can be called without initializing LLVM. + pub(crate) safe fn LLVMGetVersion(major: &mut c_uint, minor: &mut c_uint, patch: &mut c_uint); pub(crate) fn LLVMDisposeTargetMachine(T: ptr::NonNull); @@ -2176,9 +2180,9 @@ unsafe extern "C" { /// Returns the LLVM major version that the compiler was built with. /// /// Note that this is hard-coded as `LLVM_VERSION_MAJOR` when `RustWrapper.cpp` is built. This - /// could be different than what the runtime LLVM library reports in `LLVMGetVersion`, so we + /// could be different than what the runtime LLVM library reports in [`LLVMGetVersion`], so we /// assert their equality in `configure_llvm`. - pub(crate) fn LLVMRustVersionMajor() -> u32; + pub(crate) safe fn LLVMRustVersionMajor() -> u32; /// Add LLVM module flags. /// diff --git a/compiler/rustc_codegen_llvm/src/llvm/offload_ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/offload_ffi.rs index 7ecf450ab1dba..fecb9e40eab88 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/offload_ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/offload_ffi.rs @@ -14,7 +14,7 @@ use rustc_fs_util::path_to_c_string; use rustc_session::config::host_tuple; use rustc_session::filesearch; -use crate::llvm::LLVMRustVersionMajor; +use crate::llvm; pub(crate) struct RustOffloadWrapper { LLVMRustBundleImages: LLVMRustBundleImagesFn, @@ -119,7 +119,7 @@ impl RustOffloadWrapper { fn get_offload_and_lld_paths( sysroot: &rustc_session::config::Sysroot, ) -> Result<(PathBuf, Option), RustOffloadLibraryError> { - let llvm_version_major = unsafe { LLVMRustVersionMajor() }; + let llvm_version_major = llvm::LLVMRustVersionMajor(); let mut searched = Vec::new(); for root in sysroot.all_paths() { diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index a5441b1ef1135..223cbf2aae31f 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -459,15 +459,13 @@ pub(crate) fn print_version() { println!("LLVM version: {major}.{minor}.{patch}"); } +/// Returns the version of LLVM that we are actually linked to at runtime. pub(crate) fn get_version() -> (u32, u32, u32) { - // Can be called without initializing LLVM - unsafe { - let mut llvm_major = 0; - let mut llvm_minor = 0; - let mut llvm_patch = 0; - llvm::LLVMGetVersion(&mut llvm_major, &mut llvm_minor, &mut llvm_patch); - (llvm_major, llvm_minor, llvm_patch) - } + let mut llvm_major = 0; + let mut llvm_minor = 0; + let mut llvm_patch = 0; + llvm::LLVMGetVersion(&mut llvm_major, &mut llvm_minor, &mut llvm_patch); + (llvm_major, llvm_minor, llvm_patch) } pub(crate) fn print_passes() { From dff85fd214300896667c8148bc0485a82d4e4b10 Mon Sep 17 00:00:00 2001 From: Yusuf Efe <120668197+yuefdev@users.noreply.github.com> Date: Sun, 13 Sep 2026 15:10:55 +0300 Subject: [PATCH 4/4] Fix typo in riscv64a23-unknown-linux-gnu platform docs --- .../rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md b/src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md index df0c971f249a4..b50ee50db9b11 100644 --- a/src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md +++ b/src/doc/rustc/src/platform-support/riscv64a23-unknown-linux-gnu.md @@ -12,7 +12,7 @@ This target will enable all mandatory features of rva23u64 by default. ## Requirements -This target can be sucessfully build on the following platform: ubuntu 24.04 (Linux Kernel version 6.8.0, glibc 2.39). +This target can be successfully built on the following platform: ubuntu 24.04 (Linux Kernel version 6.8.0, glibc 2.39). Other platforms may work, but are not tested. Please contact us if you encounter any issues.