mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
move librustc/plugin to librustc_plugin
this is a [breaking-change] to all plugin authors - sorry
This commit is contained in:
parent
26b19206d3
commit
1430a35000
@ -56,7 +56,8 @@ TARGET_CRATES := libc std flate arena term \
|
||||
alloc_system
|
||||
RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_driver \
|
||||
rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \
|
||||
rustc_data_structures rustc_front rustc_platform_intrinsics
|
||||
rustc_data_structures rustc_front rustc_platform_intrinsics \
|
||||
rustc_plugin
|
||||
HOST_CRATES := syntax $(RUSTC_CRATES) rustdoc fmt_macros
|
||||
TOOLS := compiletest rustdoc rustc rustbook error-index-generator
|
||||
|
||||
@ -94,7 +95,7 @@ DEPS_rustc_borrowck := rustc rustc_front log graphviz syntax
|
||||
DEPS_rustc_data_structures := std log serialize
|
||||
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
|
||||
rustc_typeck rustc_mir rustc_resolve log syntax serialize rustc_llvm \
|
||||
rustc_trans rustc_privacy rustc_lint rustc_front
|
||||
rustc_trans rustc_privacy rustc_lint rustc_front rustc_plugin
|
||||
|
||||
DEPS_rustc_front := std syntax log serialize
|
||||
DEPS_rustc_lint := rustc log syntax
|
||||
@ -102,6 +103,7 @@ DEPS_rustc_llvm := native:rustllvm libc std rustc_bitflags
|
||||
DEPS_rustc_mir := rustc rustc_front syntax
|
||||
DEPS_rustc_resolve := rustc rustc_front log syntax
|
||||
DEPS_rustc_platform_intrinsics := rustc rustc_llvm
|
||||
DEPS_rustc_plugin := rustc syntax
|
||||
DEPS_rustc_privacy := rustc rustc_front log syntax
|
||||
DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back rustc_mir \
|
||||
log syntax serialize rustc_llvm rustc_front rustc_platform_intrinsics
|
||||
|
@ -8,12 +8,12 @@ extend the compiler's behavior with new syntax extensions, lint checks, etc.
|
||||
A plugin is a dynamic library crate with a designated *registrar* function that
|
||||
registers extensions with `rustc`. Other crates can load these extensions using
|
||||
the crate attribute `#![plugin(...)]`. See the
|
||||
[`rustc::plugin`](../rustc/plugin/index.html) documentation for more about the
|
||||
[`rustc_plugin`](../rustc_plugin/index.html) documentation for more about the
|
||||
mechanics of defining and loading a plugin.
|
||||
|
||||
If present, arguments passed as `#![plugin(foo(... args ...))]` are not
|
||||
interpreted by rustc itself. They are provided to the plugin through the
|
||||
`Registry`'s [`args` method](../rustc/plugin/registry/struct.Registry.html#method.args).
|
||||
`Registry`'s [`args` method](../rustc_plugin/registry/struct.Registry.html#method.args).
|
||||
|
||||
In the vast majority of cases, a plugin should *only* be used through
|
||||
`#![plugin]` and not through an `extern crate` item. Linking a plugin would
|
||||
@ -43,13 +43,14 @@ that implements Roman numeral integer literals.
|
||||
|
||||
extern crate syntax;
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token;
|
||||
use syntax::ast::TokenTree;
|
||||
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
|
||||
use syntax::ext::build::AstBuilder; // trait for expr_usize
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
|
||||
-> Box<MacResult + 'static> {
|
||||
@ -120,7 +121,7 @@ The advantages over a simple `fn(&str) -> u32` are:
|
||||
In addition to procedural macros, you can define new
|
||||
[`derive`](../reference.html#derive)-like attributes and other kinds of
|
||||
extensions. See
|
||||
[`Registry::register_syntax_extension`](../rustc/plugin/registry/struct.Registry.html#method.register_syntax_extension)
|
||||
[`Registry::register_syntax_extension`](../rustc_plugin/registry/struct.Registry.html#method.register_syntax_extension)
|
||||
and the [`SyntaxExtension`
|
||||
enum](https://doc.rust-lang.org/syntax/ext/base/enum.SyntaxExtension.html). For
|
||||
a more involved macro example, see
|
||||
@ -189,10 +190,11 @@ extern crate syntax;
|
||||
// Load rustc as a plugin to get macros
|
||||
#[macro_use]
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass,
|
||||
EarlyLintPassObject, LintArray};
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
use syntax::ast;
|
||||
|
||||
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
|
||||
|
@ -2181,6 +2181,5 @@ register_diagnostics! {
|
||||
E0491, // in type `..`, reference has a longer lifetime than the data it...
|
||||
E0492, // cannot borrow a constant which contains interior mutability
|
||||
E0495, // cannot infer an appropriate lifetime due to conflicting requirements
|
||||
E0498, // malformed plugin attribute
|
||||
E0514, // metadata version mismatch
|
||||
}
|
||||
|
@ -33,7 +33,6 @@
|
||||
#![feature(const_fn)]
|
||||
#![feature(core)]
|
||||
#![feature(duration_span)]
|
||||
#![feature(dynamic_lib)]
|
||||
#![feature(enumset)]
|
||||
#![feature(hashmap_hasher)]
|
||||
#![feature(into_cow)]
|
||||
@ -100,8 +99,8 @@ pub mod front {
|
||||
}
|
||||
|
||||
pub mod middle {
|
||||
pub mod expr_use_visitor; // STAGE0: increase glitch immunity
|
||||
pub mod astconv_util;
|
||||
pub mod expr_use_visitor; // STAGE0: increase glitch immunity
|
||||
pub mod astencode;
|
||||
pub mod cfg;
|
||||
pub mod check_const;
|
||||
@ -142,8 +141,6 @@ pub mod metadata;
|
||||
|
||||
pub mod session;
|
||||
|
||||
pub mod plugin;
|
||||
|
||||
pub mod lint;
|
||||
|
||||
pub mod util {
|
||||
|
@ -22,8 +22,6 @@ use rustc::metadata::cstore::CStore;
|
||||
use rustc::middle::{stability, ty, reachable};
|
||||
use rustc::middle::dependency_format;
|
||||
use rustc::middle;
|
||||
use rustc::plugin::registry::Registry;
|
||||
use rustc::plugin;
|
||||
use rustc::util::nodemap::NodeMap;
|
||||
use rustc::util::common::time;
|
||||
use rustc_borrowck as borrowck;
|
||||
@ -33,6 +31,8 @@ use rustc_trans::back::write;
|
||||
use rustc_trans::trans;
|
||||
use rustc_typeck as typeck;
|
||||
use rustc_privacy;
|
||||
use rustc_plugin::registry::Registry;
|
||||
use rustc_plugin as plugin;
|
||||
use rustc_front::hir;
|
||||
use rustc_front::lowering::{lower_crate, LoweringContext};
|
||||
use super::Compilation;
|
||||
|
@ -45,6 +45,7 @@ extern crate rustc_back;
|
||||
extern crate rustc_borrowck;
|
||||
extern crate rustc_front;
|
||||
extern crate rustc_lint;
|
||||
extern crate rustc_plugin;
|
||||
extern crate rustc_privacy;
|
||||
extern crate rustc_mir;
|
||||
extern crate rustc_resolve;
|
||||
|
@ -13,7 +13,7 @@
|
||||
//! This currently only contains the definitions and implementations
|
||||
//! of most of the lints that `rustc` supports directly, it does not
|
||||
//! contain the infrastructure for defining/registering lints. That is
|
||||
//! available in `rustc::lint` and `rustc::plugin` respectively.
|
||||
//! available in `rustc::lint` and `rustc_plugin` respectively.
|
||||
//!
|
||||
//! # Note
|
||||
//!
|
||||
|
19
src/librustc_plugin/diagnostics.rs
Normal file
19
src/librustc_plugin/diagnostics.rs
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2015 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.
|
||||
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
register_long_diagnostics! {
|
||||
|
||||
}
|
||||
|
||||
register_diagnostics! {
|
||||
E0498 // malformed plugin attribute
|
||||
}
|
@ -50,8 +50,31 @@
|
||||
//! See the [Plugins Chapter](../../book/compiler-plugins.html) of the book
|
||||
//! for more examples.
|
||||
|
||||
#![cfg_attr(stage0, feature(custom_attribute))]
|
||||
#![crate_name = "rustc_plugin"]
|
||||
#![unstable(feature = "rustc_private", issue = "27812")]
|
||||
#![cfg_attr(stage0, staged_api)]
|
||||
#![crate_type = "dylib"]
|
||||
#![crate_type = "rlib"]
|
||||
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
||||
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
|
||||
html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
|
||||
#![feature(dynamic_lib)]
|
||||
#![feature(staged_api)]
|
||||
#![feature(rustc_diagnostic_macros)]
|
||||
#![feature(rustc_private)]
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
#[macro_use] extern crate syntax;
|
||||
#[macro_use] #[no_link] extern crate rustc_bitflags;
|
||||
|
||||
extern crate rustc;
|
||||
extern crate rustc_front;
|
||||
|
||||
pub use self::registry::Registry;
|
||||
|
||||
pub mod diagnostics;
|
||||
pub mod registry;
|
||||
pub mod load;
|
||||
pub mod build;
|
@ -10,10 +10,10 @@
|
||||
|
||||
//! Used by `rustc` when loading a plugin.
|
||||
|
||||
use session::Session;
|
||||
use metadata::creader::CrateReader;
|
||||
use metadata::cstore::CStore;
|
||||
use plugin::registry::Registry;
|
||||
use rustc::session::Session;
|
||||
use rustc::metadata::creader::CrateReader;
|
||||
use rustc::metadata::cstore::CStore;
|
||||
use registry::Registry;
|
||||
|
||||
use std::borrow::ToOwned;
|
||||
use std::env;
|
@ -10,8 +10,8 @@
|
||||
|
||||
//! Used by plugin crates to tell `rustc` about the plugins they provide.
|
||||
|
||||
use lint::{EarlyLintPassObject, LateLintPassObject, LintId, Lint};
|
||||
use session::Session;
|
||||
use rustc::lint::{EarlyLintPassObject, LateLintPassObject, LintId, Lint};
|
||||
use rustc::session::Session;
|
||||
|
||||
use syntax::ext::base::{SyntaxExtension, NamedSyntaxExtension, NormalTT};
|
||||
use syntax::ext::base::{IdentTT, MultiModifier, MultiDecorator};
|
@ -16,9 +16,10 @@
|
||||
extern crate syntax;
|
||||
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use syntax::feature_gate::AttributeType;
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
extern crate syntax;
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
@ -25,7 +26,7 @@ use syntax::ext::deriving::generic::{cs_fold, TraitDef, MethodDef, combine_subst
|
||||
use syntax::ext::deriving::generic::ty::{Literal, LifetimeBounds, Path, borrowed_explicit_self};
|
||||
use syntax::parse::token;
|
||||
use syntax::ptr::P;
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(reg: &mut Registry) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
extern crate syntax;
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::attr::AttrMetaMethods;
|
||||
@ -27,7 +28,7 @@ use syntax::ext::deriving::generic::{Substructure, Struct, EnumMatching};
|
||||
use syntax::ext::deriving::generic::ty::{Literal, LifetimeBounds, Path, borrowed_explicit_self};
|
||||
use syntax::parse::token;
|
||||
use syntax::ptr::P;
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(reg: &mut Registry) {
|
||||
|
@ -15,12 +15,13 @@
|
||||
|
||||
extern crate syntax;
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::codemap;
|
||||
use syntax::ext::base::{ExtCtxt, MacResult, MacEager};
|
||||
use syntax::util::small_vector::SmallVector;
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(reg: &mut Registry) {
|
||||
|
@ -15,10 +15,11 @@
|
||||
|
||||
#[macro_use] extern crate rustc;
|
||||
extern crate rustc_front;
|
||||
extern crate rustc_plugin;
|
||||
extern crate syntax;
|
||||
|
||||
use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LateLintPassObject, LintArray};
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
use rustc_front::hir;
|
||||
use syntax::attr;
|
||||
|
||||
|
@ -18,10 +18,11 @@ extern crate rustc_front;
|
||||
// Load rustc as a plugin to get macros
|
||||
#[macro_use]
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use rustc_front::hir;
|
||||
use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LateLintPassObject, LintArray};
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
|
||||
|
||||
|
@ -18,10 +18,11 @@ extern crate syntax;
|
||||
// Load rustc as a plugin to get macros
|
||||
#[macro_use]
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass,
|
||||
EarlyLintPassObject, LintArray};
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
use syntax::ast;
|
||||
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
|
||||
|
||||
|
@ -14,8 +14,9 @@
|
||||
#![feature(rustc_private)]
|
||||
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(reg: &mut Registry) {
|
||||
|
@ -14,8 +14,9 @@
|
||||
#![feature(rustc_private)]
|
||||
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(_reg: &mut Registry) {}
|
||||
|
@ -14,10 +14,11 @@
|
||||
|
||||
extern crate syntax;
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use syntax::parse::token;
|
||||
use syntax::ext::base::MacroRulesTT;
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(reg: &mut Registry) {
|
||||
|
@ -14,13 +14,14 @@
|
||||
|
||||
extern crate syntax;
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use syntax::ast::{self, TokenTree, Item, MetaItem, ImplItem, TraitItem};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::ext::base::*;
|
||||
use syntax::parse::{self, token};
|
||||
use syntax::ptr::P;
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! exported_macro { () => (2) }
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
extern crate syntax;
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use std::borrow::ToOwned;
|
||||
use syntax::ast;
|
||||
@ -24,7 +25,7 @@ use syntax::ext::base::{TTMacroExpander, ExtCtxt, MacResult, MacEager, NormalTT}
|
||||
use syntax::parse::token;
|
||||
use syntax::print::pprust;
|
||||
use syntax::ptr::P;
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
struct Expander {
|
||||
args: Vec<P<ast::MetaItem>>,
|
||||
|
@ -14,10 +14,11 @@
|
||||
#![feature(box_syntax, rustc_private)]
|
||||
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use std::any::Any;
|
||||
use std::cell::RefCell;
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
struct Foo {
|
||||
foo: isize
|
||||
|
@ -15,8 +15,9 @@
|
||||
|
||||
extern crate macro_crate_test;
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(_: &mut Registry) { }
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
extern crate syntax;
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use syntax::codemap::Span;
|
||||
use syntax::parse::token::{self, str_to_ident, NtExpr, NtPat};
|
||||
@ -24,7 +25,7 @@ use syntax::ext::build::AstBuilder;
|
||||
use syntax::ext::tt::macro_parser::{MatchedSeq, MatchedNonterminal};
|
||||
use syntax::ext::tt::macro_parser::{Success, Failure, Error};
|
||||
use syntax::ptr::P;
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
fn expand_mbe_matches(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
|
||||
-> Box<MacResult + 'static> {
|
||||
|
@ -14,8 +14,9 @@
|
||||
#![feature(plugin_registrar, rustc_private)]
|
||||
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(_: &mut Registry) {}
|
||||
|
@ -16,13 +16,14 @@
|
||||
|
||||
extern crate syntax;
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use syntax::codemap::Span;
|
||||
use syntax::ast::TokenTree;
|
||||
use syntax::parse::token;
|
||||
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
|
||||
use syntax::ext::build::AstBuilder; // trait for expr_usize
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
// WARNING WARNING WARNING WARNING WARNING
|
||||
// =======================================
|
||||
|
@ -16,11 +16,12 @@
|
||||
extern crate syntax_extension_with_dll_deps_1 as other;
|
||||
extern crate syntax;
|
||||
extern crate rustc;
|
||||
extern crate rustc_plugin;
|
||||
|
||||
use syntax::ast::{TokenTree, Item, MetaItem};
|
||||
use syntax::codemap::Span;
|
||||
use syntax::ext::base::*;
|
||||
use rustc::plugin::Registry;
|
||||
use rustc_plugin::Registry;
|
||||
|
||||
#[plugin_registrar]
|
||||
pub fn plugin_registrar(reg: &mut Registry) {
|
||||
|
Loading…
Reference in New Issue
Block a user