summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCeri Storey2021-03-27 10:10:54 +0000
committerCeri Storey2021-03-27 10:51:05 +0000
commit6053e48575cf3b421f3eb8a6af33c853a518d9c9 (patch)
tree30f6cae538e59ef5e2f343dca9945a77e3e5b4d8
parent87c120d6b728099cffc547d340ea4c4cc304acf9 (diff)
Replace a bunch of Err(…)? and format!("constant") calls.
-rw-r--r--dhall/src/semantics/resolve/resolve.rs2
-rw-r--r--dhall/src/semantics/tck/typecheck.rs2
-rw-r--r--dhall/tests/spec.rs46
3 files changed, 32 insertions, 18 deletions
diff --git a/dhall/src/semantics/resolve/resolve.rs b/dhall/src/semantics/resolve/resolve.rs
index 7d74cd6..5ec16e5 100644
--- a/dhall/src/semantics/resolve/resolve.rs
+++ b/dhall/src/semantics/resolve/resolve.rs
@@ -558,7 +558,7 @@ pub fn skip_resolve<'cx>(
parsed: Parsed,
) -> Result<Resolved<'cx>, Error> {
let parsed = Parsed::from_expr_without_imports(parsed.0);
- Ok(resolve(cx, parsed)?)
+ resolve(cx, parsed)
}
impl Parsed {
diff --git a/dhall/src/semantics/tck/typecheck.rs b/dhall/src/semantics/tck/typecheck.rs
index 23c2bd2..b0a4f21 100644
--- a/dhall/src/semantics/tck/typecheck.rs
+++ b/dhall/src/semantics/tck/typecheck.rs
@@ -256,7 +256,7 @@ pub fn type_with<'cx, 'hir>(
HirKind::Expr(ExprKind::Let(binder, annot, val, body)) => {
let val_annot = annot
.as_ref()
- .map(|t| Ok(type_with(env, t, None)?.eval_to_type(env)?))
+ .map(|t| type_with(env, t, None)?.eval_to_type(env))
.transpose()?;
let val = type_with(env, &val, val_annot)?;
let val_nf = val.eval(env);
diff --git a/dhall/tests/spec.rs b/dhall/tests/spec.rs
index a0fe583..b6eeac7 100644
--- a/dhall/tests/spec.rs
+++ b/dhall/tests/spec.rs
@@ -103,7 +103,9 @@ impl TestFile {
TestFile::Source(_) => Parsed::parse_file(&self.path())?,
TestFile::Binary(_) => Parsed::parse_binary_file(&self.path())?,
TestFile::UI(_) => {
- Err(TestError(format!("Can't parse a UI test file")))?
+ return Err(
+ TestError("Can't parse a UI test file".to_string()).into()
+ )
}
})
}
@@ -138,9 +140,12 @@ impl TestFile {
let expr_data = binary::encode(&expr)?;
file.write_all(&expr_data)?;
}
- TestFile::UI(_) => Err(TestError(format!(
- "Can't write an expression to a UI file"
- )))?,
+ TestFile::UI(_) => {
+ return Err(TestError(
+ "Can't write an expression to a UI file".to_string(),
+ )
+ .into())
+ }
}
Ok(())
}
@@ -148,9 +153,12 @@ impl TestFile {
fn write_ui(&self, x: impl Display) -> Result<()> {
match self {
TestFile::UI(_) => {}
- _ => Err(TestError(format!(
- "Can't write a ui string to a dhall file"
- )))?,
+ _ => {
+ return Err(TestError(
+ "Can't write a ui string to a dhall file".to_string(),
+ )
+ .into())
+ }
}
let path = self.path();
create_dir_all(path.parent().unwrap())?;
@@ -195,7 +203,11 @@ impl TestFile {
pub fn compare_binary(&self, expr: Expr) -> Result<()> {
match self {
TestFile::Binary(_) => {}
- _ => Err(TestError(format!("This is not a binary file")))?,
+ _ => {
+ return Err(
+ TestError("This is not a binary file".to_string()).into()
+ )
+ }
}
if !self.path().is_file() {
return self.write_expr(expr);
@@ -593,17 +605,19 @@ fn run_test(test: &SpecTest) -> Result<()> {
ParserFailure => {
use std::io;
let err = unwrap_err(expr.parse())?;
- match err.downcast_ref::<DhallError>() {
- Some(err) => match err.kind() {
+ if let Some(err) = err.downcast_ref::<DhallError>() {
+ match err.kind() {
ErrorKind::Parse(_) => {}
ErrorKind::IO(e)
if e.kind() == io::ErrorKind::InvalidData => {}
- e => Err(TestError(format!(
- "Expected parse error, got: {:?}",
- e
- )))?,
- },
- None => {}
+ e => {
+ return Err(TestError(format!(
+ "Expected parse error, got: {:?}",
+ e
+ ))
+ .into())
+ }
+ }
}
expected.compare_ui(err)?;
}