summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--abnf_to_pest/src/lib.rs5
-rw-r--r--dhall/src/imports.rs3
-rw-r--r--dhall/src/lib.rs5
-rw-r--r--dhall/src/main.rs4
-rw-r--r--dhall/src/normalize.rs2
-rw-r--r--dhall/src/typecheck.rs2
-rw-r--r--dhall_core/src/core.rs2
-rw-r--r--dhall_core/src/lib.rs5
-rw-r--r--dhall_core/src/parser.rs19
-rw-r--r--dhall_generator/src/lib.rs15
10 files changed, 35 insertions, 27 deletions
diff --git a/abnf_to_pest/src/lib.rs b/abnf_to_pest/src/lib.rs
index 8d858bb..72746c0 100644
--- a/abnf_to_pest/src/lib.rs
+++ b/abnf_to_pest/src/lib.rs
@@ -1,3 +1,4 @@
+#![allow(clippy::implicit_hasher, clippy::or_fun_call)]
use itertools::Itertools;
use std::collections::HashMap;
@@ -16,7 +17,7 @@ impl Default for PestRuleSettings {
}
pub fn abnf_to_pest(
- data: &Vec<u8>,
+ data: &[u8],
rule_settings: &HashMap<String, PestRuleSettings>,
) -> std::io::Result<String> {
use abnf::abnf::*;
@@ -123,7 +124,7 @@ pub fn abnf_to_pest(
}
}
fn format_char(x: u64) -> String {
- if x <= (u8::max_value() as u64) {
+ if x <= u64::from(u8::max_value()) {
let x: u8 = x as u8;
if x.is_ascii_graphic() {
let x: char = x as char;
diff --git a/dhall/src/imports.rs b/dhall/src/imports.rs
index 007ed47..22f7863 100644
--- a/dhall/src/imports.rs
+++ b/dhall/src/imports.rs
@@ -78,8 +78,7 @@ pub fn load_dhall_file(
let resolve = |import: &Import| -> Expr<X, X> {
resolve_import(import, &root).unwrap()
};
- let expr = expr.map_embed(&resolve).squash_embed();
- expr
+ expr.map_embed(&resolve).squash_embed()
} else {
panic_imports(&expr)
};
diff --git a/dhall/src/lib.rs b/dhall/src/lib.rs
index 8add5b6..a8643bb 100644
--- a/dhall/src/lib.rs
+++ b/dhall/src/lib.rs
@@ -1,6 +1,11 @@
#![feature(box_patterns)]
#![feature(trace_macros)]
#![feature(proc_macro_hygiene)]
+#![allow(
+ clippy::type_complexity,
+ clippy::infallible_destructuring_match,
+ clippy::many_single_char_names
+)]
mod normalize;
pub use crate::normalize::*;
diff --git a/dhall/src/main.rs b/dhall/src/main.rs
index edc6baf..3328d99 100644
--- a/dhall/src/main.rs
+++ b/dhall/src/main.rs
@@ -28,7 +28,7 @@ fn print_error(message: &str, source: &str, start: usize, end: usize) {
BOLD.with(|| {
print!(" -->");
});
- println!(" {}:{}:0", "(stdin)", line_number);
+ println!(" (stdin):{}:0", line_number);
BOLD.with(|| {
println!("{:w$} |", "", w = line_number_width);
print!("{} |", line_number_str);
@@ -88,6 +88,6 @@ fn main() {
};
println!("{}", type_expr);
- println!("");
+ println!();
println!("{}", normalize::<_, X, _>(&expr));
}
diff --git a/dhall/src/normalize.rs b/dhall/src/normalize.rs
index b2ee0f6..c23f887 100644
--- a/dhall/src/normalize.rs
+++ b/dhall/src/normalize.rs
@@ -175,7 +175,7 @@ where
}
BinOp(ListAppend, box ListLit(t1, xs), box ListLit(t2, ys)) => {
// Drop type annotation if the result is nonempty
- let t = if xs.len() == 0 && ys.len() == 0 {
+ let t = if xs.is_empty() && ys.is_empty() {
t1.or(t2)
} else {
None
diff --git a/dhall/src/typecheck.rs b/dhall/src/typecheck.rs
index 28982fc..2916526 100644
--- a/dhall/src/typecheck.rs
+++ b/dhall/src/typecheck.rs
@@ -775,7 +775,7 @@ impl<S: Clone> TypeError<S> {
TypeError {
context: context.clone(),
current: current.clone(),
- type_message: type_message,
+ type_message,
}
}
}
diff --git a/dhall_core/src/core.rs b/dhall_core/src/core.rs
index 89fb6b9..e3e1f5c 100644
--- a/dhall_core/src/core.rs
+++ b/dhall_core/src/core.rs
@@ -97,7 +97,7 @@ impl Display for Label {
}
impl Label {
- pub fn from_str<'a>(s: &'a str) -> Label {
+ pub fn from_str(s: &str) -> Label {
s.to_owned().into()
}
}
diff --git a/dhall_core/src/lib.rs b/dhall_core/src/lib.rs
index 386d6bc..86b0363 100644
--- a/dhall_core/src/lib.rs
+++ b/dhall_core/src/lib.rs
@@ -1,5 +1,10 @@
#![feature(box_patterns)]
#![feature(trace_macros)]
+#![allow(
+ clippy::many_single_char_names,
+ clippy::should_implement_trait,
+ clippy::new_without_default
+)]
pub mod core;
pub use crate::core::*;
diff --git a/dhall_core/src/parser.rs b/dhall_core/src/parser.rs
index 2fa005a..357d006 100644
--- a/dhall_core/src/parser.rs
+++ b/dhall_core/src/parser.rs
@@ -28,7 +28,7 @@ fn debug_pair(pair: Pair<Rule>) -> String {
fn aux(s: &mut String, indent: usize, prefix: String, pair: Pair<Rule>) {
let indent_str = "| ".repeat(indent);
let rule = pair.as_rule();
- let contents = pair.as_str().clone();
+ let contents = pair.as_str();
let mut inner = pair.into_inner();
let mut first = true;
while let Some(p) = inner.next() {
@@ -109,10 +109,9 @@ macro_rules! match_iter {
match_iter!(@match 1, $iter $($rest)*);
#[allow(unused_mut)]
let mut $x = $iter.next();
- match $iter.next() {
- Some(_) => break Err(IterMatchError::TooManyItems),
- None => {},
- };
+ if $iter.next().is_some() {
+ break Err(IterMatchError::TooManyItems);
+ }
};
// Normal pattern
(@match 0, $iter:expr, $x:ident $($rest:tt)*) => {
@@ -135,10 +134,9 @@ macro_rules! match_iter {
// Check no elements remain
(@match 0, $iter:expr $(,)*) => {
- match $iter.next() {
- Some(_) => break Err(IterMatchError::TooManyItems),
- None => {},
- };
+ if $iter.next().is_some() {
+ break Err(IterMatchError::TooManyItems);
+ }
};
(@match $_:expr, $iter:expr) => {};
@@ -370,6 +368,7 @@ macro_rules! make_pest_parse_function {
($name:ident<$o:ty>; $submac:ident!( $($args:tt)* )) => (
#[allow(unused_variables)]
#[allow(non_snake_case)]
+ #[allow(clippy::all)]
fn $name<'a>(pair: Pair<'a, Rule>) -> ParseResult<$o> {
$submac!(pair; $($args)*)
}
@@ -813,7 +812,7 @@ rule!(final_expression<BoxExpr>;
children!(e: expression, _eoi: EOI) => e
);
-pub fn parse_expr<'i>(s: &'i str) -> ParseResult<BoxExpr> {
+pub fn parse_expr(s: &str) -> ParseResult<BoxExpr> {
let pairs = DhallParser::parse(Rule::final_expression, s)?;
// Match the only item in the pairs iterator
match_iter!(@panic; pairs; (p) => expression(p))
diff --git a/dhall_generator/src/lib.rs b/dhall_generator/src/lib.rs
index 780b621..4be3fa0 100644
--- a/dhall_generator/src/lib.rs
+++ b/dhall_generator/src/lib.rs
@@ -40,11 +40,11 @@ fn dhall_to_tokenstream(
quote! { App(#f, #a) }
}
Builtin(b) => {
- let b = builtin_to_tokenstream(b);
+ let b = builtin_to_tokenstream(*b);
quote! { Builtin(#b) }
}
BinOp(o, a, b) => {
- let o = binop_to_tokenstream(o);
+ let o = binop_to_tokenstream(*o);
let a = dhall_to_tokenstream_bx(a, ctx);
let b = dhall_to_tokenstream_bx(b, ctx);
quote! { BinOp(#o, #a, #b) }
@@ -55,8 +55,7 @@ fn dhall_to_tokenstream(
.map(deref)
.map(|x| dhall_to_tokenstream_bx(x, ctx)),
);
- let es =
- vec_tks(es.into_iter().map(|x| dhall_to_tokenstream(x, ctx)));
+ let es = vec_tks(es.iter().map(|x| dhall_to_tokenstream(x, ctx)));
quote! { OptionalLit(#t, #es) }
}
ListLit(t, es) => {
@@ -65,8 +64,7 @@ fn dhall_to_tokenstream(
.map(deref)
.map(|x| dhall_to_tokenstream_bx(x, ctx)),
);
- let es =
- vec_tks(es.into_iter().map(|x| dhall_to_tokenstream(x, ctx)));
+ let es = vec_tks(es.iter().map(|x| dhall_to_tokenstream(x, ctx)));
quote! { ListLit(#t, #es) }
}
e => unimplemented!("{:?}", e),
@@ -103,14 +101,15 @@ fn dhall_to_tokenstream_bx(
}
}
-fn builtin_to_tokenstream(b: &Builtin) -> TokenStream {
+fn builtin_to_tokenstream(b: Builtin) -> TokenStream {
format!("{:?}", b).parse().unwrap()
}
-fn binop_to_tokenstream(b: &BinOp) -> TokenStream {
+fn binop_to_tokenstream(b: BinOp) -> TokenStream {
format!("{:?}", b).parse().unwrap()
}
+#[allow(clippy::borrowed_box)]
fn deref<T>(x: &Box<T>) -> &T {
&*x
}