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 #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

Lines changed: 0 additions & 17 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 21 additions & 24 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 3 additions & 6 deletions
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 18 deletions
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

Lines changed: 4 additions & 1 deletion
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,

0 commit comments

Comments
 (0)