Add test, and fix the other tests
This commit is contained in:
parent
ba0601d4b6
commit
b36d23c8af
17 changed files with 69 additions and 0 deletions
|
|
@ -14,6 +14,7 @@
|
|||
// aux-build:bang_proc_macro.rs
|
||||
|
||||
#![feature(proc_macro)]
|
||||
#![allow(unused_macros)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate derive_foo;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
// gate-test-allow_internal_unstable
|
||||
|
||||
#![allow(unused_macros)]
|
||||
|
||||
macro_rules! bar {
|
||||
() => {
|
||||
// more layers don't help:
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
() => {}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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`
|
||||
|
||||
|
|
|
|||
|
|
@ -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)*
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 } }
|
||||
|
|
|
|||
|
|
@ -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 `(`
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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`
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
39
src/test/compile-fail/unused-macro.rs
Normal file
39
src/test/compile-fail/unused-macro.rs
Normal 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() {}
|
||||
|
|
@ -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`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue