Skip to content

Commit 45b4c7a

Browse files
scottmcmgitbot
authored and
gitbot
committed
PR feedback
1 parent d7242d6 commit 45b4c7a

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

Diff for: core/src/intrinsics/fallback.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,8 @@ impl const CarryingMulAdd for i128 {
114114
#[const_trait]
115115
#[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")]
116116
pub trait DisjointBitOr: Copy + 'static {
117-
/// This is always just `assume((self & other) == 0); self | other`.
118-
///
119-
/// It's essential that the assume is there so that this is sufficient to
120-
/// specify the UB for MIRI, rather than it needing to re-implement it.
121-
///
122-
/// # Safety
123-
/// See [`super::disjoint_bitor`].
117+
/// See [`super::disjoint_bitor`]; we just need the trait indirection to handle
118+
/// different types since calling intrinsics with generics doesn't work.
124119
unsafe fn disjoint_bitor(self, other: Self) -> Self;
125120
}
126121
macro_rules! zero {
@@ -135,8 +130,11 @@ macro_rules! impl_disjoint_bitor {
135130
($($t:ident,)+) => {$(
136131
#[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")]
137132
impl const DisjointBitOr for $t {
133+
#[cfg_attr(miri, track_caller)]
138134
#[inline]
139135
unsafe fn disjoint_bitor(self, other: Self) -> Self {
136+
// Note that the assume here is required for UB detection in Miri!
137+
140138
// SAFETY: our precondition is that there are no bits in common,
141139
// so this is just telling that to the backend.
142140
unsafe { super::assume((self & other) == zero!($t)) };

Diff for: core/src/intrinsics/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3257,7 +3257,8 @@ pub const fn three_way_compare<T: Copy>(_lhs: T, _rhss: T) -> crate::cmp::Orderi
32573257
#[rustc_const_unstable(feature = "disjoint_bitor", issue = "135758")]
32583258
#[rustc_nounwind]
32593259
#[cfg_attr(not(bootstrap), rustc_intrinsic)]
3260-
#[miri::intrinsic_fallback_is_spec] // the fallbacks all `assume` to tell MIRI
3260+
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
3261+
#[miri::intrinsic_fallback_is_spec] // the fallbacks all `assume` to tell Miri
32613262
pub const unsafe fn disjoint_bitor<T: ~const fallback::DisjointBitOr>(a: T, b: T) -> T {
32623263
// SAFETY: same preconditions as this function.
32633264
unsafe { fallback::DisjointBitOr::disjoint_bitor(a, b) }

Diff for: core/src/num/uint_macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ macro_rules! uint_impl {
12131213
///
12141214
/// # Safety
12151215
///
1216-
/// Requires that `(self | other) == 0`, otherwise it's immediate UB.
1216+
/// Requires that `(self & other) == 0`, otherwise it's immediate UB.
12171217
///
12181218
/// Equivalently, requires that `(self | other) == (self + other)`.
12191219
#[unstable(feature = "disjoint_bitor", issue = "135758")]

0 commit comments

Comments
 (0)