Skip to content

Commit ad05d72

Browse files
authored
Rollup merge of rust-lang#148118 - saethlin:nullary-intrinsic-check-bug-msg, r=Noratrieb,dianqk
Improve the ICE message for invalid nullary intrinsic calls In rust-lang#148104, we found the panic message here rather confusing, and (if I'm reading the tea leaves right) that's because the intended audience for either side of the phrase is very different. I think this is more clear if/when this is encountered by users. I expect this ICE to be hit in practice by people calling the `size_of` and `align_of` intrinsics, so it's now _kind of_ helpful for those users too. The original effort to stop backends from needing to support nullary intrinsics added a note to all these const-only intrinsics, but when rust-lang#147793 ported two more the paragraph wasn't added. I've added it.
2 parents ce33db0 + ba3a447 commit ad05d72

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

core/src/intrinsics/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2728,6 +2728,11 @@ pub unsafe fn vtable_align(ptr: *const ()) -> usize;
27282728
/// More specifically, this is the offset in bytes between successive
27292729
/// items of the same type, including alignment padding.
27302730
///
2731+
/// Note that, unlike most intrinsics, this can only be called at compile-time
2732+
/// as backends do not have an implementation for it. The only caller (its
2733+
/// stable counterpart) wraps this intrinsic call in a `const` block so that
2734+
/// backends only see an evaluated constant.
2735+
///
27312736
/// The stabilized version of this intrinsic is [`core::mem::size_of`].
27322737
#[rustc_nounwind]
27332738
#[unstable(feature = "core_intrinsics", issue = "none")]
@@ -2742,6 +2747,11 @@ pub const fn size_of<T>() -> usize;
27422747
/// Therefore, implementations must not require the user to uphold
27432748
/// any safety invariants.
27442749
///
2750+
/// Note that, unlike most intrinsics, this can only be called at compile-time
2751+
/// as backends do not have an implementation for it. The only caller (its
2752+
/// stable counterpart) wraps this intrinsic call in a `const` block so that
2753+
/// backends only see an evaluated constant.
2754+
///
27452755
/// The stabilized version of this intrinsic is [`core::mem::align_of`].
27462756
#[rustc_nounwind]
27472757
#[unstable(feature = "core_intrinsics", issue = "none")]

0 commit comments

Comments
 (0)