This commit is contained in:
0rphon 2022-03-15 17:15:08 -07:00
parent d25eb79594
commit 82ce58544b
7 changed files with 15 additions and 24 deletions

View File

@ -48,8 +48,8 @@ fn main() -> Result<(), String> {
let input_tree = create_session_if_not_set_then(|_| {
Handler::with(|handler| {
let input =
leo_parser::parse_program_inputs(&handler, input_string.clone(), opt.input_path.to_str().unwrap())?;
Ok(input.to_json_string()?)
leo_parser::parse_program_inputs(handler, input_string.clone(), opt.input_path.to_str().unwrap())?;
input.to_json_string()
})
.map_err(|e| e.to_string())
})?;

View File

@ -47,7 +47,7 @@ fn main() -> Result<(), String> {
// Parses the Leo file constructing an ast which is then serialized.
let serialized_leo_tree = create_session_if_not_set_then(|_| {
Handler::with(|h| {
let ast = leo_parser::parse_ast(&h, opt.input_path.to_str().unwrap(), &code)?;
let ast = leo_parser::parse_ast(h, opt.input_path.to_str().unwrap(), &code)?;
let json = Ast::to_json_string(&ast)?;
println!("{}", json);
Ok(json)

View File

@ -221,29 +221,27 @@ impl<'a> ParserContext<'a> {
}
let second = self.peek_group_coordinate(&mut i)?;
let right_paren_span;
i = i.checked_sub(1)?;
if let Some(SpannedToken {
let right_paren_span = if let Some(SpannedToken {
token: Token::RightParen,
span,
}) = self.tokens.get(i)
{
right_paren_span = span.clone();
span.clone()
} else {
return None;
}
};
let end_span;
i = i.checked_sub(1)?;
if let Some(SpannedToken {
let end_span = if let Some(SpannedToken {
token: Token::Group,
span,
}) = self.tokens.get(i)
{
end_span = span.clone();
span.clone()
} else {
return None;
}
};
self.tokens.drain(i..);
if let Err(e) = assert_no_whitespace(

View File

@ -422,7 +422,7 @@ impl Token {
eol + 4
} else {
return Err(ParserError::lexer_block_comment_does_not_close_before_eof(
String::from_utf8_lossy(&input),
String::from_utf8_lossy(input),
)
.into());
};
@ -515,7 +515,7 @@ impl Token {
));
}
Err(ParserError::could_not_lex(String::from_utf8_lossy(&input)).into())
Err(ParserError::could_not_lex(String::from_utf8_lossy(input)).into())
}
}

View File

@ -238,8 +238,8 @@ impl TryFrom<&Path> for Manifest {
// Fetch the author from the old remote.
let remote_author = old_remote
.split('/') // Split the old remote as '"{author}' and '{package_name}"'
.nth(0).unwrap() // Fetch just the '"{author}'
.replace(&['\"', ' '], ""); // Remove the quotes from the author string
.next().unwrap() // Fetch just the '"{author}'
.replace(['\"', ' '].as_slice(), ""); // Remove the quotes from the author string
// Construct the new remote section.
let new_remote = format!(

View File

@ -21,7 +21,7 @@ use tendril::StrTendril;
/// Serialization for the StrTendril type.
pub fn serialize<S: Serializer>(tendril: &StrTendril, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_str(&tendril)
serializer.serialize_str(tendril)
}
/// Deserialization for the StrTendril type.

View File

@ -70,14 +70,7 @@ fn take_hook(
output: Result<Result<Value, String>, Box<dyn Any + Send>>,
panic_buf: Arc<Mutex<Option<String>>>,
) -> Result<Result<Value, String>, String> {
output.map_err(|_| {
panic_buf
.lock()
.unwrap()
.take()
.expect("failed to get panic message")
.clone()
})
output.map_err(|_| panic_buf.lock().unwrap().take().expect("failed to get panic message"))
}
pub fn run_tests<T: Runner>(runner: &T, expectation_category: &str) {