Skip to content

Commit 90ac082

Browse files
authored
Rollup merge of rust-lang#66905 - petrochenkov:rmplugin2, r=Centril
rustc_plugin: Remove some remaining plugin features - Plugin arguments (`#![plugin(my_plugin(args))]`) are no longer supported. - Registering additional plugins from command line (`-Z extra-plugins=my_plugin`) is no longer supported, `-Z crate-attr=plugin(my_plugin)` can be used instead. - Lint `plugin_as_library` is removed as mostly useless now, when plugins exist as a compatibility feature with greatly reduced functionality. - Plugins registering additional LLVM passes (`Registry::register_llvm_pass`) are no longer supported, `-C passes=my_passes` can be used instead. r? @Centril
2 parents dbe880e + e5944a5 commit 90ac082

36 files changed

+141
-405
lines changed

src/doc/rustc/src/lints/listing/warn-by-default.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -307,18 +307,6 @@ warning: path statement with no effect
307307
|
308308
```
309309

310-
## plugin-as-library
311-
312-
This lint detects when compiler plugins are used as ordinary library in
313-
non-plugin crate. Some example code that triggers this lint:
314-
315-
```rust,ignore
316-
#![feature(plugin)]
317-
#![plugin(macro_crate_test)]
318-
319-
extern crate macro_crate_test;
320-
```
321-
322310
## private-in-public
323311

324312
This lint detects private items in public interfaces not caught by the old implementation. Some

src/doc/unstable-book/src/language-features/plugin.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,10 @@ the crate attribute `#![plugin(...)]`. See the
2121
`rustc_driver::plugin` documentation for more about the
2222
mechanics of defining and loading a plugin.
2323

24-
If present, arguments passed as `#![plugin(foo(... args ...))]` are not
25-
interpreted by rustc itself. They are provided to the plugin through the
26-
`Registry`'s `args` method.
27-
2824
In the vast majority of cases, a plugin should *only* be used through
2925
`#![plugin]` and not through an `extern crate` item. Linking a plugin would
3026
pull in all of libsyntax and librustc as dependencies of your crate. This is
31-
generally unwanted unless you are building another plugin. The
32-
`plugin_as_library` lint checks these guidelines.
27+
generally unwanted unless you are building another plugin.
3328

3429
The usual practice is to put compiler plugins in their own crate, separate from
3530
any `macro_rules!` macros or ordinary Rust code meant to be used by consumers

src/librustc/lint/context.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ use rustc_error_codes::*;
4747
/// This is basically the subset of `Context` that we can
4848
/// build early in the compile pipeline.
4949
pub struct LintStore {
50-
/// Registered lints. The bool is true if the lint was
51-
/// added by a plugin.
50+
/// Registered lints.
5251
lints: Vec<&'static Lint>,
5352

5453
/// Constructor functions for each variety of lint pass.

src/librustc/session/config.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,8 +1364,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
13641364
"enable queries of the dependency graph for regression testing"),
13651365
no_analysis: bool = (false, parse_bool, [UNTRACKED],
13661366
"parse and expand the source, but run no analysis"),
1367-
extra_plugins: Vec<String> = (Vec::new(), parse_list, [TRACKED],
1368-
"load extra plugins"),
13691367
unstable_options: bool = (false, parse_bool, [UNTRACKED],
13701368
"adds unstable command line options to rustc interface"),
13711369
force_overflow_checks: Option<bool> = (None, parse_opt_bool, [TRACKED],

src/librustc/session/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ pub struct Session {
7676
/// (sub)diagnostics that have been set once, but should not be set again,
7777
/// in order to avoid redundantly verbose output (Issue #24690, #44953).
7878
pub one_time_diagnostics: Lock<FxHashSet<(DiagnosticMessageId, Option<Span>, String)>>,
79-
pub plugin_llvm_passes: OneThread<RefCell<Vec<String>>>,
8079
pub crate_types: Once<Vec<config::CrateType>>,
8180
/// The `crate_disambiguator` is constructed out of all the `-C metadata`
8281
/// arguments passed to the compiler. Its value together with the crate-name
@@ -1149,7 +1148,6 @@ fn build_session_(
11491148
local_crate_source_file,
11501149
working_dir,
11511150
one_time_diagnostics: Default::default(),
1152-
plugin_llvm_passes: OneThread::new(RefCell::new(Vec::new())),
11531151
crate_types: Once::new(),
11541152
crate_disambiguator: Once::new(),
11551153
features: Once::new(),

src/librustc_codegen_llvm/back/write.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -365,20 +365,6 @@ pub(crate) unsafe fn optimize(cgcx: &CodegenContext<LlvmCodegenBackend>,
365365

366366
add_sanitizer_passes(config, &mut extra_passes);
367367

368-
for pass_name in &cgcx.plugin_passes {
369-
if let Some(pass) = find_pass(pass_name) {
370-
extra_passes.push(pass);
371-
} else {
372-
diag_handler.err(&format!("a plugin asked for LLVM pass \
373-
`{}` but LLVM does not \
374-
recognize it", pass_name));
375-
}
376-
377-
if pass_name == "name-anon-globals" {
378-
have_name_anon_globals_pass = true;
379-
}
380-
}
381-
382368
// Some options cause LLVM bitcode to be emitted, which uses ThinLTOBuffers, so we need
383369
// to make sure we run LLVM's NameAnonGlobals pass when emitting bitcode; otherwise
384370
// we'll get errors in LLVM.

src/librustc_codegen_ssa/back/write.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,6 @@ pub struct CodegenContext<B: WriteBackendMethods> {
231231
pub total_cgus: usize,
232232
// Handler to use for diagnostics produced during codegen.
233233
pub diag_emitter: SharedEmitter,
234-
// LLVM passes added by plugins.
235-
pub plugin_passes: Vec<String>,
236234
// LLVM optimizations for which we want to print remarks.
237235
pub remark: Passes,
238236
// Worker thread number
@@ -1028,7 +1026,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
10281026
time_passes: sess.time_extended(),
10291027
prof: sess.prof.clone(),
10301028
exported_symbols,
1031-
plugin_passes: sess.plugin_llvm_passes.borrow().clone(),
10321029
remark: sess.opts.cg.remark.clone(),
10331030
worker: 0,
10341031
incr_comp_session_dir: sess.incr_comp_session_dir_opt().map(|r| r.clone()),

src/librustc_feature/builtin_attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
283283
)
284284
),
285285
(
286-
sym::plugin, CrateLevel, template!(List: "name|name(args)"),
286+
sym::plugin, CrateLevel, template!(List: "name"),
287287
Gated(
288288
Stability::Deprecated(
289289
"https://github.com/rust-lang/rust/pull/64675",

src/librustc_interface/passes.rs

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ use rustc_mir as mir;
3030
use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str};
3131
use rustc_passes::{self, ast_validation, hir_stats, layout_test};
3232
use rustc_plugin_impl as plugin;
33-
use rustc_plugin_impl::registry::Registry;
3433
use rustc_privacy;
3534
use rustc_resolve::{Resolver, ResolverArenas};
3635
use rustc_traits;
@@ -106,8 +105,7 @@ declare_box_region_type!(
106105
(&mut Resolver<'_>) -> (Result<ast::Crate>, ResolverOutputs)
107106
);
108107

109-
/// Runs the "early phases" of the compiler: initial `cfg` processing,
110-
/// loading compiler plugins (including those from `addl_plugins`),
108+
/// Runs the "early phases" of the compiler: initial `cfg` processing, loading compiler plugins,
111109
/// syntax expansion, secondary `cfg` expansion, synthesis of a test
112110
/// harness if one is to be provided, injection of a dependency on the
113111
/// standard library and prelude, and name resolution.
@@ -209,33 +207,22 @@ pub fn register_plugins<'a>(
209207
middle::recursion_limit::update_limits(sess, &krate);
210208
});
211209

212-
let registrars = time(sess, "plugin loading", || {
213-
plugin::load::load_plugins(
214-
sess,
215-
metadata_loader,
216-
&krate,
217-
Some(sess.opts.debugging_opts.extra_plugins.clone()),
218-
)
219-
});
220-
221210
let mut lint_store = rustc_lint::new_lint_store(
222211
sess.opts.debugging_opts.no_interleave_lints,
223212
sess.unstable_options(),
224213
);
214+
register_lints(&sess, &mut lint_store);
225215

226-
(register_lints)(&sess, &mut lint_store);
227-
228-
let mut registry = Registry::new(sess, &mut lint_store, krate.span);
229-
216+
let registrars = time(sess, "plugin loading", || {
217+
plugin::load::load_plugins(sess, metadata_loader, &krate)
218+
});
230219
time(sess, "plugin registration", || {
220+
let mut registry = plugin::Registry { lint_store: &mut lint_store };
231221
for registrar in registrars {
232-
registry.args_hidden = Some(registrar.args);
233-
(registrar.fun)(&mut registry);
222+
registrar(&mut registry);
234223
}
235224
});
236225

237-
*sess.plugin_llvm_passes.borrow_mut() = registry.llvm_passes;
238-
239226
Ok((krate, Lrc::new(lint_store)))
240227
}
241228

src/librustc_interface/tests.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,6 @@ fn test_debugging_options_tracking_hash() {
650650
opts.debugging_opts.continue_parse_after_error = true;
651651
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
652652

653-
opts = reference.clone();
654-
opts.debugging_opts.extra_plugins = vec![String::from("plugin1"), String::from("plugin2")];
655-
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());
656-
657653
opts = reference.clone();
658654
opts.debugging_opts.force_overflow_checks = Some(true);
659655
assert!(reference.dep_tracking_hash() != opts.dep_tracking_hash());

0 commit comments

Comments
 (0)