Skip to content

Commit d8722f3

Browse files
committed
Add tests.
1 parent 9c88650 commit d8722f3

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
#[macro_export]
12+
macro_rules! m { ($($t:tt)*) => { $($t)* } }
13+
14+
#[macro_export]
15+
macro_rules! n { ($($t:tt)*) => { $($t)* } }
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
#![feature(item_like_imports, use_extern_macros)]
14+
15+
extern crate two_macros; // two identity macros `m` and `n`
16+
17+
mod foo {
18+
pub use two_macros::n as m;
19+
}
20+
21+
mod m1 {
22+
m!(use two_macros::*;);
23+
use foo::m; // This shadows the glob import
24+
}
25+
26+
mod m2 {
27+
use two_macros::*; //~ NOTE could also resolve
28+
m! { //~ ERROR ambiguous
29+
//~| NOTE macro-expanded macro imports do not shadow
30+
use foo::m; //~ NOTE could resolve to the name imported here
31+
//~^^^ NOTE in this expansion
32+
}
33+
}
34+
35+
mod m3 {
36+
use two_macros::m; //~ NOTE could also resolve
37+
fn f() {
38+
use two_macros::n as m; // This shadows the above import
39+
m!();
40+
}
41+
42+
fn g() {
43+
m! { //~ ERROR ambiguous
44+
//~| NOTE macro-expanded macro imports do not shadow
45+
use two_macros::n as m; //~ NOTE could resolve to the name imported here
46+
//~^^^ NOTE in this expansion
47+
}
48+
}
49+
}
50+
51+
mod m4 {
52+
macro_rules! m { () => {} } //~ NOTE could resolve to the macro defined here
53+
use two_macros::m; //~ NOTE could also resolve to the macro imported here
54+
m!(); //~ ERROR ambiguous
55+
}

0 commit comments

Comments
 (0)