// aux-build:bang_proc_macro.rs
#![feature(proc_macro)]
+#![allow(unused_macros)]
#[macro_use]
extern crate derive_foo;
// gate-test-allow_internal_unstable
+#![allow(unused_macros)]
+
macro_rules! bar {
() => {
// more layers don't help:
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+#![allow(unused_macros)]
+
#[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps
macro_rules! foo {
() => {}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+#![allow(unused_macros)]
+
macro_rules! invalid {
_ => (); //~ ERROR invalid macro matcher
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+#![allow(unused_macros)]
+
macro_rules! test { ($wrong:t_ty ..) => () }
//~^ ERROR: invalid fragment specifier `t_ty`
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+#![allow(unused_macros)]
+
macro_rules! assign {
(($($a:tt)*) = ($($b:tt))*) => { //~ ERROR expected `*` or `+`
$($a)* = $($b)*
// except according to those terms.
#![deny(missing_fragment_specifier)] //~ NOTE lint level defined here
+#![allow(unused_macros)]
macro_rules! m { ($i) => {} }
//~^ ERROR missing fragment specifier
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+#![allow(unused_macros)]
+
macro_rules! foo {
( $()* ) => {};
//~^ ERROR repetition matches empty token tree
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+#![allow(unused_macros)]
+
mod macros_cant_escape_fns {
fn f() {
macro_rules! m { () => { 3 + 4 } }
//
// Check the macro follow sets (see corresponding rpass test).
+#![allow(unused_macros)]
+
// FOLLOW(pat) = {FatArrow, Comma, Eq, Or, Ident(if), Ident(in)}
macro_rules! follow_pat {
($p:pat ()) => {}; //~ERROR `$p:pat` is followed by `(`
// Regression test for issue #25436: check that things which can be
// followed by any token also permit X* to come afterwards.
+#![allow(unused_macros)]
+
macro_rules! foo {
( $a:expr $($b:tt)* ) => { }; //~ ERROR not allowed for `expr` fragments
( $a:ty $($b:tt)* ) => { }; //~ ERROR not allowed for `ty` fragments
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+#![allow(unused_macros)]
+
macro_rules! errors_everywhere {
($ty:ty <) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty`
($ty:ty < foo ,) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty`
// aux-build:two_macros.rs
+#![allow(unused_macros)]
+
macro_rules! foo { () => {} }
macro_rules! macro_one { () => {} }
#[macro_use(macro_two)] extern crate two_macros;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+#![allow(unused_macros)]
+
// Issue #21370
macro_rules! test {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+#![allow(unused_macros)]
+
macro_rules! test {
($e:expr +) => () //~ ERROR not allowed for `expr` fragments
}
--- /dev/null
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![deny(unused_macros)]
+
+// Most simple case
+macro_rules! unused { //~ ERROR: unused macro definition
+ () => {};
+}
+
+// Test macros created by macros
+macro_rules! create_macro {
+ () => {
+ macro_rules! m { //~ ERROR: unused macro definition
+ () => {};
+ }
+ };
+}
+create_macro!();
+
+#[allow(unused_macros)]
+mod bar {
+ // Test that putting the #[deny] close to the macro's definition
+ // works.
+
+ #[deny(unused_macros)]
+ macro_rules! unused { //~ ERROR: unused macro definition
+ () => {};
+ }
+}
+
+fn main() {}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
+#![allow(unused_macros)]
+
macro_rules! macro_rules { () => {} } //~ ERROR user-defined macros may not be named `macro_rules`