Use a crate attribute to load plugins

#[plugin] #[no_link] extern crate bleh;

becomes a crate attribute

    #![plugin(bleh)]

The feature gate is still required.

It's almost never correct to link a plugin into the resulting library /
executable, because it will bring all of libsyntax and librustc with it.
However if you really want this behavior, you can get it with a separate
`extern crate` item in addition to the `plugin` attribute.

Fixes #21043.
Fixes #20769.

[breaking-change]
This commit is contained in:
Keegan McAllister
2015-02-06 13:56:38 -08:00
parent 0ba9e1fa52
commit 93b642d974
37 changed files with 152 additions and 165 deletions

View File

@@ -284,11 +284,7 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
}
match i.node {
ast::ItemExternCrate(_) => {
if attr::contains_name(&i.attrs[], "plugin") {
self.gate_feature("plugin", i.span,
"compiler plugins are experimental \
and possibly buggy");
} else if attr::contains_name(&i.attrs[], "macro_reexport") {
if attr::contains_name(&i.attrs[], "macro_reexport") {
self.gate_feature("macro_reexport", i.span,
"macros reexports are experimental \
and possibly buggy");
@@ -462,6 +458,10 @@ impl<'a, 'v> Visitor<'v> for PostExpansionVisitor<'a> {
if attr.check_name("staged_api") {
self.gate_feature("staged_api", attr.span,
"staged_api is for use by rustc only");
} else if attr.check_name("plugin") {
self.gate_feature("plugin", attr.span,
"compiler plugins are experimental \
and possibly buggy");
}
if attr::contains_name(slice::ref_slice(attr), "lang") {