Skip to content

Commit

Permalink
Add test, and fix the other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
est31 committed May 13, 2017
1 parent ba0601d commit b36d23c
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/test/compile-fail-fulldeps/proc-macro/resolve-error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// aux-build:bang_proc_macro.rs

#![feature(proc_macro)]
#![allow(unused_macros)]

#[macro_use]
extern crate derive_foo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

// gate-test-allow_internal_unstable

#![allow(unused_macros)]

macro_rules! bar {
() => {
// more layers don't help:
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/feature-gate-allow-internal-unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// 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 {
() => {}
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/invalid-macro-matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// 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
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/issue-21356.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// 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`

Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/issue-39388.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// 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)*
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/issue-39404.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// 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
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/issue-5067.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// 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
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/macro-expansion-tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// 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 } }
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/macro-follow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
//
// 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 `(`
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/macro-followed-by-seq-bad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
// 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
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/macro-input-future-proofing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// 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`
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/macro-shadowing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

// aux-build:two_macros.rs

#![allow(unused_macros)]

macro_rules! foo { () => {} }
macro_rules! macro_one { () => {} }
#[macro_use(macro_two)] extern crate two_macros;
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/unused-macro-with-bad-frag-spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![allow(unused_macros)]

// Issue #21370

macro_rules! test {
Expand Down
2 changes: 2 additions & 0 deletions src/test/compile-fail/unused-macro-with-follow-violation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// 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
}
Expand Down
39 changes: 39 additions & 0 deletions src/test/compile-fail/unused-macro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 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() {}
2 changes: 2 additions & 0 deletions src/test/compile-fail/user-defined-macro-rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
// 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`

0 comments on commit b36d23c

Please sign in to comment.