Skip to content

Commit b36d23c

Browse files
committed
Add test, and fix the other tests
1 parent ba0601d commit b36d23c

17 files changed

+69
-0
lines changed

src/test/compile-fail-fulldeps/proc-macro/resolve-error.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// aux-build:bang_proc_macro.rs
1515

1616
#![feature(proc_macro)]
17+
#![allow(unused_macros)]
1718

1819
#[macro_use]
1920
extern crate derive_foo;

src/test/compile-fail/feature-gate-allow-internal-unstable-nested-macro.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// gate-test-allow_internal_unstable
1212

13+
#![allow(unused_macros)]
14+
1315
macro_rules! bar {
1416
() => {
1517
// more layers don't help:

src/test/compile-fail/feature-gate-allow-internal-unstable.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![allow(unused_macros)]
12+
1113
#[allow_internal_unstable] //~ ERROR allow_internal_unstable side-steps
1214
macro_rules! foo {
1315
() => {}

src/test/compile-fail/invalid-macro-matcher.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![allow(unused_macros)]
12+
1113
macro_rules! invalid {
1214
_ => (); //~ ERROR invalid macro matcher
1315
}

src/test/compile-fail/issue-21356.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![allow(unused_macros)]
12+
1113
macro_rules! test { ($wrong:t_ty ..) => () }
1214
//~^ ERROR: invalid fragment specifier `t_ty`
1315

src/test/compile-fail/issue-39388.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![allow(unused_macros)]
12+
1113
macro_rules! assign {
1214
(($($a:tt)*) = ($($b:tt))*) => { //~ ERROR expected `*` or `+`
1315
$($a)* = $($b)*

src/test/compile-fail/issue-39404.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#![deny(missing_fragment_specifier)] //~ NOTE lint level defined here
12+
#![allow(unused_macros)]
1213

1314
macro_rules! m { ($i) => {} }
1415
//~^ ERROR missing fragment specifier

src/test/compile-fail/issue-5067.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![allow(unused_macros)]
12+
1113
macro_rules! foo {
1214
( $()* ) => {};
1315
//~^ ERROR repetition matches empty token tree

src/test/compile-fail/macro-expansion-tests.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![allow(unused_macros)]
12+
1113
mod macros_cant_escape_fns {
1214
fn f() {
1315
macro_rules! m { () => { 3 + 4 } }

src/test/compile-fail/macro-follow.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
//
1111
// Check the macro follow sets (see corresponding rpass test).
1212

13+
#![allow(unused_macros)]
14+
1315
// FOLLOW(pat) = {FatArrow, Comma, Eq, Or, Ident(if), Ident(in)}
1416
macro_rules! follow_pat {
1517
($p:pat ()) => {}; //~ERROR `$p:pat` is followed by `(`

src/test/compile-fail/macro-followed-by-seq-bad.rs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// Regression test for issue #25436: check that things which can be
1212
// followed by any token also permit X* to come afterwards.
1313

14+
#![allow(unused_macros)]
15+
1416
macro_rules! foo {
1517
( $a:expr $($b:tt)* ) => { }; //~ ERROR not allowed for `expr` fragments
1618
( $a:ty $($b:tt)* ) => { }; //~ ERROR not allowed for `ty` fragments

src/test/compile-fail/macro-input-future-proofing.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![allow(unused_macros)]
12+
1113
macro_rules! errors_everywhere {
1214
($ty:ty <) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty`
1315
($ty:ty < foo ,) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty`

src/test/compile-fail/macro-shadowing.rs

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// aux-build:two_macros.rs
1212

13+
#![allow(unused_macros)]
14+
1315
macro_rules! foo { () => {} }
1416
macro_rules! macro_one { () => {} }
1517
#[macro_use(macro_two)] extern crate two_macros;

src/test/compile-fail/unused-macro-with-bad-frag-spec.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![allow(unused_macros)]
12+
1113
// Issue #21370
1214

1315
macro_rules! test {

src/test/compile-fail/unused-macro-with-follow-violation.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![allow(unused_macros)]
12+
1113
macro_rules! test {
1214
($e:expr +) => () //~ ERROR not allowed for `expr` fragments
1315
}

src/test/compile-fail/unused-macro.rs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![deny(unused_macros)]
12+
13+
// Most simple case
14+
macro_rules! unused { //~ ERROR: unused macro definition
15+
() => {};
16+
}
17+
18+
// Test macros created by macros
19+
macro_rules! create_macro {
20+
() => {
21+
macro_rules! m { //~ ERROR: unused macro definition
22+
() => {};
23+
}
24+
};
25+
}
26+
create_macro!();
27+
28+
#[allow(unused_macros)]
29+
mod bar {
30+
// Test that putting the #[deny] close to the macro's definition
31+
// works.
32+
33+
#[deny(unused_macros)]
34+
macro_rules! unused { //~ ERROR: unused macro definition
35+
() => {};
36+
}
37+
}
38+
39+
fn main() {}

src/test/compile-fail/user-defined-macro-rules.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![allow(unused_macros)]
12+
1113
macro_rules! macro_rules { () => {} } //~ ERROR user-defined macros may not be named `macro_rules`

0 commit comments

Comments
 (0)