Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #47 from erickt/clippy
Browse files Browse the repository at this point in the history
Add clippy support
  • Loading branch information
erickt authored Jun 23, 2016
2 parents 096e377 + 1eca73c commit c03ecdd
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
2 changes: 2 additions & 0 deletions quasi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
10 changes: 6 additions & 4 deletions quasi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -70,9 +72,9 @@ impl<T: ToTokens> ToTokens for Spanned<T> {

impl<T: ToTokens> ToTokens for Option<T> {
fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> {
match self {
&Some(ref t) => t.to_tokens(cx),
&None => Vec::new(),
match *self {
Some(ref t) => t.to_tokens(cx),
None => Vec::new(),
}
}
}
Expand Down Expand Up @@ -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("<quote expansion>".to_string(), s, cx.cfg(), cx.parse_sess()))
Expand Down
2 changes: 2 additions & 0 deletions quasi_codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
12 changes: 7 additions & 5 deletions quasi_codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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>(
Expand Down Expand Up @@ -451,7 +453,7 @@ fn statements_mk_tt(tt: &ast::TokenTree, matcher: bool) -> Result<QuoteStmts, ()
ast::TokenTree::Token(sp, SubstNt(ident)) => {
// 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()
Expand Down Expand Up @@ -486,7 +488,7 @@ fn statements_mk_tt(tt: &ast::TokenTree, matcher: bool) -> Result<QuoteStmts, ()
statements_mk_tts(&seq[..], matcher)
}
ast::TokenTree::Token(sp, ref tok) => {
let builder = builder.clone().span(sp);
let builder = builder.span(sp);

let e_tok = builder.expr().call()
.build(mk_tt_path(&builder, "Token"))
Expand Down Expand Up @@ -514,7 +516,7 @@ fn statements_mk_tt(tt: &ast::TokenTree, matcher: bool) -> Result<QuoteStmts, ()
})
},
ast::TokenTree::Sequence(sp, ref seq) if matcher => {
let builder = builder.clone().span(sp);
let builder = builder.span(sp);

let e_sp = builder.expr().id("_sp");

Expand Down Expand Up @@ -580,7 +582,7 @@ fn statements_mk_tt(tt: &ast::TokenTree, matcher: bool) -> Result<QuoteStmts, ()
if idents.is_empty() {
return Err(());
}
let builder = builder.clone().span(sp);
let builder = builder.span(sp);
let one_or_more = builder.expr().bool(seq.op == ast::KleeneOp::OneOrMore);
let mut iter = idents.iter().cloned();
let first = iter.next().unwrap();
Expand Down
4 changes: 4 additions & 0 deletions quasi_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ include = ["Cargo.toml", "src/**/*.rs"]
name = "quasi_macros"
plugin = true

[features]
unstable-testing = ["clippy", "quasi/unstable-testing", "quasi_codegen/unstable-testing"]

[dependencies]
clippy = { version = "^0.*", optional = true }
quasi_codegen = { version = "^0.13.0", path = "../quasi_codegen", default-features = false }

[dev-dependencies]
Expand Down
2 changes: 2 additions & 0 deletions quasi_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
// except according to those terms.

#![feature(plugin_registrar, unboxed_closures, rustc_private)]
#![cfg_attr(feature = "unstable-testing", feature(plugin))]
#![cfg_attr(feature = "unstable-testing", plugin(clippy))]

extern crate quasi_codegen;
extern crate rustc_plugin;
Expand Down
6 changes: 6 additions & 0 deletions quasi_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ description = "A quasi-quoting macro system"
repository = "https://github.com/erickt/rust-quasi"
build = "build.rs"

[features]
unstable-testing = ["clippy", "quasi/unstable-testing", "quasi_codegen/unstable-testing"]

[build-dependencies]
quasi_codegen = { path = "../quasi_codegen" }
syntex = { version = "^0.36.0" }

[dependencies]
clippy = { version = "^0.*", optional = true }

[dev-dependencies]
aster = { version = "^0.19.0", features = ["with-syntex"] }
quasi = { path = "../quasi", features = ["with-syntex"] }
Expand Down

0 comments on commit c03ecdd

Please sign in to comment.