From db357a6e3be7b741a710a926d3ddeed79fc40482 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 30 Nov 2019 11:31:25 +0300 Subject: [PATCH] rustc_plugin: Remove support for adding plugins from command line --- src/librustc/lint/context.rs | 3 +-- src/librustc/session/config.rs | 2 -- src/librustc_interface/passes.rs | 10 ++-------- src/librustc_interface/tests.rs | 4 ---- src/librustc_plugin_impl/load.rs | 11 +++-------- src/test/ui-fulldeps/lint-plugin-cmdline-load.rs | 6 +++--- src/test/ui-fulldeps/lint-plugin-cmdline-load.stderr | 8 ++++++++ 7 files changed, 17 insertions(+), 27 deletions(-) diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 05543f1d2ef..7f72154e42c 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -47,8 +47,7 @@ use rustc_error_codes::*; /// This is basically the subset of `Context` that we can /// build early in the compile pipeline. pub struct LintStore { - /// Registered lints. The bool is true if the lint was - /// added by a plugin. + /// Registered lints. lints: Vec<&'static Lint>, /// Constructor functions for each variety of lint pass. diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index fbfae721bbe..d2ac5436cc8 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1364,8 +1364,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "enable queries of the dependency graph for regression testing"), no_analysis: bool = (false, parse_bool, [UNTRACKED], "parse and expand the source, but run no analysis"), - extra_plugins: Vec = (Vec::new(), parse_list, [TRACKED], - "load extra plugins"), unstable_options: bool = (false, parse_bool, [UNTRACKED], "adds unstable command line options to rustc interface"), force_overflow_checks: Option = (None, parse_opt_bool, [TRACKED], diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs index 1d181faa09a..e752a5eab4e 100644 --- a/src/librustc_interface/passes.rs +++ b/src/librustc_interface/passes.rs @@ -106,8 +106,7 @@ declare_box_region_type!( (&mut Resolver<'_>) -> (Result, ResolverOutputs) ); -/// Runs the "early phases" of the compiler: initial `cfg` processing, -/// loading compiler plugins (including those from `addl_plugins`), +/// Runs the "early phases" of the compiler: initial `cfg` processing, loading compiler plugins, /// syntax expansion, secondary `cfg` expansion, synthesis of a test /// harness if one is to be provided, injection of a dependency on the /// standard library and prelude, and name resolution. @@ -210,12 +209,7 @@ pub fn register_plugins<'a>( }); let registrars = time(sess, "plugin loading", || { - plugin::load::load_plugins( - sess, - metadata_loader, - &krate, - Some(sess.opts.debugging_opts.extra_plugins.clone()), - ) + plugin::load::load_plugins(sess, metadata_loader, &krate) }); let mut lint_store = rustc_lint::new_lint_store( diff --git a/src/librustc_interface/tests.rs b/src/librustc_interface/tests.rs index d39a5d3a073..4c630b56cb4 100644 --- a/src/librustc_interface/tests.rs +++ b/src/librustc_interface/tests.rs @@ -650,10 +650,6 @@ fn test_debugging_options_tracking_hash() { opts.debugging_opts.continue_parse_after_error = true; assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash()); - opts = reference.clone(); - opts.debugging_opts.extra_plugins = vec![String::from("plugin1"), String::from("plugin2")]; - assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash()); - opts = reference.clone(); opts.debugging_opts.force_overflow_checks = Some(true); assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash()); diff --git a/src/librustc_plugin_impl/load.rs b/src/librustc_plugin_impl/load.rs index 8150af5b2b6..6f2af6895e4 100644 --- a/src/librustc_plugin_impl/load.rs +++ b/src/librustc_plugin_impl/load.rs @@ -28,10 +28,8 @@ fn call_malformed_plugin_attribute(sess: &Session, span: Span) { /// Read plugin metadata and dynamically load registrar functions. pub fn load_plugins(sess: &Session, metadata_loader: &dyn MetadataLoader, - krate: &Crate, - addl_plugins: Option>) -> Vec { + krate: &Crate) -> Vec { let mut plugins = Vec::new(); - let mut load_plugin = |ident| load_plugin(&mut plugins, sess, metadata_loader, ident); for attr in &krate.attrs { if !attr.check_name(sym::plugin) { @@ -40,16 +38,13 @@ pub fn load_plugins(sess: &Session, for plugin in attr.meta_item_list().unwrap_or_default() { match plugin.ident() { - Some(ident) if plugin.is_word() => load_plugin(ident), + Some(ident) if plugin.is_word() => + load_plugin(&mut plugins, sess, metadata_loader, ident), _ => call_malformed_plugin_attribute(sess, plugin.span()), } } } - for plugin in addl_plugins.unwrap_or_default() { - load_plugin(Ident::from_str(&plugin)); - } - plugins } diff --git a/src/test/ui-fulldeps/lint-plugin-cmdline-load.rs b/src/test/ui-fulldeps/lint-plugin-cmdline-load.rs index fd681536b5b..0bd95dfbd14 100644 --- a/src/test/ui-fulldeps/lint-plugin-cmdline-load.rs +++ b/src/test/ui-fulldeps/lint-plugin-cmdline-load.rs @@ -1,9 +1,9 @@ -// run-pass +// check-pass // aux-build:lint-plugin-test.rs // ignore-stage1 -// compile-flags: -Z extra-plugins=lint_plugin_test +// compile-flags: -Z crate-attr=plugin(lint_plugin_test) -#![allow(dead_code)] +#![feature(plugin)] fn lintme() { } //~ WARNING item is named 'lintme' diff --git a/src/test/ui-fulldeps/lint-plugin-cmdline-load.stderr b/src/test/ui-fulldeps/lint-plugin-cmdline-load.stderr index 5a6b35433ac..1263a0efe62 100644 --- a/src/test/ui-fulldeps/lint-plugin-cmdline-load.stderr +++ b/src/test/ui-fulldeps/lint-plugin-cmdline-load.stderr @@ -1,3 +1,11 @@ +warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675 + --> :1:1 + | +LL | plugin(lint_plugin_test) + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version + | + = note: `#[warn(deprecated)]` on by default + warning: item is named 'lintme' --> $DIR/lint-plugin-cmdline-load.rs:8:1 |