From 1e1bf0d1fc603c6586076c9e2f92cc7931a1f83d Mon Sep 17 00:00:00 2001 From: Derek Benson Date: Fri, 26 Jul 2024 11:07:22 -0700 Subject: [PATCH] Move the declaration of the upb map begin constant into rust PiperOrigin-RevId: 656463679 --- rust/upb.rs | 3 +-- rust/upb/lib.rs | 2 +- rust/upb/map.rs | 4 ++-- rust/upb/upb_api.c | 2 -- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/rust/upb.rs b/rust/upb.rs index eda6fc4e27..b90de06d41 100644 --- a/rust/upb.rs +++ b/rust/upb.rs @@ -682,8 +682,7 @@ pub struct RawMapIter { impl RawMapIter { pub fn new(_private: Private, map: RawMap) -> Self { - // SAFETY: __rust_proto_kUpb_Map_Begin is never modified - RawMapIter { map, iter: unsafe { __rust_proto_kUpb_Map_Begin } } + RawMapIter { map, iter: UPB_MAP_BEGIN } } /// # Safety diff --git a/rust/upb/lib.rs b/rust/upb/lib.rs index 3511918b3c..84b09fc5de 100644 --- a/rust/upb/lib.rs +++ b/rust/upb/lib.rs @@ -27,7 +27,7 @@ pub use extension_registry::{upb_ExtensionRegistry, RawExtensionRegistry}; mod map; pub use map::{ upb_Map, upb_Map_Clear, upb_Map_Delete, upb_Map_Get, upb_Map_Insert, upb_Map_New, upb_Map_Next, - upb_Map_Size, MapInsertStatus, RawMap, __rust_proto_kUpb_Map_Begin, + upb_Map_Size, MapInsertStatus, RawMap, UPB_MAP_BEGIN, }; mod message; diff --git a/rust/upb/map.rs b/rust/upb/map.rs index 5b60149a74..5b3a8d7bbb 100644 --- a/rust/upb/map.rs +++ b/rust/upb/map.rs @@ -21,9 +21,9 @@ pub enum MapInsertStatus { OutOfMemory = 2, } -extern "C" { - pub static __rust_proto_kUpb_Map_Begin: usize; +pub const UPB_MAP_BEGIN: usize = usize::MAX; +extern "C" { pub fn upb_Map_New(arena: RawArena, key_type: CType, value_type: CType) -> RawMap; pub fn upb_Map_Size(map: RawMap) -> usize; pub fn upb_Map_Insert( diff --git a/rust/upb/upb_api.c b/rust/upb/upb_api.c index 16cc9e081c..2b23a52e17 100644 --- a/rust/upb/upb_api.c +++ b/rust/upb/upb_api.c @@ -21,5 +21,3 @@ #include "upb/mini_table/message.h" // IWYU pragma: keep #include "upb/text/debug_string.h" // IWYU pragma: keep // go/keep-sorted end - -const size_t __rust_proto_kUpb_Map_Begin = kUpb_Map_Begin;