Skip to content

Commit 60be2f5

Browse files
author
Keegan McAllister
committed
Replace #[phase] with #[plugin] / #[macro_use] / #[no_link]
1 parent f314e2c commit 60be2f5

File tree

82 files changed

+363
-236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+363
-236
lines changed

src/compiletest/compiletest.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@
1515

1616
extern crate test;
1717
extern crate getopts;
18-
#[phase(plugin, link)] extern crate log;
18+
19+
#[cfg(stage0)]
20+
#[phase(plugin, link)]
21+
extern crate log;
22+
23+
#[cfg(not(stage0))]
24+
#[macro_use]
25+
extern crate log;
1926

2027
extern crate regex;
2128

src/grammar/verify.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(globs, phase, macro_rules)]
11+
#![feature(globs, plugin, macro_rules)]
1212

1313
extern crate syntax;
1414
extern crate rustc;
1515

16-
#[phase(link)]
1716
extern crate regex;
1817

19-
#[phase(link, plugin)]
18+
#[macro_use]
2019
extern crate log;
2120

2221
use std::collections::HashMap;

src/liballoc/lib.rs

+21-2
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,33 @@
6868
#![feature(lang_items, phase, unsafe_destructor, default_type_params, old_orphan_check)]
6969
#![feature(associated_types)]
7070

71+
#[cfg(stage0)]
7172
#[phase(plugin, link)]
7273
extern crate core;
74+
75+
#[cfg(not(stage0))]
76+
#[macro_use]
77+
extern crate core;
78+
7379
extern crate libc;
7480

7581
// Allow testing this library
7682

77-
#[cfg(test)] #[phase(plugin, link)] extern crate std;
78-
#[cfg(test)] #[phase(plugin, link)] extern crate log;
83+
#[cfg(all(test, stage0))]
84+
#[phase(plugin, link)]
85+
extern crate std;
86+
87+
#[cfg(all(test, not(stage0)))]
88+
#[macro_use]
89+
extern crate std;
90+
91+
#[cfg(all(test, stage0))]
92+
#[phase(plugin, link)]
93+
extern crate log;
94+
95+
#[cfg(all(test, not(stage0)))]
96+
#[macro_use]
97+
extern crate log;
7998

8099
// Heaps provided for low-level allocation strategies
81100

src/libcollections/lib.rs

+22-3
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,34 @@
2929
#![feature(associated_types)]
3030
#![no_std]
3131

32-
#[phase(plugin, link)] extern crate core;
32+
#[cfg(stage0)]
33+
#[phase(plugin, link)]
34+
extern crate core;
35+
36+
#[cfg(not(stage0))]
37+
#[macro_use]
38+
extern crate core;
39+
3340
extern crate unicode;
3441
extern crate alloc;
3542

3643
#[cfg(test)] extern crate test;
3744

38-
#[cfg(test)] #[phase(plugin, link)] extern crate std;
39-
#[cfg(test)] #[phase(plugin, link)] extern crate log;
45+
#[cfg(all(test, stage0))]
46+
#[phase(plugin, link)]
47+
extern crate std;
48+
49+
#[cfg(all(test, not(stage0)))]
50+
#[macro_use]
51+
extern crate std;
52+
53+
#[cfg(all(test, stage0))]
54+
#[phase(plugin, link)]
55+
extern crate log;
4056

57+
#[cfg(all(test, not(stage0)))]
58+
#[macro_use]
59+
extern crate log;
4160

4261
pub use binary_heap::BinaryHeap;
4362
pub use bitv::Bitv;

src/libflate/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2222
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2323
html_root_url = "http://doc.rust-lang.org/nightly/")]
24-
#![feature(phase, unboxed_closures)]
24+
#![feature(unboxed_closures)]
2525

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

2828
extern crate libc;
2929

src/libgetopts/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@
8585
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
8686
html_root_url = "http://doc.rust-lang.org/nightly/",
8787
html_playground_url = "http://play.rust-lang.org/")]
88-
#![feature(globs, phase, slicing_syntax)]
88+
#![feature(globs, slicing_syntax)]
8989
#![feature(unboxed_closures)]
9090
#![deny(missing_docs)]
9191

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

9494
use self::Name::*;
9595
use self::HasArg::*;

src/liblog/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
//! # Examples
1414
//!
1515
//! ```
16-
//! #![feature(phase)]
17-
//! #[phase(plugin, link)] extern crate log;
16+
//! #[macro_use] extern crate log;
1817
//!
1918
//! fn main() {
2019
//! debug!("this is a debug {}", "message");

src/liblog/macros.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
/// # Example
2020
///
2121
/// ```
22-
/// #![feature(phase)]
23-
/// #[phase(plugin, link)] extern crate log;
22+
/// #[macro_use] extern crate log;
2423
///
2524
/// fn main() {
2625
/// log!(log::WARN, "this is a warning {}", "message");
@@ -68,8 +67,7 @@ macro_rules! log {
6867
/// # Example
6968
///
7069
/// ```
71-
/// #![feature(phase)]
72-
/// #[phase(plugin, link)] extern crate log;
70+
/// #[macro_use] extern crate log;
7371
///
7472
/// fn main() {
7573
/// let error = 3u;
@@ -94,8 +92,7 @@ macro_rules! error {
9492
/// # Example
9593
///
9694
/// ```
97-
/// #![feature(phase)]
98-
/// #[phase(plugin, link)] extern crate log;
95+
/// #[macro_use] extern crate log;
9996
///
10097
/// fn main() {
10198
/// let code = 3u;
@@ -119,8 +116,7 @@ macro_rules! warn {
119116
/// # Example
120117
///
121118
/// ```
122-
/// #![feature(phase)]
123-
/// #[phase(plugin, link)] extern crate log;
119+
/// #[macro_use] extern crate log;
124120
///
125121
/// fn main() {
126122
/// let ret = 3i;
@@ -146,8 +142,7 @@ macro_rules! info {
146142
/// # Example
147143
///
148144
/// ```
149-
/// #![feature(phase)]
150-
/// #[phase(plugin, link)] extern crate log;
145+
/// #[macro_use] extern crate log;
151146
///
152147
/// fn main() {
153148
/// debug!("x = {x}, y = {y}", x=10i, y=20i);
@@ -170,8 +165,7 @@ macro_rules! debug {
170165
/// # Example
171166
///
172167
/// ```
173-
/// #![feature(phase)]
174-
/// #[phase(plugin, link)] extern crate log;
168+
/// #[macro_use] extern crate log;
175169
///
176170
/// struct Point { x: int, y: int }
177171
/// fn some_expensive_computation() -> Point { Point { x: 1, y: 2 } }

src/librand/lib.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,29 @@
2929
#![no_std]
3030
#![experimental]
3131

32+
#[cfg(stage0)]
3233
#[phase(plugin, link)]
3334
extern crate core;
3435

35-
#[cfg(test)] #[phase(plugin, link)] extern crate std;
36-
#[cfg(test)] #[phase(plugin, link)] extern crate log;
36+
#[cfg(not(stage0))]
37+
#[macro_use]
38+
extern crate core;
39+
40+
#[cfg(all(test, stage0))]
41+
#[phase(plugin, link)]
42+
extern crate std;
43+
44+
#[cfg(all(test, not(stage0)))]
45+
#[macro_use]
46+
extern crate std;
47+
48+
#[cfg(all(test, stage0))]
49+
#[phase(plugin, link)]
50+
extern crate log;
51+
52+
#[cfg(all(test, not(stage0)))]
53+
#[macro_use]
54+
extern crate log;
3755

3856
use core::prelude::*;
3957

src/librbml/lib.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@
3030

3131
extern crate serialize;
3232

33-
#[phase(plugin, link)] extern crate log;
33+
#[cfg(stage0)]
34+
#[phase(plugin, link)]
35+
extern crate log;
36+
37+
#[cfg(not(stage0))]
38+
#[macro_use]
39+
extern crate log;
40+
3441
#[cfg(test)] extern crate test;
3542

3643
pub use self::EbmlEncoderTag::*;

src/libregex/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
html_playground_url = "http://play.rust-lang.org/")]
2525

2626
#![allow(unknown_features)]
27-
#![feature(macro_rules, phase, slicing_syntax, globs)]
27+
#![feature(macro_rules, slicing_syntax, globs)]
2828
#![feature(unboxed_closures)]
2929
#![feature(associated_types)]
3030
#![deny(missing_docs)]

src/librustc/lib.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,22 @@ extern crate rustc_back;
4040
extern crate serialize;
4141
extern crate rbml;
4242
extern crate collections;
43-
#[phase(plugin, link)] extern crate log;
44-
#[phase(plugin, link)] extern crate syntax;
43+
44+
#[cfg(stage0)]
45+
#[phase(plugin, link)]
46+
extern crate log;
47+
48+
#[cfg(not(stage0))]
49+
#[macro_use]
50+
extern crate log;
51+
52+
#[cfg(stage0)]
53+
#[phase(plugin, link)]
54+
extern crate syntax;
55+
56+
#[cfg(not(stage0))]
57+
#[macro_use]
58+
extern crate syntax;
4559

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

src/librustc/metadata/creader.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,7 @@ fn warn_if_multiple_versions(diag: &SpanHandler, cstore: &CStore) {
8989
}
9090

9191
fn should_link(i: &ast::ViewItem) -> bool {
92-
i.attrs.iter().all(|attr| {
93-
attr.name().get() != "phase" ||
94-
attr.meta_item_list().map_or(false, |phases| {
95-
attr::contains_name(phases[], "link")
96-
})
97-
})
92+
!attr::contains_name(i.attrs[], "no_link")
9893
}
9994

10095
struct CrateInfo {

src/librustc/plugin/load.rs

+22-12
Original file line numberDiff line numberDiff line change
@@ -84,26 +84,36 @@ impl<'a, 'v> Visitor<'v> for PluginLoader<'a> {
8484
_ => return,
8585
}
8686

87-
let mut plugin_phase = false;
88-
for attr in vi.attrs.iter().filter(|a| a.check_name("phase")) {
89-
let phases = attr.meta_item_list().unwrap_or(&[]);
90-
if attr::contains_name(phases, "plugin") {
91-
plugin_phase = true;
87+
// Parse the attributes relating to macro / plugin loading.
88+
let mut load_macros = false;
89+
let mut load_registrar = false;
90+
for attr in vi.attrs.iter() {
91+
let mut used = true;
92+
match attr.name().get() {
93+
"phase" => {
94+
self.sess.span_err(attr.span, "#[phase] is deprecated; use \
95+
#[macro_use], #[plugin], and/or #[no_link]");
96+
}
97+
"plugin" => load_registrar = true,
98+
"macro_use" => load_macros = true,
99+
_ => used = false,
92100
}
93-
if attr::contains_name(phases, "syntax") {
94-
plugin_phase = true;
95-
self.sess.span_warn(attr.span,
96-
"phase(syntax) is a deprecated synonym for phase(plugin)");
101+
if used {
102+
attr::mark_used(attr);
97103
}
98104
}
99105

100106
let mut macros = vec![];
101107
let mut registrar = None;
102108

103-
if plugin_phase {
109+
if load_macros || load_registrar {
104110
let pmd = self.reader.read_plugin_metadata(vi);
105-
macros = pmd.exported_macros();
106-
registrar = pmd.plugin_registrar();
111+
if load_macros {
112+
macros = pmd.exported_macros();
113+
}
114+
if load_registrar {
115+
registrar = pmd.plugin_registrar();
116+
}
107117
}
108118

109119
self.plugins.macros.extend(macros.into_iter());

src/librustc/plugin/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@
4343
//! To use a plugin while compiling another crate:
4444
//!
4545
//! ```rust
46-
//! #![feature(phase)]
46+
//! #![feature(plugin)]
4747
//!
48-
//! #[phase(plugin)]
48+
//! #[plugin]
4949
//! extern crate myplugin;
5050
//! ```
5151
//!
52-
//! If you also need the plugin crate available at runtime, use
53-
//! `phase(plugin, link)`.
52+
//! If you don't need the plugin crate available at runtime, use
53+
//! `#[no_link]` as well.
5454
//!
5555
//! See [the compiler plugin guide](../../guide-plugin.html)
5656
//! for more examples.

src/librustc_back/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@
3434
#![feature(unboxed_closures)]
3535
#![feature(old_orphan_check)]
3636

37+
#[cfg(stage0)]
3738
#[phase(plugin, link)]
3839
extern crate log;
40+
41+
#[cfg(not(stage0))]
42+
#[macro_use]
43+
extern crate log;
44+
3945
extern crate syntax;
4046
extern crate serialize;
4147

0 commit comments

Comments
 (0)