Skip to content

Commit

Permalink
Deprecate using rustc_plugin without the rustc_driver dylib.
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Aug 19, 2019
1 parent 29a5403 commit d0bbc60
Show file tree
Hide file tree
Showing 25 changed files with 52 additions and 41 deletions.
5 changes: 3 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3189,6 +3189,7 @@ dependencies = [
"rustc_interface",
"rustc_metadata",
"rustc_mir",
"rustc_plugin_impl",
"rustc_save_analysis",
"rustc_target",
"serialize",
Expand Down Expand Up @@ -3246,7 +3247,7 @@ dependencies = [
"rustc_metadata",
"rustc_mir",
"rustc_passes",
"rustc_plugin",
"rustc_plugin_impl",
"rustc_privacy",
"rustc_resolve",
"rustc_traits",
Expand Down Expand Up @@ -3372,7 +3373,7 @@ dependencies = [
]

[[package]]
name = "rustc_plugin"
name = "rustc_plugin_impl"
version = "0.0.0"
dependencies = [
"rustc",
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc-ux-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ for details on how to format and write long error codes.
[librustc_privacy](https://github.com/rust-lang/rust/blob/master/src/librustc_privacy/error_codes.rs),
[librustc_resolve](https://github.com/rust-lang/rust/blob/master/src/librustc_resolve/error_codes.rs),
[librustc_codegen_llvm](https://github.com/rust-lang/rust/blob/master/src/librustc_codegen_llvm/error_codes.rs),
[librustc_plugin](https://github.com/rust-lang/rust/blob/master/src/librustc_plugin/error_codes.rs),
[librustc_plugin_impl](https://github.com/rust-lang/rust/blob/master/src/librustc_plugin/error_codes.rs),
[librustc_typeck](https://github.com/rust-lang/rust/blob/master/src/librustc_typeck/error_codes.rs).
* Explanations have full markdown support. Use it, especially to highlight
code with backticks.
Expand Down
10 changes: 5 additions & 5 deletions src/doc/unstable-book/src/language-features/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ 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` documentation for more about the
`rustc_driver::plugin` documentation for more about the
mechanics of defining and loading a plugin.

If present, arguments passed as `#![plugin(foo(... args ...))]` are not
Expand Down Expand Up @@ -54,13 +54,13 @@ that implements Roman numeral integer literals.
extern crate syntax;
extern crate syntax_pos;
extern crate rustc;
extern crate rustc_plugin;
extern crate rustc_driver;
use syntax::parse::token::{self, Token};
use syntax::tokenstream::TokenTree;
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
use syntax_pos::Span;
use rustc_plugin::Registry;
use rustc_driver::plugin::Registry;
fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
-> Box<dyn MacResult + 'static> {
Expand Down Expand Up @@ -180,11 +180,11 @@ extern crate syntax;
// Load rustc as a plugin to get macros
#[macro_use]
extern crate rustc;
extern crate rustc_plugin;
extern crate rustc_driver;
use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass,
EarlyLintPassObject, LintArray};
use rustc_plugin::Registry;
use rustc_driver::plugin::Registry;
use syntax::ast;
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
Expand Down
1 change: 1 addition & 0 deletions src/librustc_driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ rustc_data_structures = { path = "../librustc_data_structures" }
errors = { path = "../librustc_errors", package = "rustc_errors" }
rustc_metadata = { path = "../librustc_metadata" }
rustc_mir = { path = "../librustc_mir" }
rustc_plugin_impl = { path = "../librustc_plugin" }
rustc_save_analysis = { path = "../librustc_save_analysis" }
rustc_codegen_utils = { path = "../librustc_codegen_utils" }
rustc_interface = { path = "../librustc_interface" }
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ extern crate libc;
#[macro_use]
extern crate log;

pub extern crate rustc_plugin_impl as plugin;

use pretty::{PpMode, UserIdentifiedItem};

//use rustc_resolve as resolve;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ rustc_passes = { path = "../librustc_passes" }
rustc_typeck = { path = "../librustc_typeck" }
rustc_lint = { path = "../librustc_lint" }
rustc_errors = { path = "../librustc_errors" }
rustc_plugin = { path = "../librustc_plugin" }
rustc_plugin = { path = "../librustc_plugin", package = "rustc_plugin_impl" }
rustc_privacy = { path = "../librustc_privacy" }
rustc_resolve = { path = "../librustc_resolve" }
tempfile = "3.0.5"
2 changes: 1 addition & 1 deletion src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,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_driver::plugin` respectively.
//!
//! ## Note
//!
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_plugin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
authors = ["The Rust Project Developers"]
name = "rustc_plugin"
name = "rustc_plugin_impl"
version = "0.0.0"
build = false
edition = "2018"

[lib]
name = "rustc_plugin"
name = "rustc_plugin_impl"
path = "lib.rs"
doctest = false

Expand Down
14 changes: 14 additions & 0 deletions src/librustc_plugin/deprecated/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
authors = ["The Rust Project Developers"]
name = "rustc_plugin"
version = "0.0.0"
build = false
edition = "2018"

[lib]
name = "rustc_plugin"
path = "lib.rs"
doctest = false

[dependencies]
rustc_plugin_impl = { path = ".." }
8 changes: 8 additions & 0 deletions src/librustc_plugin/deprecated/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(staged_api)]
#![unstable(feature = "rustc_plugin", issue = "29597")]
#![rustc_deprecated(since = "1.38.0", reason = "\
import this through `rustc_driver::plugin` instead to make TLS work correctly. \
See https://github.com/rust-lang/rust/issues/62717")]

pub use rustc_plugin_impl::*;
3 changes: 1 addition & 2 deletions src/librustc_plugin/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
//! #![feature(plugin_registrar)]
//! #![feature(rustc_private)]
//!
//! extern crate rustc_plugin;
//! extern crate rustc_driver;
//! extern crate syntax;
//! extern crate syntax_pos;
//!
//! use rustc_plugin::Registry;
//! use rustc_driver::plugin::Registry;
//! use syntax::ext::base::{ExtCtxt, MacResult};
//! use syntax_pos::Span;
//! use syntax::tokenstream::TokenTree;
Expand Down
3 changes: 1 addition & 2 deletions src/test/ui-fulldeps/auxiliary/attr-plugin-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
#![feature(rustc_private)]

extern crate rustc_driver;
extern crate rustc_plugin;
extern crate syntax;

use rustc_plugin::Registry;
use rustc_driver::plugin::Registry;
use syntax::ext::base::SyntaxExtension;
use syntax::feature_gate::AttributeType;
use syntax::symbol::Symbol;
Expand Down
3 changes: 1 addition & 2 deletions src/test/ui-fulldeps/auxiliary/issue-40001-plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

#[macro_use]
extern crate rustc;
extern crate rustc_plugin;
extern crate rustc_driver;
extern crate syntax;

use rustc_plugin::Registry;
use rustc_driver::plugin::Registry;
use syntax::attr;
use syntax::ext::base::*;
use syntax::feature_gate::AttributeType::Whitelisted;
Expand Down
3 changes: 1 addition & 2 deletions src/test/ui-fulldeps/auxiliary/lint-for-crate-rpass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
#![feature(box_syntax)]

#[macro_use] extern crate rustc;
extern crate rustc_plugin;
extern crate rustc_driver;
extern crate syntax;

use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LateLintPassObject, LintArray};
use rustc_plugin::Registry;
use rustc_driver::plugin::Registry;
use rustc::hir;
use syntax::attr;
use syntax::symbol::Symbol;
Expand Down
3 changes: 1 addition & 2 deletions src/test/ui-fulldeps/auxiliary/lint-for-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
#![feature(box_syntax)]

#[macro_use] extern crate rustc;
extern crate rustc_plugin;
extern crate rustc_driver;
extern crate syntax;

use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LateLintPassObject, LintArray};
use rustc_plugin::Registry;
use rustc_driver::plugin::Registry;
use rustc::hir;
use syntax::attr;
use syntax::symbol::Symbol;
Expand Down
3 changes: 1 addition & 2 deletions src/test/ui-fulldeps/auxiliary/lint-group-plugin-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
// Load rustc as a plugin to get macros.
#[macro_use]
extern crate rustc;
extern crate rustc_plugin;
extern crate rustc_driver;

use rustc::hir;
use rustc::lint::{LateContext, LintContext, LintPass, LateLintPass, LateLintPassObject, LintArray};
use rustc_plugin::Registry;
use rustc_driver::plugin::Registry;

declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");

Expand Down
3 changes: 1 addition & 2 deletions src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ extern crate syntax;
// Load rustc as a plugin to get macros
#[macro_use]
extern crate rustc;
extern crate rustc_plugin;
extern crate rustc_driver;

use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass,
EarlyLintPassObject, LintArray};
use rustc_plugin::Registry;
use rustc_driver::plugin::Registry;
use syntax::ast;
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");

Expand Down
3 changes: 1 addition & 2 deletions src/test/ui-fulldeps/auxiliary/lint-tool-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ extern crate syntax;
// Load rustc as a plugin to get macros
#[macro_use]
extern crate rustc;
extern crate rustc_plugin;
extern crate rustc_driver;

use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
use rustc_plugin::Registry;
use rustc_driver::plugin::Registry;
use syntax::ast;
declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff");
declare_tool_lint!(
Expand Down
3 changes: 1 addition & 2 deletions src/test/ui-fulldeps/auxiliary/llvm-pass-plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
#![feature(rustc_private)]

extern crate rustc;
extern crate rustc_plugin;
extern crate rustc_driver;

use rustc_plugin::Registry;
use rustc_driver::plugin::Registry;

#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
#![feature(rustc_private)]

extern crate rustc;
extern crate rustc_plugin;
extern crate rustc_driver;

use rustc_plugin::Registry;
use rustc_driver::plugin::Registry;

#[plugin_registrar]
pub fn plugin_registrar(_reg: &mut Registry) {}
1 change: 0 additions & 1 deletion src/test/ui-fulldeps/auxiliary/macro-crate-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

extern crate syntax;
extern crate rustc;
extern crate rustc_plugin;
extern crate rustc_driver;
extern crate syntax_pos;
extern crate proc_macro;
Expand Down
3 changes: 1 addition & 2 deletions src/test/ui-fulldeps/auxiliary/outlive-expansion-phase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
#![feature(box_syntax, rustc_private)]

extern crate rustc;
extern crate rustc_plugin;
extern crate rustc_driver;

use std::any::Any;
use std::cell::RefCell;
use rustc_plugin::Registry;
use rustc_driver::plugin::Registry;

struct Foo {
foo: isize
Expand Down
3 changes: 1 addition & 2 deletions src/test/ui-fulldeps/auxiliary/plugin-args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
extern crate syntax;
extern crate syntax_pos;
extern crate rustc;
extern crate rustc_plugin;
extern crate rustc_driver;

use std::borrow::ToOwned;
Expand All @@ -17,7 +16,7 @@ use syntax::print::pprust;
use syntax::symbol::Symbol;
use syntax_pos::Span;
use syntax::tokenstream::TokenStream;
use rustc_plugin::Registry;
use rustc_driver::plugin::Registry;

struct Expander {
args: Vec<ast::NestedMetaItem>,
Expand Down
3 changes: 1 addition & 2 deletions src/test/ui-fulldeps/auxiliary/rlib-crate-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
#![feature(plugin_registrar, rustc_private)]

extern crate rustc;
extern crate rustc_plugin;
extern crate rustc_driver;

use rustc_plugin::Registry;
use rustc_driver::plugin::Registry;

#[plugin_registrar]
pub fn plugin_registrar(_: &mut Registry) {}
3 changes: 1 addition & 2 deletions src/test/ui-fulldeps/auxiliary/roman-numerals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
extern crate syntax;
extern crate syntax_pos;
extern crate rustc;
extern crate rustc_plugin;
extern crate rustc_driver;

use syntax::parse::token::{self, Token};
use syntax::tokenstream::TokenTree;
use syntax::ext::base::{ExtCtxt, MacResult, DummyResult, MacEager};
use syntax_pos::Span;
use rustc_plugin::Registry;
use rustc_driver::plugin::Registry;

fn expand_rn(cx: &mut ExtCtxt, sp: Span, args: &[TokenTree])
-> Box<dyn MacResult + 'static> {
Expand Down

0 comments on commit d0bbc60

Please sign in to comment.