From 1eca73c523c1c0b16c8493d1abc52353883ee556 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Wed, 22 Jun 2016 18:33:09 -0700 Subject: [PATCH] Add clippy support --- quasi/Cargo.toml | 2 ++ quasi/src/lib.rs | 10 ++++++---- quasi_codegen/Cargo.toml | 2 ++ quasi_codegen/src/lib.rs | 12 +++++++----- quasi_macros/Cargo.toml | 4 ++++ quasi_macros/src/lib.rs | 2 ++ quasi_tests/Cargo.toml | 6 ++++++ 7 files changed, 29 insertions(+), 9 deletions(-) diff --git a/quasi/Cargo.toml b/quasi/Cargo.toml index 05721383..6d96e805 100644 --- a/quasi/Cargo.toml +++ b/quasi/Cargo.toml @@ -9,6 +9,8 @@ include = ["Cargo.toml", "src/**/*.rs"] [features] with-syntex = ["syntex_syntax"] +unstable-testing = ["clippy"] [dependencies] syntex_syntax = { version = "^0.36.0", optional = true } +clippy = { version = "^0.*", optional = true } diff --git a/quasi/src/lib.rs b/quasi/src/lib.rs index 1baad7d3..bace1f4c 100644 --- a/quasi/src/lib.rs +++ b/quasi/src/lib.rs @@ -9,6 +9,8 @@ // except according to those terms. #![cfg_attr(not(feature = "with-syntex"), feature(rustc_private))] +#![cfg_attr(feature = "unstable-testing", feature(plugin))] +#![cfg_attr(feature = "unstable-testing", plugin(clippy))] #[macro_use] #[cfg(feature = "with-syntex")] @@ -70,9 +72,9 @@ impl ToTokens for Spanned { impl ToTokens for Option { fn to_tokens(&self, cx: &ExtCtxt) -> Vec { - match self { - &Some(ref t) => t.to_tokens(cx), - &None => Vec::new(), + match *self { + Some(ref t) => t.to_tokens(cx), + None => Vec::new(), } } } @@ -145,7 +147,7 @@ impl ToTokens for ast::WhereClause { */ let s = pprust::to_string(|s| { - s.print_where_clause(&self) + s.print_where_clause(self) }); panictry!(parse_tts_from_source_str("".to_string(), s, cx.cfg(), cx.parse_sess())) diff --git a/quasi_codegen/Cargo.toml b/quasi_codegen/Cargo.toml index 53d1c7d8..ce8a93e4 100644 --- a/quasi_codegen/Cargo.toml +++ b/quasi_codegen/Cargo.toml @@ -10,8 +10,10 @@ include = ["Cargo.toml", "src/**/*.rs"] [features] default = ["with-syntex"] with-syntex = ["syntex", "syntex_syntax", "aster/with-syntex"] +unstable-testing = ["clippy"] [dependencies] aster = { version = "^0.19.0", default-features = false } +clippy = { version = "^0.*", optional = true } syntex = { version = "^0.36.0", optional = true } syntex_syntax = { version = "^0.36.0", optional = true } diff --git a/quasi_codegen/src/lib.rs b/quasi_codegen/src/lib.rs index 22ee68b6..32c0e691 100644 --- a/quasi_codegen/src/lib.rs +++ b/quasi_codegen/src/lib.rs @@ -9,6 +9,8 @@ // except according to those terms. #![cfg_attr(not(feature = "with-syntex"), feature(rustc_private))] +#![cfg_attr(feature = "unstable-testing", feature(plugin))] +#![cfg_attr(feature = "unstable-testing", plugin(clippy))] extern crate aster; @@ -41,7 +43,7 @@ use syntax::ptr::P; /// /// This is registered as a set of expression syntax extension called quote! /// that lifts its argument token-tree to an AST representing the -/// construction of the same token tree, with token::SubstNt interpreted +/// construction of the same token tree, with `token::SubstNt` interpreted /// as antiquotes (splices). fn expand_quote_tokens<'cx>( @@ -451,7 +453,7 @@ fn statements_mk_tt(tt: &ast::TokenTree, matcher: bool) -> Result { // tt.extend($ident.to_tokens(ext_cx).into_iter()) - let builder = builder.clone().span(sp); + let builder = builder.span(sp); let to_tokens = builder.path() .global() @@ -486,7 +488,7 @@ fn statements_mk_tt(tt: &ast::TokenTree, matcher: bool) -> Result { - let builder = builder.clone().span(sp); + let builder = builder.span(sp); let e_tok = builder.expr().call() .build(mk_tt_path(&builder, "Token")) @@ -514,7 +516,7 @@ fn statements_mk_tt(tt: &ast::TokenTree, matcher: bool) -> Result { - let builder = builder.clone().span(sp); + let builder = builder.span(sp); let e_sp = builder.expr().id("_sp"); @@ -580,7 +582,7 @@ fn statements_mk_tt(tt: &ast::TokenTree, matcher: bool) -> Result