rust/src/test/ui/hygiene/nested_macro_privacy.rs

18 lines
354 B
Rust
Raw Normal View History

2017-03-24 21:37:55 -05:00
#![feature(decl_macro)]
macro n($foo:ident, $S:ident, $i:ident, $m:ident) {
mod $foo {
#[derive(Default)]
pub struct $S { $i: u32 }
pub macro $m($e:expr) { $e.$i }
}
}
n!(foo, S, i, m);
fn main() {
use foo::{S, m};
S::default().i; //~ ERROR field `i` of struct `foo::S` is private
m!(S::default()); // ok
}