Skip to content

Commit 287ceed

Browse files
committed
Deprecate #![plugin] and #[plugin_registrar].
1 parent 2daa404 commit 287ceed

20 files changed

+119
-18
lines changed

src/libsyntax/feature_gate/builtin_attrs.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,14 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
279279

280280
// Plugins:
281281
ungated!(plugin_registrar, Normal, template!(Word)),
282-
gated!(
283-
plugin, CrateLevel, template!(List: "name|name(args)"),
284-
"compiler plugins are experimental and possibly buggy",
282+
(
283+
sym::plugin, CrateLevel, template!(List: "name|name(args)"),
284+
Gated(
285+
Stability::Deprecated("https://github.com/rust-lang/rust/issues/29597", None),
286+
sym::plugin,
287+
"compiler plugins are deprecated and will be removed in 1.44.0",
288+
cfg_fn!(plugin)
289+
)
285290
),
286291

287292
// Testing:

src/libsyntax/feature_gate/check.rs

+4
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
311311
if attr::contains_name(&i.attrs[..], sym::plugin_registrar) {
312312
gate_feature_post!(&self, plugin_registrar, i.span,
313313
"compiler plugins are experimental and possibly buggy");
314+
self.parse_sess.span_diagnostic.span_warn(
315+
i.span,
316+
"`#[plugin_registrar]` is deprecated and will be removed in 1.44.0",
317+
);
314318
}
315319
if attr::contains_name(&i.attrs[..], sym::start) {
316320
gate_feature_post!(&self, start, i.span,

src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl MetadataLoader for NoLlvmMetadataLoader {
4141
struct TheBackend;
4242

4343
impl CodegenBackend for TheBackend {
44-
fn metadata_loader(&self) -> Box<MetadataLoader + Sync> {
44+
fn metadata_loader(&self) -> Box<dyn MetadataLoader + Sync> {
4545
Box::new(NoLlvmMetadataLoader)
4646
}
4747

@@ -64,15 +64,15 @@ impl CodegenBackend for TheBackend {
6464
tcx: TyCtxt<'tcx>,
6565
_metadata: EncodedMetadata,
6666
_need_metadata_module: bool,
67-
) -> Box<Any> {
67+
) -> Box<dyn Any> {
6868
use rustc::hir::def_id::LOCAL_CRATE;
6969

7070
Box::new(tcx.crate_name(LOCAL_CRATE) as Symbol)
7171
}
7272

7373
fn join_codegen_and_link(
7474
&self,
75-
ongoing_codegen: Box<Any>,
75+
ongoing_codegen: Box<dyn Any>,
7676
sess: &Session,
7777
_dep_graph: &DepGraph,
7878
outputs: &OutputFilenames,
@@ -97,6 +97,6 @@ impl CodegenBackend for TheBackend {
9797

9898
/// This is the entrypoint for a hot plugged rustc_codegen_llvm
9999
#[no_mangle]
100-
pub fn __rustc_codegen_backend() -> Box<CodegenBackend> {
100+
pub fn __rustc_codegen_backend() -> Box<dyn CodegenBackend> {
101101
Box::new(TheBackend)
102102
}

src/test/ui-fulldeps/gated-plugin.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
// ignore-tidy-linelength
12
// aux-build:attr-plugin-test.rs
23

34
#![plugin(attr_plugin_test)]
4-
//~^ ERROR compiler plugins are experimental and possibly buggy
5+
//~^ ERROR compiler plugins are deprecated and will be removed in 1.44.0
6+
//~| WARN use of deprecated attribute `plugin`: compiler plugins are deprecated and will be removed in 1.44.0
57

68
fn main() {}
+10-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
error[E0658]: compiler plugins are experimental and possibly buggy
2-
--> $DIR/gated-plugin.rs:3:1
1+
error[E0658]: compiler plugins are deprecated and will be removed in 1.44.0
2+
--> $DIR/gated-plugin.rs:4:1
33
|
44
LL | #![plugin(attr_plugin_test)]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: for more information, see https://github.com/rust-lang/rust/issues/29597
88
= help: add `#![feature(plugin)]` to the crate attributes to enable
99

10+
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated and will be removed in 1.44.0. See https://github.com/rust-lang/rust/issues/29597
11+
--> $DIR/gated-plugin.rs:4:1
12+
|
13+
LL | #![plugin(attr_plugin_test)]
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
15+
|
16+
= note: `#[warn(deprecated)]` on by default
17+
1018
error: aborting due to previous error
1119

1220
For more information about this error, try `rustc --explain E0658`.

src/test/ui-fulldeps/macro-crate-rlib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
#![feature(plugin)]
66
#![plugin(rlib_crate_test)]
77
//~^ ERROR: plugin `rlib_crate_test` only found in rlib format, but must be available in dylib format
8+
//~| WARN use of deprecated attribute `plugin`: compiler plugins are deprecated and will be removed in 1.44.0
89

910
fn main() {}

src/test/ui-fulldeps/macro-crate-rlib.stderr

+8
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,13 @@ error[E0457]: plugin `rlib_crate_test` only found in rlib format, but must be av
44
LL | #![plugin(rlib_crate_test)]
55
| ^^^^^^^^^^^^^^^
66

7+
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated and will be removed in 1.44.0. See https://github.com/rust-lang/rust/issues/29597
8+
--> $DIR/macro-crate-rlib.rs:6:1
9+
|
10+
LL | #![plugin(rlib_crate_test)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
12+
|
13+
= note: `#[warn(deprecated)]` on by default
14+
715
error: aborting due to previous error
816

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Test that `#![plugin(...)]` attribute is gated by `plugin` feature gate
22

33
#![plugin(foo)]
4-
//~^ ERROR compiler plugins are experimental and possibly buggy
4+
//~^ ERROR compiler plugins are deprecated and will be removed in 1.44.0
5+
//~| WARN use of deprecated attribute `plugin`: compiler plugins are deprecated
56

67
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0658]: compiler plugins are experimental and possibly buggy
1+
error[E0658]: compiler plugins are deprecated and will be removed in 1.44.0
22
--> $DIR/feature-gate-plugin.rs:3:1
33
|
44
LL | #![plugin(foo)]
@@ -7,6 +7,14 @@ LL | #![plugin(foo)]
77
= note: for more information, see https://github.com/rust-lang/rust/issues/29597
88
= help: add `#![feature(plugin)]` to the crate attributes to enable
99

10+
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated and will be removed in 1.44.0. See https://github.com/rust-lang/rust/issues/29597
11+
--> $DIR/feature-gate-plugin.rs:3:1
12+
|
13+
LL | #![plugin(foo)]
14+
| ^^^^^^^^^^^^^^^ help: remove this attribute
15+
|
16+
= note: `#[warn(deprecated)]` on by default
17+
1018
error: aborting due to previous error
1119

1220
For more information about this error, try `rustc --explain E0658`.

src/test/ui/feature-gates/feature-gate-plugin_registrar.rs

+2
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
#[plugin_registrar]
66
pub fn registrar() {}
77
//~^ ERROR compiler plugins are experimental
8+
//~| WARN `#[plugin_registrar]` is deprecated and will be removed in 1.44.0
9+
810
fn main() {}

src/test/ui/feature-gates/feature-gate-plugin_registrar.stderr

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ LL | pub fn registrar() {}
77
= note: for more information, see https://github.com/rust-lang/rust/issues/29597
88
= help: add `#![feature(plugin_registrar)]` to the crate attributes to enable
99

10+
warning: `#[plugin_registrar]` is deprecated and will be removed in 1.44.0
11+
--> $DIR/feature-gate-plugin_registrar.rs:6:1
12+
|
13+
LL | pub fn registrar() {}
14+
| ^^^^^^^^^^^^^^^^^^^^^
15+
1016
error: aborting due to previous error
1117

1218
For more information about this error, try `rustc --explain E0658`.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
// ignore-tidy-linelength
2+
13
#![deny(unused_attributes)]
24
#![feature(plugin)]
35

46
#[plugin(bla)] //~ ERROR unused attribute
57
//~^ ERROR should be an inner attribute
8+
//~| WARN use of deprecated attribute `plugin`: compiler plugins are deprecated and will be removed in 1.44.0
69

710
fn main() {}

src/test/ui/invalid/invalid-plugin-attr.stderr

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1+
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated and will be removed in 1.44.0. See https://github.com/rust-lang/rust/issues/29597
2+
--> $DIR/invalid-plugin-attr.rs:6:1
3+
|
4+
LL | #[plugin(bla)]
5+
| ^^^^^^^^^^^^^^ help: remove this attribute
6+
|
7+
= note: `#[warn(deprecated)]` on by default
8+
19
error: unused attribute
2-
--> $DIR/invalid-plugin-attr.rs:4:1
10+
--> $DIR/invalid-plugin-attr.rs:6:1
311
|
412
LL | #[plugin(bla)]
513
| ^^^^^^^^^^^^^^
614
|
715
note: lint level defined here
8-
--> $DIR/invalid-plugin-attr.rs:1:9
16+
--> $DIR/invalid-plugin-attr.rs:3:9
917
|
1018
LL | #![deny(unused_attributes)]
1119
| ^^^^^^^^^^^^^^^^^
1220

1321
error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
14-
--> $DIR/invalid-plugin-attr.rs:4:1
22+
--> $DIR/invalid-plugin-attr.rs:6:1
1523
|
1624
LL | #[plugin(bla)]
1725
| ^^^^^^^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
// ignore-tidy-linelength
2+
13
#![feature(plugin)]
24
#![plugin] //~ ERROR malformed `plugin` attribute
5+
//~| WARN use of deprecated attribute `plugin`: compiler plugins are deprecated and will be removed in 1.44.0
36

47
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
error: malformed `plugin` attribute input
2-
--> $DIR/malformed-plugin-1.rs:2:1
2+
--> $DIR/malformed-plugin-1.rs:4:1
33
|
44
LL | #![plugin]
55
| ^^^^^^^^^^ help: must be of the form: `#[plugin(name|name(args))]`
66

7+
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated and will be removed in 1.44.0. See https://github.com/rust-lang/rust/issues/29597
8+
--> $DIR/malformed-plugin-1.rs:4:1
9+
|
10+
LL | #![plugin]
11+
| ^^^^^^^^^^ help: remove this attribute
12+
|
13+
= note: `#[warn(deprecated)]` on by default
14+
715
error: aborting due to previous error
816

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
// ignore-tidy-linelength
2+
13
#![feature(plugin)]
24
#![plugin="bleh"] //~ ERROR malformed `plugin` attribute
5+
//~| WARN use of deprecated attribute `plugin`: compiler plugins are deprecated and will be removed in 1.44.0
36

47
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
error: malformed `plugin` attribute input
2-
--> $DIR/malformed-plugin-2.rs:2:1
2+
--> $DIR/malformed-plugin-2.rs:4:1
33
|
44
LL | #![plugin="bleh"]
55
| ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[plugin(name|name(args))]`
66

7+
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated and will be removed in 1.44.0. See https://github.com/rust-lang/rust/issues/29597
8+
--> $DIR/malformed-plugin-2.rs:4:1
9+
|
10+
LL | #![plugin="bleh"]
11+
| ^^^^^^^^^^^^^^^^^ help: remove this attribute
12+
|
13+
= note: `#[warn(deprecated)]` on by default
14+
715
error: aborting due to previous error
816

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
// ignore-tidy-linelength
2+
13
#![feature(plugin)]
24
#![plugin(foo="bleh")] //~ ERROR malformed `plugin` attribute
5+
//~| WARN use of deprecated attribute `plugin`: compiler plugins are deprecated and will be removed in 1.44.0
36

47
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
error[E0498]: malformed `plugin` attribute
2-
--> $DIR/malformed-plugin-3.rs:2:1
2+
--> $DIR/malformed-plugin-3.rs:4:1
33
|
44
LL | #![plugin(foo="bleh")]
55
| ^^^^^^^^^^^^^^^^^^^^^^ malformed attribute
66

7+
warning: use of deprecated attribute `plugin`: compiler plugins are deprecated and will be removed in 1.44.0. See https://github.com/rust-lang/rust/issues/29597
8+
--> $DIR/malformed-plugin-3.rs:4:1
9+
|
10+
LL | #![plugin(foo="bleh")]
11+
| ^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
12+
|
13+
= note: `#[warn(deprecated)]` on by default
14+
715
error: aborting due to previous error
816

src/test/ui/multiple-plugin-registrars.stderr

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
warning: `#[plugin_registrar]` is deprecated and will be removed in 1.44.0
2+
--> $DIR/multiple-plugin-registrars.rs:7:1
3+
|
4+
LL | pub fn one() {}
5+
| ^^^^^^^^^^^^^^^
6+
7+
warning: `#[plugin_registrar]` is deprecated and will be removed in 1.44.0
8+
--> $DIR/multiple-plugin-registrars.rs:10:1
9+
|
10+
LL | pub fn two() {}
11+
| ^^^^^^^^^^^^^^^
12+
113
error: multiple plugin registration functions found
214
|
315
note: one is here

0 commit comments

Comments
 (0)