message: Result handling cleanups
diff: @@ -29,22 +29,19 @@ pub mod cli;
  use codespan::FileMap;
  use codespan_reporting::Diagnostic;
  -use syntax::core::Module;
  +use syntax::core;
  -pub fn load_file(file: &FileMap) -> Result<Module, Vec<Diagnostic>> {
  +pub fn load_file(file: &FileMap) -> Result<core::Module, Vec<Diagnostic>> {
  use syntax::translation::Desugar;
  - let mut diagnostics = Vec::new();
  -
  let (module, errors) = syntax::parse::module(&file);
  - diagnostics.extend(errors.iter().map(|err| err.to_diagnostic()));
  + let mut diagnostics = errors
  + .iter()
  + .map(|err| err.to_diagnostic())
  + .collect::<Vec<_>>();
  - let module = module.desugar();
  - match semantics::check_module(&module) {
  - Ok(module) => Ok(module),
  - Err(err) => {
  + semantics::check_module(&module.desugar()).map_err(|err| {
  diagnostics.push(err.to_diagnostic());
  - Err(diagnostics)
  - },
  - }
  + diagnostics
  + })
  }
  