Resolve clippy complaints
diff --git a/src/aster/qpath.rs b/src/aster/qpath.rs
index 6ecde86..71f68b1 100644
--- a/src/aster/qpath.rs
+++ b/src/aster/qpath.rs
@@ -65,9 +65,6 @@
where F: Invoke<(QSelf, Path)>
{
/// Build a qualified path with a path builder.
- // Clippy false positive
- // https://github.com/Manishearth/rust-clippy/issues/1285
- #[cfg_attr(feature = "clippy", allow(wrong_self_convention))]
pub fn as_(self) -> PathBuilder<Self> {
PathBuilder::with_callback(self)
}
diff --git a/src/escape.rs b/src/escape.rs
index 1c9c6ed..80c3def 100644
--- a/src/escape.rs
+++ b/src/escape.rs
@@ -229,7 +229,7 @@
}};
}
-#[cfg_attr(feature = "clippy", allow(diverging_sub_expression))]
+#[cfg_attr(feature = "cargo-clippy", allow(diverging_sub_expression))]
fn backslash_x_char<I>(chars: &mut I) -> Option<char>
where I: Iterator<Item = (usize, char)>
{
@@ -238,7 +238,7 @@
char::from_u32(from_hex!(a b))
}
-#[cfg_attr(feature = "clippy", allow(diverging_sub_expression))]
+#[cfg_attr(feature = "cargo-clippy", allow(diverging_sub_expression))]
fn backslash_x_byte<I>(chars: &mut I) -> Option<u8>
where I: Iterator<Item = (usize, u8)>
{
@@ -247,7 +247,7 @@
Some(from_hex!(a b))
}
-#[cfg_attr(feature = "clippy", allow(diverging_sub_expression, many_single_char_names))]
+#[cfg_attr(feature = "cargo-clippy", allow(diverging_sub_expression, many_single_char_names))]
fn backslash_u<I>(chars: &mut I) -> Option<char>
where I: Iterator<Item = (usize, char)>
{
diff --git a/src/expr.rs b/src/expr.rs
index 80045c2..dfca207 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -204,7 +204,7 @@
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
// Clippy false positive
// https://github.com/Manishearth/rust-clippy/issues/1241
-#[cfg_attr(feature = "clippy", allow(enum_variant_names))]
+#[cfg_attr(feature = "cargo-clippy", allow(enum_variant_names))]
pub enum Pat {
/// Represents a wildcard pattern (`_`)
Wild,
@@ -339,6 +339,7 @@
named!(expr_no_struct -> Expr, ambiguous_expr!(false));
+ #[cfg_attr(feature = "cargo-clippy", allow(cyclomatic_complexity))]
fn ambiguous_expr(i: &str, allow_struct: bool, allow_block: bool) -> IResult<&str, Expr> {
do_parse!(
i,
diff --git a/src/fold.rs b/src/fold.rs
index 055fb78..374ff68 100644
--- a/src/fold.rs
+++ b/src/fold.rs
@@ -4,6 +4,7 @@
//! and returns a piece of the same type.
use super::*;
+#[cfg(not(feature = "full"))]
use constant;
/// AST->AST fold.
@@ -149,6 +150,9 @@
impl<T, U> LiftOnce<T, U> for Box<T> {
type Output = Box<U>;
+ // Clippy false positive
+ // https://github.com/Manishearth/rust-clippy/issues/1478
+ #[cfg_attr(feature = "cargo-clippy", allow(boxed_local))]
fn lift<F>(self, f: F) -> Box<U>
where F: FnOnce(T) -> U
{
diff --git a/src/ident.rs b/src/ident.rs
index c658d1a..29fd7e8 100644
--- a/src/ident.rs
+++ b/src/ident.rs
@@ -89,7 +89,7 @@
_ => return IResult::Error,
}
- while let Some((i, ch)) = chars.next() {
+ for (i, ch) in chars {
if !UnicodeXID::is_xid_continue(ch) {
return IResult::Done(&input[i..], input[..i].into());
}
diff --git a/src/item.rs b/src/item.rs
index ea530b7..4cbac33 100644
--- a/src/item.rs
+++ b/src/item.rs
@@ -848,7 +848,7 @@
polarity: impl_polarity >>
path: path >>
keyword!("for") >>
- ((polarity, Some(path)))
+ (polarity, Some(path))
)
|
epsilon!() => { |_| (ImplPolarity::Positive, None) }
diff --git a/src/lib.rs b/src/lib.rs
index 21ceb1e..d098630 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,5 +1,4 @@
-#![cfg_attr(feature = "clippy", feature(plugin))]
-#![cfg_attr(feature = "clippy", plugin(clippy))]
+#![cfg_attr(feature = "cargo-clippy", allow(large_enum_variant))]
#[cfg(feature = "printing")]
extern crate quote;
diff --git a/src/visit.rs b/src/visit.rs
index a5d4f41..6c32fce 100644
--- a/src/visit.rs
+++ b/src/visit.rs
@@ -375,10 +375,7 @@
ItemKind::Use(ref view_path) => {
visitor.visit_view_path(view_path);
}
- ItemKind::Static(ref ty, _, ref expr) => {
- visitor.visit_ty(ty);
- visitor.visit_expr(expr);
- }
+ ItemKind::Static(ref ty, _, ref expr) |
ItemKind::Const(ref ty, ref expr) => {
visitor.visit_ty(ty);
visitor.visit_expr(expr);
@@ -403,9 +400,7 @@
ItemKind::Enum(ref variant, ref generics) => {
walk_list!(visitor, visit_variant, variant, generics);
}
- ItemKind::Struct(ref variant_data, ref generics) => {
- visitor.visit_variant_data(variant_data, &item.ident, generics);
- }
+ ItemKind::Struct(ref variant_data, ref generics) |
ItemKind::Union(ref variant_data, ref generics) => {
visitor.visit_variant_data(variant_data, &item.ident, generics);
}
@@ -432,19 +427,14 @@
}
#[cfg(feature = "full")]
+#[cfg_attr(feature = "cargo-clippy", allow(cyclomatic_complexity))]
pub fn walk_expr<V: Visitor>(visitor: &mut V, expr: &Expr) {
walk_list!(visitor, visit_attribute, &expr.attrs);
match expr.node {
- ExprKind::Box(ref expr) => {
- visitor.visit_expr(expr);
- }
ExprKind::InPlace(ref place, ref value) => {
visitor.visit_expr(place);
visitor.visit_expr(value);
}
- ExprKind::Array(ref exprs) => {
- walk_list!(visitor, visit_expr, exprs);
- }
ExprKind::Call(ref callee, ref args) => {
visitor.visit_expr(callee);
walk_list!(visitor, visit_expr, args);
@@ -454,23 +444,17 @@
walk_list!(visitor, visit_ty, ty_args);
walk_list!(visitor, visit_expr, args);
}
+ ExprKind::Array(ref exprs) |
ExprKind::Tup(ref exprs) => {
walk_list!(visitor, visit_expr, exprs);
}
- ExprKind::Binary(_, ref lhs, ref rhs) => {
- visitor.visit_expr(lhs);
- visitor.visit_expr(rhs);
- }
ExprKind::Unary(_, ref operand) => {
visitor.visit_expr(operand);
}
ExprKind::Lit(ref lit) => {
visitor.visit_lit(lit);
}
- ExprKind::Cast(ref expr, ref ty) => {
- visitor.visit_expr(expr);
- visitor.visit_ty(ty);
- }
+ ExprKind::Cast(ref expr, ref ty) |
ExprKind::Type(ref expr, ref ty) => {
visitor.visit_expr(expr);
visitor.visit_ty(ty);
@@ -529,10 +513,8 @@
ExprKind::Block(_, ref block) => {
walk_list!(visitor, visit_stmt, &block.stmts);
}
- ExprKind::Assign(ref lhs, ref rhs) => {
- visitor.visit_expr(lhs);
- visitor.visit_expr(rhs);
- }
+ ExprKind::Binary(_, ref lhs, ref rhs) |
+ ExprKind::Assign(ref lhs, ref rhs) |
ExprKind::AssignOp(_, ref lhs, ref rhs) => {
visitor.visit_expr(lhs);
visitor.visit_expr(rhs);
@@ -562,9 +544,6 @@
}
visitor.visit_path(path);
}
- ExprKind::AddrOf(_, ref expr) => {
- visitor.visit_expr(expr);
- }
ExprKind::Break(ref maybe_label, ref maybe_expr) => {
walk_opt_ident(visitor, maybe_label);
if let Some(ref expr) = *maybe_expr {
@@ -596,9 +575,9 @@
visitor.visit_expr(value);
visitor.visit_expr(times);
}
- ExprKind::Paren(ref expr) => {
- visitor.visit_expr(expr);
- }
+ ExprKind::Box(ref expr) |
+ ExprKind::AddrOf(_, ref expr) |
+ ExprKind::Paren(ref expr) |
ExprKind::Try(ref expr) => {
visitor.visit_expr(expr);
}