parent
e2a9c04e19
commit
538288176a
10 changed files with 147 additions and 1 deletions
|
|
@ -616,7 +616,12 @@ pub fn expand_item_mac(it: P<ast::Item>,
|
|||
imported_from, tts);
|
||||
|
||||
fld.cx.syntax_env.insert(intern(name.as_slice()), ext);
|
||||
if attr::contains_name(it.attrs.as_slice(), "macro_export") {
|
||||
|
||||
if match imported_from {
|
||||
None => attr::contains_name(it.attrs.as_slice(), "macro_export"),
|
||||
Some(_) => fld.cx.ecfg.reexported_macros.iter()
|
||||
.any(|e| e.as_slice() == name.as_slice()),
|
||||
} {
|
||||
fld.cx.exported_macros.push(it);
|
||||
}
|
||||
|
||||
|
|
@ -1156,6 +1161,7 @@ pub struct ExpansionConfig {
|
|||
pub deriving_hash_type_parameter: bool,
|
||||
pub enable_quotes: bool,
|
||||
pub recursion_limit: uint,
|
||||
pub reexported_macros: Vec<String>,
|
||||
}
|
||||
|
||||
impl ExpansionConfig {
|
||||
|
|
@ -1165,6 +1171,7 @@ impl ExpansionConfig {
|
|||
deriving_hash_type_parameter: false,
|
||||
enable_quotes: false,
|
||||
recursion_limit: 64,
|
||||
reexported_macros: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
41
src/libsyntax/ext/tt/reexport.rs
Normal file
41
src/libsyntax/ext/tt/reexport.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
//! Defines the crate attribute syntax for macro re-export.
|
||||
|
||||
use ast;
|
||||
use attr::AttrMetaMethods;
|
||||
use diagnostic::SpanHandler;
|
||||
|
||||
/// Return a vector of the names of all macros re-exported from the crate.
|
||||
pub fn gather(diag: &SpanHandler, krate: &ast::Crate) -> Vec<String> {
|
||||
let usage = "malformed macro_reexport attribute, expected \
|
||||
#![macro_reexport(ident, ident, ...)]";
|
||||
|
||||
let mut reexported: Vec<String> = vec!();
|
||||
for attr in krate.attrs.iter() {
|
||||
if !attr.check_name("macro_reexport") {
|
||||
continue;
|
||||
}
|
||||
|
||||
match attr.meta_item_list() {
|
||||
None => diag.span_err(attr.span, usage),
|
||||
Some(list) => for mi in list.iter() {
|
||||
match mi.node {
|
||||
ast::MetaWord(ref word)
|
||||
=> reexported.push(word.to_string()),
|
||||
_ => diag.span_err(mi.span, usage),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reexported
|
||||
}
|
||||
|
|
@ -104,5 +104,6 @@ pub mod ext {
|
|||
pub mod transcribe;
|
||||
pub mod macro_parser;
|
||||
pub mod macro_rules;
|
||||
pub mod reexport;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue