diff --git a/src/Init/Data/UInt/Basic.lean b/src/Init/Data/UInt/Basic.lean index 263a9919ec..1c6b76acff 100644 --- a/src/Init/Data/UInt/Basic.lean +++ b/src/Init/Data/UInt/Basic.lean @@ -268,6 +268,9 @@ def USize.shiftRight (a b : USize) : USize := ⟨a.toBitVec >>> (mod b (USize.of def UInt32.toUSize (a : UInt32) : USize := USize.ofNat32 a.toBitVec.toNat a.toBitVec.isLt @[extern "lean_usize_to_uint32"] def USize.toUInt32 (a : USize) : UInt32 := a.toNat.toUInt32 +/-- Converts a `UInt64` to a `USize` by reducing modulo `USize.size`. -/ +@[extern "lean_uint64_to_usize"] +def UInt64.toUSize (a : UInt64) : USize := a.toNat.toUSize instance : Mul USize := ⟨USize.mul⟩ instance : Mod USize := ⟨USize.mod⟩ diff --git a/src/Init/Prelude.lean b/src/Init/Prelude.lean index 35fd5c7ca4..5201230729 100644 --- a/src/Init/Prelude.lean +++ b/src/Init/Prelude.lean @@ -3432,10 +3432,6 @@ class Hashable (α : Sort u) where export Hashable (hash) -/-- Converts a `UInt64` to a `USize` by reducing modulo `USize.size`. -/ -@[extern "lean_uint64_to_usize"] -opaque UInt64.toUSize (u : UInt64) : USize - /-- Upcast a `USize` to a `UInt64`. This is lossless because `USize.size` is either `2^32` or `2^64`.