From c14b4e95ea099e6654b4ff411fb3fd08fe7f65e9 Mon Sep 17 00:00:00 2001 From: George Mitenkov Date: Wed, 6 Nov 2024 20:01:31 +0000 Subject: [PATCH] [move] Remove SignatureTokenKind (#15211) --- .../move-binary-format/src/file_format.rs | 32 ++----------------- .../move/move-binary-format/src/lib.rs | 26 --------------- .../move/move-binary-format/src/views.rs | 7 +--- 3 files changed, 3 insertions(+), 62 deletions(-) diff --git a/third_party/move/move-binary-format/src/file_format.rs b/third_party/move/move-binary-format/src/file_format.rs index 8730f84299ecf..538a588439c54 100644 --- a/third_party/move/move-binary-format/src/file_format.rs +++ b/third_party/move/move-binary-format/src/file_format.rs @@ -34,7 +34,7 @@ use crate::{ errors::{PartialVMError, PartialVMResult}, file_format_common, internals::ModuleIndex, - IndexKind, SignatureTokenKind, + IndexKind, }; use move_bytecode_spec::bytecode_spec; use move_core_types::{ @@ -1315,35 +1315,7 @@ impl std::fmt::Debug for SignatureToken { } impl SignatureToken { - /// Returns the "value kind" for the `SignatureToken` - #[inline] - pub fn signature_token_kind(&self) -> SignatureTokenKind { - // TODO: SignatureTokenKind is out-dated. fix/update/remove SignatureTokenKind and see if - // this function needs to be cleaned up - use SignatureToken::*; - - match self { - Reference(_) => SignatureTokenKind::Reference, - MutableReference(_) => SignatureTokenKind::MutableReference, - Bool - | U8 - | U16 - | U32 - | U64 - | U128 - | U256 - | Address - | Signer - | Struct(_) - | StructInstantiation(_, _) - | Vector(_) => SignatureTokenKind::Value, - // TODO: This is a temporary hack to please the verifier. SignatureTokenKind will soon - // be completely removed. `SignatureTokenView::kind()` should be used instead. - TypeParameter(_) => SignatureTokenKind::Value, - } - } - - // Returns `true` if the `SignatureToken` is an integer type. + /// Returns true if the token is an integer type. pub fn is_integer(&self) -> bool { use SignatureToken::*; match self { diff --git a/third_party/move/move-binary-format/src/lib.rs b/third_party/move/move-binary-format/src/lib.rs index d9dc260cb1f42..9ffa05af1f817 100644 --- a/third_party/move/move-binary-format/src/lib.rs +++ b/third_party/move/move-binary-format/src/lib.rs @@ -132,32 +132,6 @@ impl fmt::Display for IndexKind { } } -// TODO: is this outdated? -/// Represents the kind of a signature token. -#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] -pub enum SignatureTokenKind { - /// Any sort of owned value that isn't an array (Integer, Bool, Struct etc). - Value, - /// A reference. - Reference, - /// A mutable reference. - MutableReference, -} - -impl fmt::Display for SignatureTokenKind { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use SignatureTokenKind::*; - - let desc = match self { - Value => "value", - Reference => "reference", - MutableReference => "mutable reference", - }; - - f.write_str(desc) - } -} - /// A macro which should be preferred in critical runtime paths for unwrapping an option /// if a `PartialVMError` is expected. In debug mode, this will panic. Otherwise /// we return an Err. diff --git a/third_party/move/move-binary-format/src/views.rs b/third_party/move/move-binary-format/src/views.rs index d2952dd646d4c..60e3988260782 100644 --- a/third_party/move/move-binary-format/src/views.rs +++ b/third_party/move/move-binary-format/src/views.rs @@ -12,7 +12,7 @@ //! immediately -- the views are a convenience to make that simpler. They've been written as lazy //! iterators to aid understanding of the file format and to make it easy to generate views. -use crate::{access::ModuleAccess, file_format::*, SignatureTokenKind}; +use crate::{access::ModuleAccess, file_format::*}; use move_core_types::{identifier::IdentStr, language_storage::ModuleId}; use std::{ collections::{BTreeMap, BTreeSet}, @@ -685,11 +685,6 @@ impl<'a, T: ModuleAccess> SignatureTokenView<'a, T> { self.token } - #[inline] - pub fn signature_token_kind(&self) -> SignatureTokenKind { - self.token.signature_token_kind() - } - #[inline] pub fn is_reference(&self) -> bool { self.token.is_reference()