Skip to content

Commit

Permalink
Replace #[phase] with #[plugin] / #[macro_use] / #[no_link]
Browse files Browse the repository at this point in the history
  • Loading branch information
Keegan McAllister committed Jan 6, 2015
1 parent f314e2c commit 60be2f5
Show file tree
Hide file tree
Showing 82 changed files with 363 additions and 236 deletions.
9 changes: 8 additions & 1 deletion src/compiletest/compiletest.rs
Expand Up @@ -15,7 +15,14 @@

extern crate test;
extern crate getopts;
#[phase(plugin, link)] extern crate log;

#[cfg(stage0)]
#[phase(plugin, link)]
extern crate log;

#[cfg(not(stage0))]
#[macro_use]
extern crate log;

extern crate regex;

Expand Down
5 changes: 2 additions & 3 deletions src/grammar/verify.rs
Expand Up @@ -8,15 +8,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(globs, phase, macro_rules)]
#![feature(globs, plugin, macro_rules)]

extern crate syntax;
extern crate rustc;

#[phase(link)]
extern crate regex;

#[phase(link, plugin)]
#[macro_use]
extern crate log;

use std::collections::HashMap;
Expand Down
23 changes: 21 additions & 2 deletions src/liballoc/lib.rs
Expand Up @@ -68,14 +68,33 @@
#![feature(lang_items, phase, unsafe_destructor, default_type_params, old_orphan_check)]
#![feature(associated_types)]

#[cfg(stage0)]
#[phase(plugin, link)]
extern crate core;

#[cfg(not(stage0))]
#[macro_use]
extern crate core;

extern crate libc;

// Allow testing this library

#[cfg(test)] #[phase(plugin, link)] extern crate std;
#[cfg(test)] #[phase(plugin, link)] extern crate log;
#[cfg(all(test, stage0))]
#[phase(plugin, link)]
extern crate std;

#[cfg(all(test, not(stage0)))]
#[macro_use]
extern crate std;

#[cfg(all(test, stage0))]
#[phase(plugin, link)]
extern crate log;

#[cfg(all(test, not(stage0)))]
#[macro_use]
extern crate log;

// Heaps provided for low-level allocation strategies

Expand Down
25 changes: 22 additions & 3 deletions src/libcollections/lib.rs
Expand Up @@ -29,15 +29,34 @@
#![feature(associated_types)]
#![no_std]

#[phase(plugin, link)] extern crate core;
#[cfg(stage0)]
#[phase(plugin, link)]
extern crate core;

#[cfg(not(stage0))]
#[macro_use]
extern crate core;

extern crate unicode;
extern crate alloc;

#[cfg(test)] extern crate test;

#[cfg(test)] #[phase(plugin, link)] extern crate std;
#[cfg(test)] #[phase(plugin, link)] extern crate log;
#[cfg(all(test, stage0))]
#[phase(plugin, link)]
extern crate std;

#[cfg(all(test, not(stage0)))]
#[macro_use]
extern crate std;

#[cfg(all(test, stage0))]
#[phase(plugin, link)]
extern crate log;

#[cfg(all(test, not(stage0)))]
#[macro_use]
extern crate log;

pub use binary_heap::BinaryHeap;
pub use bitv::Bitv;
Expand Down
4 changes: 2 additions & 2 deletions src/libflate/lib.rs
Expand Up @@ -21,9 +21,9 @@
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![feature(phase, unboxed_closures)]
#![feature(unboxed_closures)]

#[cfg(test)] #[phase(plugin, link)] extern crate log;
#[cfg(test)] #[macro_use] extern crate log;

extern crate libc;

Expand Down
4 changes: 2 additions & 2 deletions src/libgetopts/lib.rs
Expand Up @@ -85,11 +85,11 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![feature(globs, phase, slicing_syntax)]
#![feature(globs, slicing_syntax)]
#![feature(unboxed_closures)]
#![deny(missing_docs)]

#[cfg(test)] #[phase(plugin, link)] extern crate log;
#[cfg(test)] #[macro_use] extern crate log;

use self::Name::*;
use self::HasArg::*;
Expand Down
3 changes: 1 addition & 2 deletions src/liblog/lib.rs
Expand Up @@ -13,8 +13,7 @@
//! # Examples
//!
//! ```
//! #![feature(phase)]
//! #[phase(plugin, link)] extern crate log;
//! #[macro_use] extern crate log;
//!
//! fn main() {
//! debug!("this is a debug {}", "message");
Expand Down
18 changes: 6 additions & 12 deletions src/liblog/macros.rs
Expand Up @@ -19,8 +19,7 @@
/// # Example
///
/// ```
/// #![feature(phase)]
/// #[phase(plugin, link)] extern crate log;
/// #[macro_use] extern crate log;
///
/// fn main() {
/// log!(log::WARN, "this is a warning {}", "message");
Expand Down Expand Up @@ -68,8 +67,7 @@ macro_rules! log {
/// # Example
///
/// ```
/// #![feature(phase)]
/// #[phase(plugin, link)] extern crate log;
/// #[macro_use] extern crate log;
///
/// fn main() {
/// let error = 3u;
Expand All @@ -94,8 +92,7 @@ macro_rules! error {
/// # Example
///
/// ```
/// #![feature(phase)]
/// #[phase(plugin, link)] extern crate log;
/// #[macro_use] extern crate log;
///
/// fn main() {
/// let code = 3u;
Expand All @@ -119,8 +116,7 @@ macro_rules! warn {
/// # Example
///
/// ```
/// #![feature(phase)]
/// #[phase(plugin, link)] extern crate log;
/// #[macro_use] extern crate log;
///
/// fn main() {
/// let ret = 3i;
Expand All @@ -146,8 +142,7 @@ macro_rules! info {
/// # Example
///
/// ```
/// #![feature(phase)]
/// #[phase(plugin, link)] extern crate log;
/// #[macro_use] extern crate log;
///
/// fn main() {
/// debug!("x = {x}, y = {y}", x=10i, y=20i);
Expand All @@ -170,8 +165,7 @@ macro_rules! debug {
/// # Example
///
/// ```
/// #![feature(phase)]
/// #[phase(plugin, link)] extern crate log;
/// #[macro_use] extern crate log;
///
/// struct Point { x: int, y: int }
/// fn some_expensive_computation() -> Point { Point { x: 1, y: 2 } }
Expand Down
22 changes: 20 additions & 2 deletions src/librand/lib.rs
Expand Up @@ -29,11 +29,29 @@
#![no_std]
#![experimental]

#[cfg(stage0)]
#[phase(plugin, link)]
extern crate core;

#[cfg(test)] #[phase(plugin, link)] extern crate std;
#[cfg(test)] #[phase(plugin, link)] extern crate log;
#[cfg(not(stage0))]
#[macro_use]
extern crate core;

#[cfg(all(test, stage0))]
#[phase(plugin, link)]
extern crate std;

#[cfg(all(test, not(stage0)))]
#[macro_use]
extern crate std;

#[cfg(all(test, stage0))]
#[phase(plugin, link)]
extern crate log;

#[cfg(all(test, not(stage0)))]
#[macro_use]
extern crate log;

use core::prelude::*;

Expand Down
9 changes: 8 additions & 1 deletion src/librbml/lib.rs
Expand Up @@ -30,7 +30,14 @@

extern crate serialize;

#[phase(plugin, link)] extern crate log;
#[cfg(stage0)]
#[phase(plugin, link)]
extern crate log;

#[cfg(not(stage0))]
#[macro_use]
extern crate log;

#[cfg(test)] extern crate test;

pub use self::EbmlEncoderTag::*;
Expand Down
2 changes: 1 addition & 1 deletion src/libregex/lib.rs
Expand Up @@ -24,7 +24,7 @@
html_playground_url = "http://play.rust-lang.org/")]

#![allow(unknown_features)]
#![feature(macro_rules, phase, slicing_syntax, globs)]
#![feature(macro_rules, slicing_syntax, globs)]
#![feature(unboxed_closures)]
#![feature(associated_types)]
#![deny(missing_docs)]
Expand Down
18 changes: 16 additions & 2 deletions src/librustc/lib.rs
Expand Up @@ -40,8 +40,22 @@ extern crate rustc_back;
extern crate serialize;
extern crate rbml;
extern crate collections;
#[phase(plugin, link)] extern crate log;
#[phase(plugin, link)] extern crate syntax;

#[cfg(stage0)]
#[phase(plugin, link)]
extern crate log;

#[cfg(not(stage0))]
#[macro_use]
extern crate log;

#[cfg(stage0)]
#[phase(plugin, link)]
extern crate syntax;

#[cfg(not(stage0))]
#[macro_use]
extern crate syntax;

extern crate "serialize" as rustc_serialize; // used by deriving

Expand Down
7 changes: 1 addition & 6 deletions src/librustc/metadata/creader.rs
Expand Up @@ -89,12 +89,7 @@ fn warn_if_multiple_versions(diag: &SpanHandler, cstore: &CStore) {
}

fn should_link(i: &ast::ViewItem) -> bool {
i.attrs.iter().all(|attr| {
attr.name().get() != "phase" ||
attr.meta_item_list().map_or(false, |phases| {
attr::contains_name(phases[], "link")
})
})
!attr::contains_name(i.attrs[], "no_link")
}

struct CrateInfo {
Expand Down
34 changes: 22 additions & 12 deletions src/librustc/plugin/load.rs
Expand Up @@ -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());
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/plugin/mod.rs
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions src/librustc_back/lib.rs
Expand Up @@ -34,8 +34,14 @@
#![feature(unboxed_closures)]
#![feature(old_orphan_check)]

#[cfg(stage0)]
#[phase(plugin, link)]
extern crate log;

#[cfg(not(stage0))]
#[macro_use]
extern crate log;

extern crate syntax;
extern crate serialize;

Expand Down

0 comments on commit 60be2f5

Please sign in to comment.