Skip to content

Commit 7e06631

Browse files
committed
Remove support for compiler plugins.
They've been deprecated for four years. This commit includes the following changes. - It eliminates the `rustc_plugin_impl` crate. - It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`. - E0457 and E0498 are no longer used. - E0463 is narrowed, now only relating to unfound crates, not plugins. - The `plugin` feature was moved from "active" to "removed". - It removes the entire plugins chapter from the unstable book. - It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`. Closes rust-lang#29597.
1 parent 236ac91 commit 7e06631

File tree

101 files changed

+57
-1712
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+57
-1712
lines changed

Cargo.lock

-17
Original file line numberDiff line numberDiff line change
@@ -3774,7 +3774,6 @@ dependencies = [
37743774
"rustc_monomorphize",
37753775
"rustc_parse",
37763776
"rustc_passes",
3777-
"rustc_plugin_impl",
37783777
"rustc_privacy",
37793778
"rustc_query_system",
37803779
"rustc_resolve",
@@ -4063,7 +4062,6 @@ dependencies = [
40634062
"rustc_monomorphize",
40644063
"rustc_parse",
40654064
"rustc_passes",
4066-
"rustc_plugin_impl",
40674065
"rustc_privacy",
40684066
"rustc_query_impl",
40694067
"rustc_query_system",
@@ -4373,21 +4371,6 @@ dependencies = [
43734371
"tracing",
43744372
]
43754373

4376-
[[package]]
4377-
name = "rustc_plugin_impl"
4378-
version = "0.0.0"
4379-
dependencies = [
4380-
"libloading 0.7.4",
4381-
"rustc_ast",
4382-
"rustc_errors",
4383-
"rustc_fluent_macro",
4384-
"rustc_lint",
4385-
"rustc_macros",
4386-
"rustc_metadata",
4387-
"rustc_session",
4388-
"rustc_span",
4389-
]
4390-
43914374
[[package]]
43924375
name = "rustc_privacy"
43934376
version = "0.0.0"

compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ rm -r tests/run-make/split-debuginfo # same
6868
rm -r tests/run-make/symbols-include-type-name # --emit=asm not supported
6969
rm -r tests/run-make/target-specs # i686 not supported by Cranelift
7070
rm -r tests/run-make/mismatching-target-triples # same
71-
rm -r tests/run-make/use-extern-for-plugins # same
7271
rm tests/ui/asm/x86_64/issue-82869.rs # vector regs in inline asm not yet supported
7372
rm tests/ui/asm/x86_64/issue-96797.rs # const and sym inline asm operands don't work entirely correctly
7473

compiler/rustc_driver_impl/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ rustc_mir_transform = { path = "../rustc_mir_transform" }
3939
rustc_monomorphize = { path = "../rustc_monomorphize" }
4040
rustc_parse = { path = "../rustc_parse" }
4141
rustc_passes = { path = "../rustc_passes" }
42-
rustc_plugin_impl = { path = "../rustc_plugin_impl" }
4342
rustc_privacy = { path = "../rustc_privacy" }
4443
rustc_query_system = { path = "../rustc_query_system" }
4544
rustc_resolve = { path = "../rustc_resolve" }

compiler/rustc_driver_impl/src/lib.rs

+21-24
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#[macro_use]
2121
extern crate tracing;
2222

23-
pub extern crate rustc_plugin_impl as plugin;
24-
2523
use rustc_ast as ast;
2624
use rustc_codegen_ssa::{traits::CodegenBackend, CodegenErrors, CodegenResults};
2725
use rustc_data_structures::profiling::{
@@ -131,7 +129,6 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
131129
rustc_monomorphize::DEFAULT_LOCALE_RESOURCE,
132130
rustc_parse::DEFAULT_LOCALE_RESOURCE,
133131
rustc_passes::DEFAULT_LOCALE_RESOURCE,
134-
rustc_plugin_impl::DEFAULT_LOCALE_RESOURCE,
135132
rustc_privacy::DEFAULT_LOCALE_RESOURCE,
136133
rustc_query_system::DEFAULT_LOCALE_RESOURCE,
137134
rustc_resolve::DEFAULT_LOCALE_RESOURCE,
@@ -993,16 +990,14 @@ the command line flag directly.
993990
}
994991

995992
/// Write to stdout lint command options, together with a list of all available lints
996-
pub fn describe_lints(sess: &Session, lint_store: &LintStore, loaded_plugins: bool) {
993+
pub fn describe_lints(sess: &Session, lint_store: &LintStore, loaded_lints: bool) {
997994
safe_println!(
998995
"
999996
Available lint options:
1000997
-W <foo> Warn about <foo>
1001-
-A <foo> \
1002-
Allow <foo>
998+
-A <foo> Allow <foo>
1003999
-D <foo> Deny <foo>
1004-
-F <foo> Forbid <foo> \
1005-
(deny <foo> and all attempts to override)
1000+
-F <foo> Forbid <foo> (deny <foo> and all attempts to override)
10061001
10071002
"
10081003
);
@@ -1021,18 +1016,18 @@ Available lint options:
10211016
lints
10221017
}
10231018

1024-
let (plugin, builtin): (Vec<_>, _) =
1025-
lint_store.get_lints().iter().cloned().partition(|&lint| lint.is_plugin);
1026-
let plugin = sort_lints(sess, plugin);
1019+
let (loaded, builtin): (Vec<_>, _) =
1020+
lint_store.get_lints().iter().cloned().partition(|&lint| lint.is_loaded);
1021+
let loaded = sort_lints(sess, loaded);
10271022
let builtin = sort_lints(sess, builtin);
10281023

1029-
let (plugin_groups, builtin_groups): (Vec<_>, _) =
1024+
let (loaded_groups, builtin_groups): (Vec<_>, _) =
10301025
lint_store.get_lint_groups().partition(|&(.., p)| p);
1031-
let plugin_groups = sort_lint_groups(plugin_groups);
1026+
let loaded_groups = sort_lint_groups(loaded_groups);
10321027
let builtin_groups = sort_lint_groups(builtin_groups);
10331028

10341029
let max_name_len =
1035-
plugin.iter().chain(&builtin).map(|&s| s.name.chars().count()).max().unwrap_or(0);
1030+
loaded.iter().chain(&builtin).map(|&s| s.name.chars().count()).max().unwrap_or(0);
10361031
let padded = |x: &str| {
10371032
let mut s = " ".repeat(max_name_len - x.chars().count());
10381033
s.push_str(x);
@@ -1060,7 +1055,7 @@ Available lint options:
10601055

10611056
let max_name_len = max(
10621057
"warnings".len(),
1063-
plugin_groups
1058+
loaded_groups
10641059
.iter()
10651060
.chain(&builtin_groups)
10661061
.map(|&(s, _)| s.chars().count())
@@ -1098,20 +1093,22 @@ Available lint options:
10981093

10991094
print_lint_groups(builtin_groups, true);
11001095

1101-
match (loaded_plugins, plugin.len(), plugin_groups.len()) {
1096+
match (loaded_lints, loaded.len(), loaded_groups.len()) {
11021097
(false, 0, _) | (false, _, 0) => {
1103-
safe_println!("Lint tools like Clippy can provide additional lints and lint groups.");
1098+
safe_println!("Lint tools like Clippy can load additional lints and lint groups.");
1099+
}
1100+
(false, ..) => panic!("didn't load additional lints but got them anyway!"),
1101+
(true, 0, 0) => {
1102+
safe_println!("This crate does not load any additional lints or lint groups.")
11041103
}
1105-
(false, ..) => panic!("didn't load lint plugins but got them anyway!"),
1106-
(true, 0, 0) => safe_println!("This crate does not load any lint plugins or lint groups."),
11071104
(true, l, g) => {
11081105
if l > 0 {
1109-
safe_println!("Lint checks provided by plugins loaded by this crate:\n");
1110-
print_lints(plugin);
1106+
safe_println!("Lint checks loaded by this crate:\n");
1107+
print_lints(loaded);
11111108
}
11121109
if g > 0 {
1113-
safe_println!("Lint groups provided by plugins loaded by this crate:\n");
1114-
print_lint_groups(plugin_groups, false);
1110+
safe_println!("Lint groups loaded by this crate:\n");
1111+
print_lint_groups(loaded_groups, false);
11151112
}
11161113
}
11171114
}
@@ -1128,7 +1125,7 @@ pub fn describe_flag_categories(handler: &EarlyErrorHandler, matches: &Matches)
11281125
rustc_errors::FatalError.raise();
11291126
}
11301127

1131-
// Don't handle -W help here, because we might first load plugins.
1128+
// Don't handle -W help here, because we might first load additional lints.
11321129
let debug_flags = matches.opt_strs("Z");
11331130
if debug_flags.iter().any(|x| *x == "help") {
11341131
describe_debug_flags();

compiler/rustc_error_codes/src/error_codes/E0457.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#### Note: this error code is no longer emitted by the compiler`
2+
13
Plugin `..` only found in rlib format, but must be available in dylib format.
24

35
Erroneous code example:

compiler/rustc_error_codes/src/error_codes/E0463.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
A plugin/crate was declared but cannot be found.
1+
A crate was declared but cannot be found.
22

33
Erroneous code example:
44

55
```compile_fail,E0463
6-
#![feature(plugin)]
7-
#![plugin(cookie_monster)] // error: can't find crate for `cookie_monster`
8-
extern crate cake_is_a_lie; // error: can't find crate for `cake_is_a_lie`
6+
extern crate foo; // error: can't find crate
97
```
108

119
You need to link your code to the relevant crate in order to be able to use it
12-
(through Cargo or the `-L` option of rustc example). Plugins are crates as
13-
well, and you link to them the same way.
10+
(through Cargo or the `-L` option of rustc, for example).
1411

1512
## Common causes
1613

compiler/rustc_error_codes/src/error_codes/E0498.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
#### Note: this error code is no longer emitted by the compiler.
2+
13
The `plugin` attribute was malformed.
24

35
Erroneous code example:
46

5-
```compile_fail,E0498
7+
```ignore (E0498 is no longer emitted)
68
#![feature(plugin)]
79
#![plugin(foo(args))] // error: invalid argument
810
#![plugin(bar="test")] // error: invalid argument

compiler/rustc_feature/src/builtin_attrs.rs

-18
Original file line numberDiff line numberDiff line change
@@ -417,24 +417,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
417417
naked_functions, experimental!(naked)
418418
),
419419

420-
// Plugins:
421-
BuiltinAttribute {
422-
name: sym::plugin,
423-
only_local: false,
424-
type_: CrateLevel,
425-
template: template!(List: "name"),
426-
duplicates: DuplicatesOk,
427-
gate: Gated(
428-
Stability::Deprecated(
429-
"https://github.com/rust-lang/rust/pull/64675",
430-
Some("may be removed in a future compiler version"),
431-
),
432-
sym::plugin,
433-
"compiler plugins are deprecated",
434-
cfg_fn!(plugin)
435-
),
436-
},
437-
438420
// Testing:
439421
gated!(
440422
test_runner, CrateLevel, template!(List: "path"), ErrorFollowing, custom_test_frameworks,

compiler/rustc_feature/src/removed.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,12 @@ declare_features! (
152152
Some("removed in favor of `#![feature(marker_trait_attr)]`")),
153153
(removed, panic_implementation, "1.28.0", Some(44489), None,
154154
Some("subsumed by `#[panic_handler]`")),
155+
/// Allows using `#![plugin(myplugin)]`.
156+
(removed, plugin, "CURRENT_RUSTC_VERSION", Some(29597), None,
157+
Some("plugins are no longer supported")),
155158
/// Allows using `#[plugin_registrar]` on functions.
156159
(removed, plugin_registrar, "1.54.0", Some(29597), None,
157-
Some("a __rustc_plugin_registrar symbol must now be defined instead")),
160+
Some("plugins are no longer supported")),
158161
(removed, proc_macro_expr, "1.27.0", Some(54727), None,
159162
Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
160163
(removed, proc_macro_gen, "1.27.0", Some(54727), None,

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,6 @@ declare_features! (
528528
(unstable, object_safe_for_dispatch, "1.40.0", Some(43561), None),
529529
/// Allows using `#[optimize(X)]`.
530530
(unstable, optimize_attribute, "1.34.0", Some(54882), None),
531-
/// Allows using `#![plugin(myplugin)]`.
532-
(unstable, plugin, "1.0.0", Some(29597), None),
533531
/// Allows exhaustive integer pattern matching on `usize` and `isize`.
534532
(unstable, precise_pointer_size_matching, "1.32.0", Some(56354), None),
535533
/// Allows macro attributes on expressions, statements and non-inline modules.

compiler/rustc_interface/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ rustc_mir_transform = { path = "../rustc_mir_transform" }
3636
rustc_monomorphize = { path = "../rustc_monomorphize" }
3737
rustc_parse = { path = "../rustc_parse" }
3838
rustc_passes = { path = "../rustc_passes" }
39-
rustc_plugin_impl = { path = "../rustc_plugin_impl" }
4039
rustc_privacy = { path = "../rustc_privacy" }
4140
rustc_query_impl = { path = "../rustc_query_impl" }
4241
rustc_query_system = { path = "../rustc_query_system" }

compiler/rustc_interface/src/interface.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ pub struct Config {
354354
pub hash_untracked_state: Option<Box<dyn FnOnce(&Session, &mut StableHasher) + Send>>,
355355

356356
/// This is a callback from the driver that is called when we're registering lints;
357-
/// it is called during plugin registration when we have the LintStore in a non-shared state.
357+
/// it is called during lint loading when we have the LintStore in a non-shared state.
358358
///
359359
/// Note that if you find a Some here you probably want to call that function in the new
360360
/// function being registered.

compiler/rustc_interface/src/passes.rs

+1-15
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ use rustc_middle::util::Providers;
2323
use rustc_mir_build as mir_build;
2424
use rustc_parse::{parse_crate_from_file, parse_crate_from_source_str, validate_attr};
2525
use rustc_passes::{self, abi_test, hir_stats, layout_test};
26-
use rustc_plugin_impl as plugin;
2726
use rustc_resolve::Resolver;
2827
use rustc_session::code_stats::VTableSizeInfo;
2928
use rustc_session::config::{CrateType, Input, OutFileName, OutputFilenames, OutputType};
30-
use rustc_session::cstore::{MetadataLoader, Untracked};
29+
use rustc_session::cstore::Untracked;
3130
use rustc_session::output::filename_for_input;
3231
use rustc_session::search_paths::PathKind;
3332
use rustc_session::{Limit, Session};
@@ -75,25 +74,12 @@ fn count_nodes(krate: &ast::Crate) -> usize {
7574

7675
pub(crate) fn create_lint_store(
7776
sess: &Session,
78-
metadata_loader: &dyn MetadataLoader,
7977
register_lints: Option<impl Fn(&Session, &mut LintStore)>,
80-
pre_configured_attrs: &[ast::Attribute],
8178
) -> LintStore {
8279
let mut lint_store = rustc_lint::new_lint_store(sess.enable_internal_lints());
8380
if let Some(register_lints) = register_lints {
8481
register_lints(sess, &mut lint_store);
8582
}
86-
87-
let registrars = sess.time("plugin_loading", || {
88-
plugin::load::load_plugins(sess, metadata_loader, pre_configured_attrs)
89-
});
90-
sess.time("plugin_registration", || {
91-
let mut registry = plugin::Registry { lint_store: &mut lint_store };
92-
for registrar in registrars {
93-
registrar(&mut registry);
94-
}
95-
});
96-
9783
lint_store
9884
}
9985

compiler/rustc_interface/src/queries.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,8 @@ impl<'tcx> Queries<'tcx> {
148148
);
149149
let dep_graph = setup_dep_graph(sess, crate_name, stable_crate_id)?;
150150

151-
let lint_store = Lrc::new(passes::create_lint_store(
152-
sess,
153-
&*self.codegen_backend().metadata_loader(),
154-
self.compiler.register_lints.as_deref(),
155-
&pre_configured_attrs,
156-
));
151+
let lint_store =
152+
Lrc::new(passes::create_lint_store(sess, self.compiler.register_lints.as_deref()));
157153
let cstore = FreezeLock::new(Box::new(CStore::new(
158154
self.codegen_backend().metadata_loader(),
159155
stable_crate_id,

compiler/rustc_lint/src/context.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ struct LintAlias {
109109

110110
struct LintGroup {
111111
lint_ids: Vec<LintId>,
112-
from_plugin: bool,
112+
is_loaded: bool,
113113
depr: Option<LintAlias>,
114114
}
115115

@@ -160,9 +160,7 @@ impl LintStore {
160160
// Don't display deprecated lint groups.
161161
depr.is_none()
162162
})
163-
.map(|(k, LintGroup { lint_ids, from_plugin, .. })| {
164-
(*k, lint_ids.clone(), *from_plugin)
165-
})
163+
.map(|(k, LintGroup { lint_ids, is_loaded, .. })| (*k, lint_ids.clone(), *is_loaded))
166164
}
167165

168166
pub fn register_early_pass(
@@ -221,7 +219,7 @@ impl LintStore {
221219
.entry(edition.lint_name())
222220
.or_insert(LintGroup {
223221
lint_ids: vec![],
224-
from_plugin: lint.is_plugin,
222+
is_loaded: lint.is_loaded,
225223
depr: None,
226224
})
227225
.lint_ids
@@ -234,7 +232,7 @@ impl LintStore {
234232
.entry("future_incompatible")
235233
.or_insert(LintGroup {
236234
lint_ids: vec![],
237-
from_plugin: lint.is_plugin,
235+
is_loaded: lint.is_loaded,
238236
depr: None,
239237
})
240238
.lint_ids
@@ -249,29 +247,29 @@ impl LintStore {
249247
alias,
250248
LintGroup {
251249
lint_ids: vec![],
252-
from_plugin: false,
250+
is_loaded: false,
253251
depr: Some(LintAlias { name: lint_name, silent: true }),
254252
},
255253
);
256254
}
257255

258256
pub fn register_group(
259257
&mut self,
260-
from_plugin: bool,
258+
is_loaded: bool,
261259
name: &'static str,
262260
deprecated_name: Option<&'static str>,
263261
to: Vec<LintId>,
264262
) {
265263
let new = self
266264
.lint_groups
267-
.insert(name, LintGroup { lint_ids: to, from_plugin, depr: None })
265+
.insert(name, LintGroup { lint_ids: to, is_loaded, depr: None })
268266
.is_none();
269267
if let Some(deprecated) = deprecated_name {
270268
self.lint_groups.insert(
271269
deprecated,
272270
LintGroup {
273271
lint_ids: vec![],
274-
from_plugin,
272+
is_loaded,
275273
depr: Some(LintAlias { name, silent: false }),
276274
},
277275
);

0 commit comments

Comments
 (0)