Skip to content

Commit 0fcfd98

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 36aab8d commit 0fcfd98

File tree

101 files changed

+57
-1692
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
-1692
lines changed

Cargo.lock

-17
Original file line numberDiff line numberDiff line change
@@ -3666,7 +3666,6 @@ dependencies = [
36663666
"rustc_monomorphize",
36673667
"rustc_parse",
36683668
"rustc_passes",
3669-
"rustc_plugin_impl",
36703669
"rustc_privacy",
36713670
"rustc_query_system",
36723671
"rustc_resolve",
@@ -3956,7 +3955,6 @@ dependencies = [
39563955
"rustc_monomorphize",
39573956
"rustc_parse",
39583957
"rustc_passes",
3959-
"rustc_plugin_impl",
39603958
"rustc_privacy",
39613959
"rustc_query_impl",
39623960
"rustc_query_system",
@@ -4266,21 +4264,6 @@ dependencies = [
42664264
"tracing",
42674265
]
42684266

4269-
[[package]]
4270-
name = "rustc_plugin_impl"
4271-
version = "0.0.0"
4272-
dependencies = [
4273-
"libloading 0.7.4",
4274-
"rustc_ast",
4275-
"rustc_errors",
4276-
"rustc_fluent_macro",
4277-
"rustc_lint",
4278-
"rustc_macros",
4279-
"rustc_metadata",
4280-
"rustc_session",
4281-
"rustc_span",
4282-
]
4283-
42844267
[[package]]
42854268
name = "rustc_privacy"
42864269
version = "0.0.0"

compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ rm -r tests/run-make/split-debuginfo # same
7676
rm -r tests/run-make/symbols-include-type-name # --emit=asm not supported
7777
rm -r tests/run-make/target-specs # i686 not supported by Cranelift
7878
rm -r tests/run-make/mismatching-target-triples # same
79-
rm -r tests/run-make/use-extern-for-plugins # same
8079

8180
# requires LTO
8281
rm -r tests/run-make/cdylib

compiler/rustc_driver_impl/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ rustc_hir_pretty = { path = "../rustc_hir_pretty" }
4444
rustc_macros = { path = "../rustc_macros" }
4545
rustc_metadata = { path = "../rustc_metadata" }
4646
rustc_parse = { path = "../rustc_parse" }
47-
rustc_plugin_impl = { path = "../rustc_plugin_impl" }
4847
rustc_codegen_ssa = { path = "../rustc_codegen_ssa" }
4948
rustc_session = { path = "../rustc_session" }
5049
rustc_error_codes = { path = "../rustc_error_codes" }

compiler/rustc_driver_impl/src/lib.rs

+21-24
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
#[macro_use]
1818
extern crate tracing;
1919

20-
pub extern crate rustc_plugin_impl as plugin;
21-
2220
use rustc_ast as ast;
2321
use rustc_codegen_ssa::{traits::CodegenBackend, CodegenErrors, CodegenResults};
2422
use rustc_data_structures::profiling::{
@@ -129,7 +127,6 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
129127
rustc_monomorphize::DEFAULT_LOCALE_RESOURCE,
130128
rustc_parse::DEFAULT_LOCALE_RESOURCE,
131129
rustc_passes::DEFAULT_LOCALE_RESOURCE,
132-
rustc_plugin_impl::DEFAULT_LOCALE_RESOURCE,
133130
rustc_privacy::DEFAULT_LOCALE_RESOURCE,
134131
rustc_query_system::DEFAULT_LOCALE_RESOURCE,
135132
rustc_resolve::DEFAULT_LOCALE_RESOURCE,
@@ -970,16 +967,14 @@ the command line flag directly.
970967
}
971968

972969
/// Write to stdout lint command options, together with a list of all available lints
973-
pub fn describe_lints(sess: &Session, lint_store: &LintStore, loaded_plugins: bool) {
970+
pub fn describe_lints(sess: &Session, lint_store: &LintStore, loaded_lints: bool) {
974971
safe_println!(
975972
"
976973
Available lint options:
977974
-W <foo> Warn about <foo>
978-
-A <foo> \
979-
Allow <foo>
975+
-A <foo> Allow <foo>
980976
-D <foo> Deny <foo>
981-
-F <foo> Forbid <foo> \
982-
(deny <foo> and all attempts to override)
977+
-F <foo> Forbid <foo> (deny <foo> and all attempts to override)
983978
984979
"
985980
);
@@ -998,18 +993,18 @@ Available lint options:
998993
lints
999994
}
1000995

1001-
let (plugin, builtin): (Vec<_>, _) =
1002-
lint_store.get_lints().iter().cloned().partition(|&lint| lint.is_plugin);
1003-
let plugin = sort_lints(sess, plugin);
996+
let (loaded, builtin): (Vec<_>, _) =
997+
lint_store.get_lints().iter().cloned().partition(|&lint| lint.is_loaded);
998+
let loaded = sort_lints(sess, loaded);
1004999
let builtin = sort_lints(sess, builtin);
10051000

1006-
let (plugin_groups, builtin_groups): (Vec<_>, _) =
1001+
let (loaded_groups, builtin_groups): (Vec<_>, _) =
10071002
lint_store.get_lint_groups().partition(|&(.., p)| p);
1008-
let plugin_groups = sort_lint_groups(plugin_groups);
1003+
let loaded_groups = sort_lint_groups(loaded_groups);
10091004
let builtin_groups = sort_lint_groups(builtin_groups);
10101005

10111006
let max_name_len =
1012-
plugin.iter().chain(&builtin).map(|&s| s.name.chars().count()).max().unwrap_or(0);
1007+
loaded.iter().chain(&builtin).map(|&s| s.name.chars().count()).max().unwrap_or(0);
10131008
let padded = |x: &str| {
10141009
let mut s = " ".repeat(max_name_len - x.chars().count());
10151010
s.push_str(x);
@@ -1037,7 +1032,7 @@ Available lint options:
10371032

10381033
let max_name_len = max(
10391034
"warnings".len(),
1040-
plugin_groups
1035+
loaded_groups
10411036
.iter()
10421037
.chain(&builtin_groups)
10431038
.map(|&(s, _)| s.chars().count())
@@ -1075,20 +1070,22 @@ Available lint options:
10751070

10761071
print_lint_groups(builtin_groups, true);
10771072

1078-
match (loaded_plugins, plugin.len(), plugin_groups.len()) {
1073+
match (loaded_lints, loaded.len(), loaded_groups.len()) {
10791074
(false, 0, _) | (false, _, 0) => {
1080-
safe_println!("Lint tools like Clippy can provide additional lints and lint groups.");
1075+
safe_println!("Lint tools like Clippy can load additional lints and lint groups.");
1076+
}
1077+
(false, ..) => panic!("didn't load additional lints but got them anyway!"),
1078+
(true, 0, 0) => {
1079+
safe_println!("This crate does not load any additional lints or lint groups.")
10811080
}
1082-
(false, ..) => panic!("didn't load lint plugins but got them anyway!"),
1083-
(true, 0, 0) => safe_println!("This crate does not load any lint plugins or lint groups."),
10841081
(true, l, g) => {
10851082
if l > 0 {
1086-
safe_println!("Lint checks provided by plugins loaded by this crate:\n");
1087-
print_lints(plugin);
1083+
safe_println!("Lint checks loaded by this crate:\n");
1084+
print_lints(loaded);
10881085
}
10891086
if g > 0 {
1090-
safe_println!("Lint groups provided by plugins loaded by this crate:\n");
1091-
print_lint_groups(plugin_groups, false);
1087+
safe_println!("Lint groups loaded by this crate:\n");
1088+
print_lint_groups(loaded_groups, false);
10921089
}
10931090
}
10941091
}
@@ -1105,7 +1102,7 @@ pub fn describe_flag_categories(handler: &EarlyErrorHandler, matches: &Matches)
11051102
rustc_errors::FatalError.raise();
11061103
}
11071104

1108-
// Don't handle -W help here, because we might first load plugins.
1105+
// Don't handle -W help here, because we might first load additional lints.
11091106
let debug_flags = matches.opt_strs("Z");
11101107
if debug_flags.iter().any(|x| *x == "help") {
11111108
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/active.rs

-2
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,6 @@ declare_features! (
524524
(active, object_safe_for_dispatch, "1.40.0", Some(43561), None),
525525
/// Allows using `#[optimize(X)]`.
526526
(active, optimize_attribute, "1.34.0", Some(54882), None),
527-
/// Allows using `#![plugin(myplugin)]`.
528-
(active, plugin, "1.0.0", Some(29597), None),
529527
/// Allows exhaustive integer pattern matching on `usize` and `isize`.
530528
(active, precise_pointer_size_matching, "1.32.0", Some(56354), None),
531529
/// Allows macro attributes on expressions, statements and non-inline modules.

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
@@ -155,9 +155,12 @@ declare_features! (
155155
Some("removed in favor of `#![feature(marker_trait_attr)]`")),
156156
(removed, panic_implementation, "1.28.0", Some(44489), None,
157157
Some("subsumed by `#[panic_handler]`")),
158+
/// Allows using `#![plugin(myplugin)]`.
159+
(removed, plugin, "1.74.0", Some(29597), None, // njn: version?
160+
Some("plugins are no longer supported")),
158161
/// Allows using `#[plugin_registrar]` on functions.
159162
(removed, plugin_registrar, "1.54.0", Some(29597), None,
160-
Some("a __rustc_plugin_registrar symbol must now be defined instead")),
163+
Some("plugins are no longer supported")),
161164
(removed, proc_macro_expr, "1.27.0", Some(54727), None,
162165
Some("subsumed by `#![feature(proc_macro_hygiene)]`")),
163166
(removed, proc_macro_gen, "1.27.0", Some(54727), None,

compiler/rustc_interface/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ rustc_hir_analysis = { path = "../rustc_hir_analysis" }
4343
rustc_hir_typeck = { path = "../rustc_hir_typeck" }
4444
rustc_lint = { path = "../rustc_lint" }
4545
rustc_errors = { path = "../rustc_errors" }
46-
rustc_plugin_impl = { path = "../rustc_plugin_impl" }
4746
rustc_privacy = { path = "../rustc_privacy" }
4847
rustc_query_system = { path = "../rustc_query_system" }
4948
rustc_query_impl = { path = "../rustc_query_impl" }

compiler/rustc_interface/src/interface.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ pub struct Config {
261261
pub parse_sess_created: Option<Box<dyn FnOnce(&mut ParseSess) + Send>>,
262262

263263
/// This is a callback from the driver that is called when we're registering lints;
264-
/// it is called during plugin registration when we have the LintStore in a non-shared state.
264+
/// it is called during lint loading when we have the LintStore in a non-shared state.
265265
///
266266
/// Note that if you find a Some here you probably want to call that function in the new
267267
/// 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)