Skip to content

Commit 5c462a3

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 ab161d1 commit 5c462a3

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3796,7 +3796,6 @@ dependencies = [
37963796
"rustc_monomorphize",
37973797
"rustc_parse",
37983798
"rustc_passes",
3799-
"rustc_plugin_impl",
38003799
"rustc_privacy",
38013800
"rustc_query_system",
38023801
"rustc_resolve",
@@ -4085,7 +4084,6 @@ dependencies = [
40854084
"rustc_monomorphize",
40864085
"rustc_parse",
40874086
"rustc_passes",
4088-
"rustc_plugin_impl",
40894087
"rustc_privacy",
40904088
"rustc_query_impl",
40914089
"rustc_query_system",
@@ -4395,21 +4393,6 @@ dependencies = [
43954393
"tracing",
43964394
]
43974395

4398-
[[package]]
4399-
name = "rustc_plugin_impl"
4400-
version = "0.0.0"
4401-
dependencies = [
4402-
"libloading 0.7.4",
4403-
"rustc_ast",
4404-
"rustc_errors",
4405-
"rustc_fluent_macro",
4406-
"rustc_lint",
4407-
"rustc_macros",
4408-
"rustc_metadata",
4409-
"rustc_session",
4410-
"rustc_span",
4411-
]
4412-
44134396
[[package]]
44144397
name = "rustc_privacy"
44154398
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
@@ -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

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

Lines changed: 21 additions & 24 deletions
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::{
@@ -132,7 +130,6 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
132130
rustc_monomorphize::DEFAULT_LOCALE_RESOURCE,
133131
rustc_parse::DEFAULT_LOCALE_RESOURCE,
134132
rustc_passes::DEFAULT_LOCALE_RESOURCE,
135-
rustc_plugin_impl::DEFAULT_LOCALE_RESOURCE,
136133
rustc_privacy::DEFAULT_LOCALE_RESOURCE,
137134
rustc_query_system::DEFAULT_LOCALE_RESOURCE,
138135
rustc_resolve::DEFAULT_LOCALE_RESOURCE,
@@ -994,16 +991,14 @@ the command line flag directly.
994991
}
995992

996993
/// Write to stdout lint command options, together with a list of all available lints
997-
pub fn describe_lints(sess: &Session, lint_store: &LintStore, loaded_plugins: bool) {
994+
pub fn describe_lints(sess: &Session, lint_store: &LintStore, loaded_lints: bool) {
998995
safe_println!(
999996
"
1000997
Available lint options:
1001998
-W <foo> Warn about <foo>
1002-
-A <foo> \
1003-
Allow <foo>
999+
-A <foo> Allow <foo>
10041000
-D <foo> Deny <foo>
1005-
-F <foo> Forbid <foo> \
1006-
(deny <foo> and all attempts to override)
1001+
-F <foo> Forbid <foo> (deny <foo> and all attempts to override)
10071002
10081003
"
10091004
);
@@ -1022,18 +1017,18 @@ Available lint options:
10221017
lints
10231018
}
10241019

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

1030-
let (plugin_groups, builtin_groups): (Vec<_>, _) =
1025+
let (loaded_groups, builtin_groups): (Vec<_>, _) =
10311026
lint_store.get_lint_groups().partition(|&(.., p)| p);
1032-
let plugin_groups = sort_lint_groups(plugin_groups);
1027+
let loaded_groups = sort_lint_groups(loaded_groups);
10331028
let builtin_groups = sort_lint_groups(builtin_groups);
10341029

10351030
let max_name_len =
1036-
plugin.iter().chain(&builtin).map(|&s| s.name.chars().count()).max().unwrap_or(0);
1031+
loaded.iter().chain(&builtin).map(|&s| s.name.chars().count()).max().unwrap_or(0);
10371032
let padded = |x: &str| {
10381033
let mut s = " ".repeat(max_name_len - x.chars().count());
10391034
s.push_str(x);
@@ -1061,7 +1056,7 @@ Available lint options:
10611056

10621057
let max_name_len = max(
10631058
"warnings".len(),
1064-
plugin_groups
1059+
loaded_groups
10651060
.iter()
10661061
.chain(&builtin_groups)
10671062
.map(|&(s, _)| s.chars().count())
@@ -1099,20 +1094,22 @@ Available lint options:
10991094

11001095
print_lint_groups(builtin_groups, true);
11011096

1102-
match (loaded_plugins, plugin.len(), plugin_groups.len()) {
1097+
match (loaded_lints, loaded.len(), loaded_groups.len()) {
11031098
(false, 0, _) | (false, _, 0) => {
1104-
safe_println!("Lint tools like Clippy can provide additional lints and lint groups.");
1099+
safe_println!("Lint tools like Clippy can load additional lints and lint groups.");
1100+
}
1101+
(false, ..) => panic!("didn't load additional lints but got them anyway!"),
1102+
(true, 0, 0) => {
1103+
safe_println!("This crate does not load any additional lints or lint groups.")
11051104
}
1106-
(false, ..) => panic!("didn't load lint plugins but got them anyway!"),
1107-
(true, 0, 0) => safe_println!("This crate does not load any lint plugins or lint groups."),
11081105
(true, l, g) => {
11091106
if l > 0 {
1110-
safe_println!("Lint checks provided by plugins loaded by this crate:\n");
1111-
print_lints(plugin);
1107+
safe_println!("Lint checks loaded by this crate:\n");
1108+
print_lints(loaded);
11121109
}
11131110
if g > 0 {
1114-
safe_println!("Lint groups provided by plugins loaded by this crate:\n");
1115-
print_lint_groups(plugin_groups, false);
1111+
safe_println!("Lint groups loaded by this crate:\n");
1112+
print_lint_groups(loaded_groups, false);
11161113
}
11171114
}
11181115
}
@@ -1129,7 +1126,7 @@ pub fn describe_flag_categories(handler: &EarlyErrorHandler, matches: &Matches)
11291126
rustc_errors::FatalError.raise();
11301127
}
11311128

1132-
// Don't handle -W help here, because we might first load plugins.
1129+
// Don't handle -W help here, because we might first load additional lints.
11331130
let debug_flags = matches.opt_strs("Z");
11341131
if debug_flags.iter().any(|x| *x == "help") {
11351132
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/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
@@ -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

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

0 commit comments

Comments
 (0)