Skip to content

pub silently dropped from nested item macro invocation #14660

Closed
@kmcallister

Description

@kmcallister
#![feature(macro_rules)]

macro_rules! priv_x( () => (
    static x: uint = 0;
))

macro_rules! pub_x( () => (
    pub priv_x!()
))

mod foo {
    pub_x!()
}

fn main() {
    let y: uint = foo::x;
}

expands to

// ...
mod foo {
    use std::prelude::*;
    static x: uint = 0;
}

fn main() { let y: uint = foo::x; }

and fails with

foo.rs:16:19: 16:25 error: static `x` is private
foo.rs:16     let y: uint = foo::x;
                            ^~~~~~

This isn't a hygeine issue; a macro which expands directly to pub static x: uint = 0; works fine.

rustc 0.11.0-pre (ef9bf3a 2014-06-04 13:06:47 -0700)
host: x86_64-unknown-linux-gnu

Metadata

Metadata

Assignees

Labels

A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions