From ec8ca29920d975ebcee6ecc290bc70be4e7e8fa9 Mon Sep 17 00:00:00 2001 From: Ceri Storey Date: Sat, 27 Mar 2021 09:47:52 +0000 Subject: Remove redundant semicolons in derived StaticType implementation. --- dhall_proc_macros/src/derive.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dhall_proc_macros/src/derive.rs b/dhall_proc_macros/src/derive.rs index e484ec6..27d911f 100644 --- a/dhall_proc_macros/src/derive.rs +++ b/dhall_proc_macros/src/derive.rs @@ -150,7 +150,7 @@ pub fn derive_static_type_inner( quote_spanned! {ty.span()=> struct #assert_name #impl_generics #local_where_clause { _phantom: std::marker::PhantomData<(#(#phantoms),*)> - }; + } } }); -- cgit v1.2.3 From 87c120d6b728099cffc547d340ea4c4cc304acf9 Mon Sep 17 00:00:00 2001 From: Ceri Storey Date: Sat, 27 Mar 2021 09:48:05 +0000 Subject: Remove a redundant semicolon in a test for good measure. --- serde_dhall/tests/traits.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/serde_dhall/tests/traits.rs b/serde_dhall/tests/traits.rs index 3c6fbfe..ed768c1 100644 --- a/serde_dhall/tests/traits.rs +++ b/serde_dhall/tests/traits.rs @@ -54,7 +54,7 @@ fn test_static_type() { enum E { A(T), B(String), - }; + } assert_eq!(>::static_type(), parse("< A: Bool | B: Text >")); #[derive(StaticType)] @@ -62,6 +62,6 @@ fn test_static_type() { enum F { A, B(bool), - }; + } assert_eq!(F::static_type(), parse("< A | B: Bool >")); } -- cgit v1.2.3 From 6053e48575cf3b421f3eb8a6af33c853a518d9c9 Mon Sep 17 00:00:00 2001 From: Ceri Storey Date: Sat, 27 Mar 2021 10:10:54 +0000 Subject: Replace a bunch of Err(…)? and format!("constant") calls. --- dhall/src/semantics/resolve/resolve.rs | 2 +- dhall/src/semantics/tck/typecheck.rs | 2 +- dhall/tests/spec.rs | 46 ++++++++++++++++++++++------------ 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, 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::() { - Some(err) => match err.kind() { + if let Some(err) = err.downcast_ref::() { + 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)?; } -- cgit v1.2.3 From 1cbee42df4868a92de5b18a174592497d451a814 Mon Sep 17 00:00:00 2001 From: Ceri Storey Date: Sat, 27 Mar 2021 10:47:00 +0000 Subject: Avoid ambiguity from use of Itertools::intersperse. --- dhall/src/builtins.rs | 7 ++++--- dhall/src/syntax/text/parser.rs | 4 +--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dhall/src/builtins.rs b/dhall/src/builtins.rs index 123e03d..82cb5ff 100644 --- a/dhall/src/builtins.rs +++ b/dhall/src/builtins.rs @@ -451,9 +451,10 @@ fn apply_builtin<'cx>( ); Ret::Nir(Nir::from_kind(NirKind::TextLit( - nze::nir::TextLit::new( - parts.intersperse(replacement), - ), + nze::nir::TextLit::new(Itertools::intersperse( + parts, + replacement, + )), ))) } } else { diff --git a/dhall/src/syntax/text/parser.rs b/dhall/src/syntax/text/parser.rs index 07921b5..d17ac61 100644 --- a/dhall/src/syntax/text/parser.rs +++ b/dhall/src/syntax/text/parser.rs @@ -279,9 +279,7 @@ impl DhallParser { trim_indent(&mut lines); - lines - .into_iter() - .intersperse(newline) + Itertools::intersperse(lines.into_iter(), newline) .flat_map(InterpolatedText::into_iter) .collect::() } -- cgit v1.2.3 From c331dcfaed6177a322de50fed418aa619210e88b Mon Sep 17 00:00:00 2001 From: Ceri Storey Date: Sat, 3 Apr 2021 13:28:11 +0100 Subject: Ignore clippy's needless question mark lint for the ast visitor macros. --- dhall/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs index 86ef99e..fb35b75 100644 --- a/dhall/src/lib.rs +++ b/dhall/src/lib.rs @@ -7,7 +7,8 @@ clippy::new_without_default, clippy::try_err, clippy::unnecessary_wraps, - clippy::useless_format + clippy::useless_format, + clippy::needless_question_mark, )] pub mod builtins; -- cgit v1.2.3