Skip to content

Commit

Permalink
[move-compiler] No need to ever return diags when parsing a file (#18301
Browse files Browse the repository at this point in the history
)

## Description 

This fixes a minor compiler implementation issue reported in
#18285 (the `parse_file`
function no longer needs to return `Result` as diagnostics previously
returned as part of it are instead added to the compilation context).

## Test plan 

All existing tests must pass
  • Loading branch information
awelc authored Jun 19, 2024
1 parent 7c44548 commit 303563e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions external-crates/move/crates/move-compiler/src/parser/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4542,7 +4542,7 @@ fn consume_spec_string(context: &mut Context) -> Result<Spanned<String>, Box<Dia
// Parse a file:
// File =
// (<Attributes> (<AddressBlock> | <Module> ))*
fn parse_file(context: &mut Context) -> Result<Vec<Definition>, Box<Diagnostic>> {
fn parse_file(context: &mut Context) -> Vec<Definition> {
let mut defs = vec![];
while context.tokens.peek() != Tok::EOF {
if let Err(diag) = parse_file_def(context, &mut defs) {
Expand All @@ -4552,7 +4552,7 @@ fn parse_file(context: &mut Context) -> Result<Vec<Definition>, Box<Diagnostic>>
skip_to_next_desired_tok_or_eof(context, &TokenSet::from(&[Tok::Spec, Tok::Module]));
}
}
Ok(defs)
defs
}

fn parse_file_def(
Expand Down Expand Up @@ -4608,8 +4608,8 @@ pub fn parse_file_string(
Err(err) => Err(Diagnostics::from(vec![*err])),
Ok(..) => Ok(()),
}?;
match parse_file(&mut Context::new(env, &mut tokens, package)) {
Err(err) => Err(Diagnostics::from(vec![*err])),
Ok(def) => Ok((def, tokens.check_and_get_doc_comments(env))),
}
Ok((
parse_file(&mut Context::new(env, &mut tokens, package)),
tokens.check_and_get_doc_comments(env),
))
}

0 comments on commit 303563e

Please sign in to comment.