From 5b32c5bdea80a0bdf19240f3cc2b8e2ae251d51a Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Wed, 6 Mar 2019 00:51:20 +0100 Subject: rustfmt --- dhall/src/main.rs | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'dhall/src/main.rs') diff --git a/dhall/src/main.rs b/dhall/src/main.rs index 58826bb..78a2905 100644 --- a/dhall/src/main.rs +++ b/dhall/src/main.rs @@ -1,5 +1,5 @@ -use std::io::{self, Read}; use std::error::Error; +use std::io::{self, Read}; use term_painter::ToStyle; use dhall::*; @@ -42,9 +42,13 @@ fn print_error(message: &str, source: &str, start: usize, end: usize) { BOLD.with(|| { print!("{:w$} |", "", w = line_number_width); ERROR_STYLE.with(|| { - println!(" {:so$}{:^>ew$}", "", "", - so = source[line_start..start].chars().count(), - ew = ::std::cmp::max(1, source[start..end].chars().count())); + println!( + " {:so$}{:^>ew$}", + "", + "", + so = source[line_start..start].chars().count(), + ew = ::std::cmp::max(1, source[start..end].chars().count()) + ); }); }); } @@ -54,12 +58,27 @@ fn main() { io::stdin().read_to_string(&mut buffer).unwrap(); let expr = match parser::parse_expr_lalrpop(&buffer) { Ok(e) => e, - Err(lalrpop_util::ParseError::User { error: lexer::LexicalError::Error(pos, e) }) => { - print_error(&format!("Unexpected token {:?}", e), &buffer, pos, pos); + Err(lalrpop_util::ParseError::User { + error: lexer::LexicalError::Error(pos, e), + }) => { + print_error( + &format!("Unexpected token {:?}", e), + &buffer, + pos, + pos, + ); return; } - Err(lalrpop_util::ParseError::UnrecognizedToken { token: Some((start, t, end)), expected: e }) => { - print_error(&format!("Unrecognized token {:?}", t), &buffer, start, end); + Err(lalrpop_util::ParseError::UnrecognizedToken { + token: Some((start, t, end)), + expected: e, + }) => { + print_error( + &format!("Unrecognized token {:?}", t), + &buffer, + start, + end, + ); if !e.is_empty() { println!("Expected {:?}", e); } -- cgit v1.2.3