Rollup merge of #62042 - petrochenkov:macstab, r=matthewjasper
Support stability and deprecation checking for all macros RELNOTES: Deprecation attributes on macros now have effect. Fixes https://github.com/rust-lang/rust/issues/34079 Fixes https://github.com/rust-lang/rust/issues/49912 Unblocks https://github.com/rust-lang/rust/pull/62086 Unblocks https://github.com/rust-lang/rust/pull/61000
This commit is contained in:
commit
3250b8ee59
54 changed files with 517 additions and 431 deletions
|
|
@ -1,7 +1,7 @@
|
|||
// run-pass
|
||||
// aux-build:unstable-macros.rs
|
||||
|
||||
#![feature(unstable_macros)]
|
||||
#![feature(unstable_macros, local_unstable)]
|
||||
|
||||
#[macro_use] extern crate unstable_macros;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
warning: derive(Encodable) is deprecated in favor of derive(RustcEncodable)
|
||||
warning: use of deprecated item 'Encodable': derive(Encodable) is deprecated in favor of derive(RustcEncodable)
|
||||
--> $DIR/deprecated-derive.rs:8:10
|
||||
|
|
||||
LL | #[derive(Encodable)]
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: #[warn(deprecated)] on by default
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0658]: inline assembly is not stable enough for use and is subject to change
|
||||
error[E0658]: use of unstable library feature 'asm': inline assembly is not stable enough for use and is subject to change
|
||||
--> $DIR/feature-gate-asm.rs:3:9
|
||||
|
|
||||
LL | asm!("");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0658]: inline assembly is not stable enough for use and is subject to change
|
||||
error[E0658]: use of unstable library feature 'asm': inline assembly is not stable enough for use and is subject to change
|
||||
--> $DIR/feature-gate-asm2.rs:5:26
|
||||
|
|
||||
LL | println!("{:?}", asm!(""));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0658]: `concat_idents` is not stable enough for use and is subject to change
|
||||
error[E0658]: use of unstable library feature 'concat_idents': `concat_idents` is not stable enough for use and is subject to change
|
||||
--> $DIR/feature-gate-concat_idents.rs:5:13
|
||||
|
|
||||
LL | let a = concat_idents!(X, Y_1);
|
||||
|
|
@ -7,7 +7,7 @@ LL | let a = concat_idents!(X, Y_1);
|
|||
= note: for more information, see https://github.com/rust-lang/rust/issues/29599
|
||||
= help: add #![feature(concat_idents)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: `concat_idents` is not stable enough for use and is subject to change
|
||||
error[E0658]: use of unstable library feature 'concat_idents': `concat_idents` is not stable enough for use and is subject to change
|
||||
--> $DIR/feature-gate-concat_idents.rs:6:13
|
||||
|
|
||||
LL | let b = concat_idents!(X, Y_2);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0658]: `concat_idents` is not stable enough for use and is subject to change
|
||||
error[E0658]: use of unstable library feature 'concat_idents': `concat_idents` is not stable enough for use and is subject to change
|
||||
--> $DIR/feature-gate-concat_idents2.rs:4:5
|
||||
|
|
||||
LL | concat_idents!(a, b);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0658]: `concat_idents` is not stable enough for use and is subject to change
|
||||
error[E0658]: use of unstable library feature 'concat_idents': `concat_idents` is not stable enough for use and is subject to change
|
||||
--> $DIR/feature-gate-concat_idents3.rs:7:20
|
||||
|
|
||||
LL | assert_eq!(10, concat_idents!(X, Y_1));
|
||||
|
|
@ -7,7 +7,7 @@ LL | assert_eq!(10, concat_idents!(X, Y_1));
|
|||
= note: for more information, see https://github.com/rust-lang/rust/issues/29599
|
||||
= help: add #![feature(concat_idents)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: `concat_idents` is not stable enough for use and is subject to change
|
||||
error[E0658]: use of unstable library feature 'concat_idents': `concat_idents` is not stable enough for use and is subject to change
|
||||
--> $DIR/feature-gate-concat_idents3.rs:8:20
|
||||
|
|
||||
LL | assert_eq!(20, concat_idents!(X, Y_2));
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
#![test_runner(main)] //~ ERROR custom test frameworks are an unstable feature
|
||||
|
||||
#[test_case] //~ ERROR custom test frameworks are an unstable feature
|
||||
fn f() {}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,12 @@
|
|||
error[E0658]: use of unstable library feature 'custom_test_frameworks': custom test frameworks are an unstable feature
|
||||
--> $DIR/feature-gate-custom_test_frameworks.rs:3:1
|
||||
|
|
||||
LL | #[test_case]
|
||||
| ^^^^^^^^^^^^
|
||||
|
|
||||
= note: for more information, see https://github.com/rust-lang/rust/issues/50297
|
||||
= help: add #![feature(custom_test_frameworks)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: custom test frameworks are an unstable feature
|
||||
--> $DIR/feature-gate-custom_test_frameworks.rs:1:1
|
||||
|
|
||||
|
|
@ -7,6 +16,6 @@ LL | #![test_runner(main)]
|
|||
= note: for more information, see https://github.com/rust-lang/rust/issues/50297
|
||||
= help: add #![feature(custom_test_frameworks)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0658]: `format_args_nl` is only for internal language use and is subject to change
|
||||
error[E0658]: use of unstable library feature 'format_args_nl': `format_args_nl` is only for internal language use and is subject to change
|
||||
--> $DIR/feature-gate-format_args_nl.rs:2:5
|
||||
|
|
||||
LL | format_args_nl!("");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0658]: `global_asm!` is not stable enough for use and is subject to change
|
||||
error[E0658]: use of unstable library feature 'global_asm': `global_asm!` is not stable enough for use and is subject to change
|
||||
--> $DIR/feature-gate-global_asm.rs:1:1
|
||||
|
|
||||
LL | global_asm!("");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0658]: `log_syntax!` is not stable enough for use and is subject to change
|
||||
error[E0658]: use of unstable library feature 'log_syntax': `log_syntax!` is not stable enough for use and is subject to change
|
||||
--> $DIR/feature-gate-log_syntax.rs:2:5
|
||||
|
|
||||
LL | log_syntax!()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0658]: `log_syntax!` is not stable enough for use and is subject to change
|
||||
error[E0658]: use of unstable library feature 'log_syntax': `log_syntax!` is not stable enough for use and is subject to change
|
||||
--> $DIR/feature-gate-log_syntax2.rs:4:22
|
||||
|
|
||||
LL | println!("{:?}", log_syntax!());
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0658]: `trace_macros` is not stable enough for use and is subject to change
|
||||
error[E0658]: use of unstable library feature 'trace_macros': `trace_macros` is not stable enough for use and is subject to change
|
||||
--> $DIR/feature-gate-trace_macros.rs:2:5
|
||||
|
|
||||
LL | trace_macros!(true);
|
||||
|
|
|
|||
3
src/test/ui/macros/auxiliary/deprecated-macros.rs
Normal file
3
src/test/ui/macros/auxiliary/deprecated-macros.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#[deprecated(since = "1.0.0", note = "deprecation note")]
|
||||
#[macro_export]
|
||||
macro_rules! deprecated_macro{ () => () }
|
||||
|
|
@ -1,6 +1,16 @@
|
|||
#![feature(decl_macro)]
|
||||
#![feature(staged_api)]
|
||||
#![stable(feature = "unit_test", since = "1.0.0")]
|
||||
|
||||
#[unstable(feature = "unstable_macros", issue = "0")]
|
||||
#[macro_export]
|
||||
macro_rules! unstable_macro{ () => () }
|
||||
|
||||
#[stable(feature = "deprecated_macros", since = "1.0.0")]
|
||||
#[rustc_deprecated(since = "1.0.0", reason = "deprecation reason")]
|
||||
#[macro_export]
|
||||
macro_rules! deprecated_macro{ () => () }
|
||||
|
||||
// FIXME: Cannot use a `pub` macro 2.0 in a staged API crate due to reachability issues.
|
||||
// #[unstable(feature = "unstable_macros", issue = "0")]
|
||||
// pub macro unstable_macro_modern() {}
|
||||
|
|
|
|||
13
src/test/ui/macros/macro-deprecation.rs
Normal file
13
src/test/ui/macros/macro-deprecation.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
// check-pass
|
||||
// aux-build:deprecated-macros.rs
|
||||
|
||||
#[macro_use] extern crate deprecated_macros;
|
||||
|
||||
#[deprecated(since = "1.0.0", note = "local deprecation note")]
|
||||
#[macro_export]
|
||||
macro_rules! local_deprecated{ () => () }
|
||||
|
||||
fn main() {
|
||||
local_deprecated!(); //~ WARN use of deprecated item 'local_deprecated': local deprecation note
|
||||
deprecated_macro!(); //~ WARN use of deprecated item 'deprecated_macro': deprecation note
|
||||
}
|
||||
14
src/test/ui/macros/macro-deprecation.stderr
Normal file
14
src/test/ui/macros/macro-deprecation.stderr
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
warning: use of deprecated item 'local_deprecated': local deprecation note
|
||||
--> $DIR/macro-deprecation.rs:11:5
|
||||
|
|
||||
LL | local_deprecated!();
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[warn(deprecated)] on by default
|
||||
|
||||
warning: use of deprecated item 'deprecated_macro': deprecation note
|
||||
--> $DIR/macro-deprecation.rs:12:5
|
||||
|
|
||||
LL | deprecated_macro!();
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
@ -1,12 +1,28 @@
|
|||
// aux-build:unstable-macros.rs
|
||||
|
||||
#![feature(decl_macro)]
|
||||
#![feature(staged_api)]
|
||||
#[macro_use] extern crate unstable_macros;
|
||||
|
||||
#[unstable(feature = "local_unstable", issue = "0")]
|
||||
macro_rules! local_unstable { () => () }
|
||||
|
||||
#[unstable(feature = "local_unstable", issue = "0")]
|
||||
macro local_unstable_modern() {}
|
||||
|
||||
#[stable(feature = "deprecated_macros", since = "1.0.0")]
|
||||
#[rustc_deprecated(since = "1.0.0", reason = "local deprecation reason")]
|
||||
#[macro_export]
|
||||
macro_rules! local_deprecated{ () => () }
|
||||
|
||||
fn main() {
|
||||
local_unstable!();
|
||||
unstable_macro!(); //~ ERROR: macro unstable_macro! is unstable
|
||||
local_unstable!(); //~ ERROR use of unstable library feature 'local_unstable'
|
||||
local_unstable_modern!(); //~ ERROR use of unstable library feature 'local_unstable'
|
||||
unstable_macro!(); //~ ERROR use of unstable library feature 'unstable_macros'
|
||||
// unstable_macro_modern!(); // ERROR use of unstable library feature 'unstable_macros'
|
||||
|
||||
deprecated_macro!();
|
||||
//~^ WARN use of deprecated item 'deprecated_macro': deprecation reason
|
||||
local_deprecated!();
|
||||
//~^ WARN use of deprecated item 'local_deprecated': local deprecation reason
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,41 @@
|
|||
error[E0658]: macro unstable_macro! is unstable
|
||||
--> $DIR/macro-stability.rs:11:5
|
||||
error[E0658]: use of unstable library feature 'local_unstable'
|
||||
--> $DIR/macro-stability.rs:19:5
|
||||
|
|
||||
LL | local_unstable!();
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(local_unstable)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: use of unstable library feature 'local_unstable'
|
||||
--> $DIR/macro-stability.rs:20:5
|
||||
|
|
||||
LL | local_unstable_modern!();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(local_unstable)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: use of unstable library feature 'unstable_macros'
|
||||
--> $DIR/macro-stability.rs:21:5
|
||||
|
|
||||
LL | unstable_macro!();
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(unstable_macros)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
warning: use of deprecated item 'deprecated_macro': deprecation reason
|
||||
--> $DIR/macro-stability.rs:24:5
|
||||
|
|
||||
LL | deprecated_macro!();
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: #[warn(deprecated)] on by default
|
||||
|
||||
warning: use of deprecated item 'local_deprecated': local deprecation reason
|
||||
--> $DIR/macro-stability.rs:26:5
|
||||
|
|
||||
LL | local_deprecated!();
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
fn main() {
|
||||
println!("{}", __rust_unstable_column!());
|
||||
//~^ERROR the __rust_unstable_column macro is unstable
|
||||
//~^ ERROR use of unstable library feature '__rust_unstable_column'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
error: the __rust_unstable_column macro is unstable
|
||||
error[E0658]: use of unstable library feature '__rust_unstable_column': internal implementation detail of the `column` macro
|
||||
--> $DIR/rust-unstable-column-gated.rs:2:20
|
||||
|
|
||||
LL | println!("{}", __rust_unstable_column!());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(__rust_unstable_column)] to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error[E0658]: `trace_macros` is not stable enough for use and is subject to change
|
||||
error[E0658]: use of unstable library feature 'trace_macros': `trace_macros` is not stable enough for use and is subject to change
|
||||
--> $DIR/trace_macros-gate.rs:4:5
|
||||
|
|
||||
LL | trace_macros!();
|
||||
|
|
@ -13,7 +13,7 @@ error: trace_macros! accepts only `true` or `false`
|
|||
LL | trace_macros!();
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0658]: `trace_macros` is not stable enough for use and is subject to change
|
||||
error[E0658]: use of unstable library feature 'trace_macros': `trace_macros` is not stable enough for use and is subject to change
|
||||
--> $DIR/trace_macros-gate.rs:6:5
|
||||
|
|
||||
LL | trace_macros!(true);
|
||||
|
|
@ -22,7 +22,7 @@ LL | trace_macros!(true);
|
|||
= note: for more information, see https://github.com/rust-lang/rust/issues/29598
|
||||
= help: add #![feature(trace_macros)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: `trace_macros` is not stable enough for use and is subject to change
|
||||
error[E0658]: use of unstable library feature 'trace_macros': `trace_macros` is not stable enough for use and is subject to change
|
||||
--> $DIR/trace_macros-gate.rs:7:5
|
||||
|
|
||||
LL | trace_macros!(false);
|
||||
|
|
@ -31,7 +31,7 @@ LL | trace_macros!(false);
|
|||
= note: for more information, see https://github.com/rust-lang/rust/issues/29598
|
||||
= help: add #![feature(trace_macros)] to the crate attributes to enable
|
||||
|
||||
error[E0658]: `trace_macros` is not stable enough for use and is subject to change
|
||||
error[E0658]: use of unstable library feature 'trace_macros': `trace_macros` is not stable enough for use and is subject to change
|
||||
--> $DIR/trace_macros-gate.rs:10:26
|
||||
|
|
||||
LL | ($x: ident) => { trace_macros!($x) }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue