message: Brute-force an implementation of cli::check
diff: @@ -10,6 +10,42 @@ pub struct Opts {
  }
  /// Run the `check` subcommand with the given options
  -pub fn run(_check_opts: Opts) -> Result<(), Error> {
  - unimplemented!()
  +pub fn run(opts: Opts) -> Result<(), Error> {
  + use codespan::CodeMap;
  + use codespan_reporting;
  +
  + use semantics;
  + use syntax::parse;
  + use syntax::translation::ToCore;
  +
  + let mut codemap = CodeMap::new();
  +
  + let mut is_error = false;
  + for path in opts.files {
  + let file = codemap.add_filemap_from_disk(path)?;
  + let (module, parse_errors) = parse::module(&file);
  +
  + let mut is_parse_error = false;
  + for error in parse_errors {
  + codespan_reporting::emit(&codemap, &error.to_diagnostic());
  + is_error = true;
  + is_parse_error = true;
  + }
  + if is_parse_error {
  + continue;
  + }
  +
  + match semantics::check_module(&module.to_core()) {
  + Ok(_module) => {},
  + Err(err) => {
  + codespan_reporting::emit(&codemap, &err.to_diagnostic());
  + is_error = true;
  + },
  + }
  + }
  + if is_error {
  + Err(format_err!("encountered an error!"))
  + } else {
  + Ok(())
  + }
  }
  