diff options
| author | Keegan McAllister <kmcallister@mozilla.com> | 2014-09-15 19:02:14 -0700 |
|---|---|---|
| committer | Keegan McAllister <kmcallister@mozilla.com> | 2015-01-05 11:38:12 -0800 |
| commit | 538288176a22b4d3755df085783f84d476386019 (patch) | |
| tree | 231a4cd0d91a8cdf4b4d9d315465e06c79a8a319 /src/libsyntax/ext/tt | |
| parent | e2a9c04e192926fde1a8e886b55e4c2b6e0e56cb (diff) | |
| download | rust-538288176a22b4d3755df085783f84d476386019.tar.gz rust-538288176a22b4d3755df085783f84d476386019.zip | |
Implement macro re-export
Fixes #17103.
Diffstat (limited to 'src/libsyntax/ext/tt')
| -rw-r--r-- | src/libsyntax/ext/tt/reexport.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/libsyntax/ext/tt/reexport.rs b/src/libsyntax/ext/tt/reexport.rs new file mode 100644 index 00000000000..104f3787253 --- /dev/null +++ b/src/libsyntax/ext/tt/reexport.rs @@ -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 +} |
