|
| 1 | +// Copyright 2016 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 | +// aux-build:two_macros.rs |
| 12 | + |
| 13 | +macro_rules! foo { () => {} } |
| 14 | +macro_rules! macro_one { () => {} } |
| 15 | + |
| 16 | +macro_rules! m1 { () => { |
| 17 | + macro_rules! foo { () => {} } //~ ERROR `foo` is already in scope |
| 18 | + //~^ NOTE macro-expanded `macro_rules!`s and `#[macro_use]`s may not shadow existing macros |
| 19 | + |
| 20 | + #[macro_use] //~ ERROR `macro_one` is already in scope |
| 21 | + //~^ NOTE macro-expanded `macro_rules!`s and `#[macro_use]`s may not shadow existing macros |
| 22 | + extern crate two_macros; |
| 23 | +}} |
| 24 | +m1!(); //~ NOTE in this expansion |
| 25 | + //~| NOTE in this expansion |
| 26 | + //~| NOTE in this expansion |
| 27 | + //~| NOTE in this expansion |
| 28 | + |
| 29 | +fn f() { macro_one!(); } |
| 30 | +foo!(); |
| 31 | + |
| 32 | +macro_rules! m2 { () => { |
| 33 | + macro_rules! foo { () => {} } |
| 34 | + #[macro_use] extern crate two_macros as __; |
| 35 | + |
| 36 | + fn g() { macro_one!(); } |
| 37 | + foo!(); |
| 38 | +}} |
| 39 | +m2!(); |
| 40 | +//^ Since `foo` and `macro_one` are not used outside this expansion, they are not shadowing errors. |
| 41 | + |
| 42 | +fn main() {} |
0 commit comments