Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion external-crates/move/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion external-crates/move/crates/move-core-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ bcs.workspace = true
leb128.workspace = true
thiserror.workspace = true
serde_with.workspace = true
num-bigint.workspace = true

[dev-dependencies]
proptest.workspace = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
account_address::AccountAddress,
gas_algebra::{AbstractMemorySize, BOX_ABSTRACT_SIZE, ENUM_BASE_ABSTRACT_SIZE},
identifier::{IdentStr, Identifier},
parsing::types::{ParsedStructType, ParsedType},
parsing::types::{ParsedModuleId, ParsedStructType, ParsedType},
};
use move_proc_macros::test_variant_order;
use once_cell::sync::Lazy;
Expand Down Expand Up @@ -327,6 +327,13 @@ impl Display for ModuleId {
}
}

impl FromStr for ModuleId {
type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
ParsedModuleId::parse(s)?.into_module_id(&|_| None)
}
}

impl ModuleId {
pub fn short_str_lossless(&self) -> String {
format!("0x{}::{}", self.address.short_str_lossless(), self.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::account_address::AccountAddress;
use crate::parsing::parser::{parse_address_number, NumberFormat};
use anyhow::anyhow;
use num_bigint::BigUint;
use num::BigUint;
use std::{fmt, hash::Hash};

// Parsed Address, either a name or a numerical address
Expand Down
15 changes: 11 additions & 4 deletions external-crates/move/crates/move-core-types/src/parsing/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
u256::{U256FromStrError, U256},
};
use anyhow::{anyhow, bail, Result};
use num_bigint::BigUint;
use num::BigUint;
use std::{fmt::Display, iter::Peekable, num::ParseIntError};

const MAX_TYPE_DEPTH: u64 = 128;
Expand Down Expand Up @@ -76,7 +76,7 @@ impl<Extra: ParsableValue> ParsedValue<Extra> {
}
}

fn parse<'a, Tok: Token, R>(
pub(crate) fn parse<'a, Tok: Token, R>(
s: &'a str,
f: impl FnOnce(&mut Parser<'a, Tok, std::vec::IntoIter<(Tok, &'a str)>>) -> Result<R>,
) -> Result<R> {
Expand Down Expand Up @@ -139,8 +139,12 @@ impl<'a, Tok: Token, I: Iterator<Item = (Tok, &'a str)>> Parser<'a, Tok, I> {
break;
}
self.advance(delim)?;
if is_end(self.peek_tok()) && allow_trailing_delim {
break;
if is_end(self.peek_tok()) {
if allow_trailing_delim {
break;
} else {
bail!("Invalid type list: trailing delimiter '{}'", delim)
}
}
}
Ok(v)
Expand Down Expand Up @@ -225,6 +229,9 @@ impl<'a, I: Iterator<Item = (TypeToken, &'a str)>> Parser<'a, TypeToken, I> {
true,
)?;
self.advance(TypeToken::Gt)?;
if type_args.is_empty() {
bail!("expected at least one type argument")
}
type_args
}
_ => vec![],
Expand Down
Loading
Loading