From 9aebb59a680997b82f7008886b7a31a3e71a1e1f Mon Sep 17 00:00:00 2001 From: Techcable Date: Sun, 12 Mar 2017 20:13:20 -0700 Subject: [PATCH 1/2] Fix compilation on latest nightly The ability for plugins to add MIR passes was removed as of 4ca9c97ac. Luckily, we don't use this feature at all and can safely ignore it. Fixes #1618 --- src/main.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 12dd5d1f695b..1ca0d2b92f34 100644 --- a/src/main.rs +++ b/src/main.rs @@ -89,7 +89,6 @@ impl<'a> CompilerCalls<'a> for ClippyCompilerCalls { lint_groups, llvm_passes, attributes, - mir_passes, .. } = registry; let sess = &state.session; let mut ls = sess.lint_store.borrow_mut(); @@ -105,7 +104,6 @@ impl<'a> CompilerCalls<'a> for ClippyCompilerCalls { } sess.plugin_llvm_passes.borrow_mut().extend(llvm_passes); - sess.mir_passes.borrow_mut().extend(mir_passes); sess.plugin_attributes.borrow_mut().extend(attributes); } old(state); From 2d145b2ef5ab528434899d7b63c51a4bda1f7be9 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 13 Mar 2017 11:09:56 +0100 Subject: [PATCH 2/2] don't lint macro_rules! in items_after_statements --- clippy_lints/src/items_after_statements.rs | 4 ++++ tests/ui/item_after_statement.rs | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/clippy_lints/src/items_after_statements.rs b/clippy_lints/src/items_after_statements.rs index 3b3cd423729b..5789f6a5f80b 100644 --- a/clippy_lints/src/items_after_statements.rs +++ b/clippy_lints/src/items_after_statements.rs @@ -58,6 +58,10 @@ impl EarlyLintPass for ItemsAfterStatements { if in_macro(cx, it.span) { return; } + if let ItemKind::MacroDef(..) = it.node { + // do not lint `macro_rules`, but continue processing further statements + continue; + } span_lint(cx, ITEMS_AFTER_STATEMENTS, it.span, diff --git a/tests/ui/item_after_statement.rs b/tests/ui/item_after_statement.rs index 09b509673dc3..5ba94383cc69 100644 --- a/tests/ui/item_after_statement.rs +++ b/tests/ui/item_after_statement.rs @@ -17,3 +17,14 @@ fn main() { fn foo() { println!("foo"); } foo(); } + +fn mac() { + let mut a = 5; + println!("{}", a); + // do not lint this, because it needs to be after `a` + macro_rules! b { + () => {{ a = 6 }} + } + b!(); + println!("{}", a); +}