2018-04-27 23:32:00 -05:00
|
|
|
#![feature(decl_macro)]
|
2017-03-24 21:37:55 -05:00
|
|
|
|
|
|
|
mod foo {
|
|
|
|
pub fn f() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod bar {
|
|
|
|
pub fn g() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
macro m($($t:tt)*) {
|
|
|
|
$($t)*
|
|
|
|
use foo::*;
|
|
|
|
f();
|
|
|
|
g(); //~ ERROR cannot find function `g` in this scope
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
m! {
|
|
|
|
use bar::*;
|
|
|
|
g();
|
|
|
|
f(); //~ ERROR cannot find function `f` in this scope
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
n!(f);
|
|
|
|
macro n($i:ident) {
|
|
|
|
mod foo {
|
|
|
|
pub fn $i() -> u32 { 0 }
|
|
|
|
pub fn f() {}
|
|
|
|
|
|
|
|
mod test {
|
|
|
|
use super::*;
|
|
|
|
fn g() {
|
|
|
|
let _: u32 = $i();
|
|
|
|
let _: () = f();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
macro n($j:ident) {
|
|
|
|
mod test {
|
|
|
|
use super::*;
|
|
|
|
fn g() {
|
|
|
|
let _: u32 = $i();
|
|
|
|
let _: () = f();
|
|
|
|
$j();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-07-07 15:07:06 -05:00
|
|
|
macro n_with_super($j:ident) {
|
|
|
|
mod test {
|
|
|
|
use super::*;
|
|
|
|
fn g() {
|
|
|
|
let _: u32 = $i();
|
|
|
|
let _: () = f();
|
|
|
|
super::$j();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-24 21:37:55 -05:00
|
|
|
|
2018-07-07 15:07:06 -05:00
|
|
|
n!(f); //~ ERROR cannot find function `f` in this scope
|
|
|
|
n_with_super!(f);
|
2017-03-24 21:37:55 -05:00
|
|
|
mod test2 {
|
|
|
|
super::n! {
|
|
|
|
f //~ ERROR cannot find function `f` in this scope
|
|
|
|
}
|
2018-07-07 15:07:06 -05:00
|
|
|
super::n_with_super! {
|
|
|
|
f
|
|
|
|
}
|
2017-03-24 21:37:55 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|