about summary refs log tree commit diff
path: root/src/librustc/plugin
diff options
context:
space:
mode:
authorKeegan McAllister <kmcallister@mozilla.com>2014-12-31 20:43:46 -0800
committerKeegan McAllister <kmcallister@mozilla.com>2015-01-05 18:21:13 -0800
commit60be2f52d2434dfbf2df7728454d572d76f58bf8 (patch)
treeb6ebc58ca4d544ed39d224c4eaf0f80b900066f9 /src/librustc/plugin
parentf314e2c4ea48c2027e627fdfca821bb6e0012e59 (diff)
downloadrust-60be2f52d2434dfbf2df7728454d572d76f58bf8.tar.gz
rust-60be2f52d2434dfbf2df7728454d572d76f58bf8.zip
Replace #[phase] with #[plugin] / #[macro_use] / #[no_link]
Diffstat (limited to 'src/librustc/plugin')
-rw-r--r--src/librustc/plugin/load.rs34
-rw-r--r--src/librustc/plugin/mod.rs8
2 files changed, 26 insertions, 16 deletions
diff --git a/src/librustc/plugin/load.rs b/src/librustc/plugin/load.rs
index 78730defc7f..d17ef199aa1 100644
--- a/src/librustc/plugin/load.rs
+++ b/src/librustc/plugin/load.rs
@@ -84,26 +84,36 @@ impl<'a, 'v> Visitor<'v> for PluginLoader<'a> {
             _ => return,
         }
 
-        let mut plugin_phase = false;
-        for attr in vi.attrs.iter().filter(|a| a.check_name("phase")) {
-            let phases = attr.meta_item_list().unwrap_or(&[]);
-            if attr::contains_name(phases, "plugin") {
-                plugin_phase = true;
+        // Parse the attributes relating to macro / plugin loading.
+        let mut load_macros = false;
+        let mut load_registrar = false;
+        for attr in vi.attrs.iter() {
+            let mut used = true;
+            match attr.name().get() {
+                "phase" => {
+                    self.sess.span_err(attr.span, "#[phase] is deprecated; use \
+                                       #[macro_use], #[plugin], and/or #[no_link]");
+                }
+                "plugin" => load_registrar = true,
+                "macro_use" => load_macros = true,
+                _ => used = false,
             }
-            if attr::contains_name(phases, "syntax") {
-                plugin_phase = true;
-                self.sess.span_warn(attr.span,
-                    "phase(syntax) is a deprecated synonym for phase(plugin)");
+            if used {
+                attr::mark_used(attr);
             }
         }
 
         let mut macros = vec![];
         let mut registrar = None;
 
-        if plugin_phase {
+        if load_macros || load_registrar {
             let pmd = self.reader.read_plugin_metadata(vi);
-            macros = pmd.exported_macros();
-            registrar = pmd.plugin_registrar();
+            if load_macros {
+                macros = pmd.exported_macros();
+            }
+            if load_registrar {
+                registrar = pmd.plugin_registrar();
+            }
         }
 
         self.plugins.macros.extend(macros.into_iter());
diff --git a/src/librustc/plugin/mod.rs b/src/librustc/plugin/mod.rs
index 8dd60880cdd..fd8873454b4 100644
--- a/src/librustc/plugin/mod.rs
+++ b/src/librustc/plugin/mod.rs
@@ -43,14 +43,14 @@
 //! To use a plugin while compiling another crate:
 //!
 //! ```rust
-//! #![feature(phase)]
+//! #![feature(plugin)]
 //!
-//! #[phase(plugin)]
+//! #[plugin]
 //! extern crate myplugin;
 //! ```
 //!
-//! If you also need the plugin crate available at runtime, use
-//! `phase(plugin, link)`.
+//! If you don't need the plugin crate available at runtime, use
+//! `#[no_link]` as well.
 //!
 //! See [the compiler plugin guide](../../guide-plugin.html)
 //! for more examples.