Add test, and fix the other tests

This commit is contained in:
est31 2017-05-12 09:53:58 +02:00
parent ba0601d4b6
commit b36d23c8af
17 changed files with 69 additions and 0 deletions

View file

@ -14,6 +14,7 @@
// aux-build:bang_proc_macro.rs
#![feature(proc_macro)]
#![allow(unused_macros)]
#[macro_use]
extern crate derive_foo;

View file

@ -10,6 +10,8 @@
// gate-test-allow_internal_unstable
#![allow(unused_macros)]
macro_rules! bar {
() => {
// more layers don't help:

View file

@ -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 {
() => {}

View file

@ -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
}

View file

@ -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`

View file

@ -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)*

View file

@ -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

View file

@ -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

View file

@ -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 } }

View file

@ -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 `(`

View file

@ -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

View file

@ -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`

View file

@ -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;

View file

@ -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 {

View file

@ -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
}

View file

@ -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() {}

View file

@ -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`