From 7a0d9c8d5e5a0892e0739af12bd0063fd3bda480 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sat, 25 Oct 2025 17:59:22 -0400 Subject: [PATCH 1/2] Improve the ICE message for invalid nullary intrinsic calls --- compiler/rustc_codegen_ssa/src/mir/intrinsic.rs | 11 +++++++++-- library/core/src/intrinsics/mod.rs | 10 ++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs index befa00c6861ed..cc3316c7f8cc0 100644 --- a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs +++ b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs @@ -120,8 +120,15 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { | sym::atomic_singlethreadfence | sym::caller_location => {} _ => { - span_bug!(span, "nullary intrinsic {name} must either be in a const block or explicitly opted out because it is inherently a runtime intrinsic -"); + span_bug!( + span, + "Nullary intrinsic {name} must be called in a const block. \ + If you are seeing this message from code outside the standard library, the \ + unstable implementation details of the relevant intrinsic may have changed. \ + Consider using stable APIs instead. \ + If you are adding a new nullary intrinsic that is inherently a runtime \ + intrinsic, update this check." + ); } } } diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index c397e762d5589..c2da8a1a92096 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -2728,6 +2728,11 @@ pub unsafe fn vtable_align(ptr: *const ()) -> usize; /// More specifically, this is the offset in bytes between successive /// items of the same type, including alignment padding. /// +/// Note that, unlike most intrinsics, this can only be called at compile-time +/// as backends do not have an implementation for it. The only caller (its +/// stable counterpart) wraps this intrinsic call in a `const` block so that +/// backends only see an evaluated constant. +/// /// The stabilized version of this intrinsic is [`core::mem::size_of`]. #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] @@ -2742,6 +2747,11 @@ pub const fn size_of() -> usize; /// Therefore, implementations must not require the user to uphold /// any safety invariants. /// +/// Note that, unlike most intrinsics, this can only be called at compile-time +/// as backends do not have an implementation for it. The only caller (its +/// stable counterpart) wraps this intrinsic call in a `const` block so that +/// backends only see an evaluated constant. +/// /// The stabilized version of this intrinsic is [`core::mem::align_of`]. #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] From e873f13454946cd289c428976bef51b29bbc3508 Mon Sep 17 00:00:00 2001 From: George Tokmaji Date: Sun, 26 Oct 2025 10:53:13 +0100 Subject: [PATCH 2/2] Add myself as a windows-msvc maintainer --- src/doc/rustc/src/platform-support/windows-msvc.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/doc/rustc/src/platform-support/windows-msvc.md b/src/doc/rustc/src/platform-support/windows-msvc.md index 826c75b79c572..c4b56201e7968 100644 --- a/src/doc/rustc/src/platform-support/windows-msvc.md +++ b/src/doc/rustc/src/platform-support/windows-msvc.md @@ -12,6 +12,7 @@ Windows MSVC targets. [@ChrisDenton](https://github.com/ChrisDenton) [@dpaoliello](https://github.com/dpaoliello) +[@Fulgen301](https://github.com/Fulgen301) [@lambdageek](https://github.com/lambdageek) [@sivadeilra](https://github.com/sivadeilra) [@wesleywiser](https://github.com/wesleywiser)