From e4ee172ab05b03bf71e0d89e0042a89ff26a3c29 Mon Sep 17 00:00:00 2001 From: unexge Date: Sat, 2 May 2020 21:14:08 +0300 Subject: [PATCH 1/3] Add long error explanation for E0539 --- src/librustc_error_codes/error_codes.rs | 2 +- src/librustc_error_codes/error_codes/E0539.md | 42 +++++++++++++++++++ .../stability-attribute-sanity.stderr | 3 +- 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 src/librustc_error_codes/error_codes/E0539.md diff --git a/src/librustc_error_codes/error_codes.rs b/src/librustc_error_codes/error_codes.rs index bf4a6c52ab858..e01412bc21cfd 100644 --- a/src/librustc_error_codes/error_codes.rs +++ b/src/librustc_error_codes/error_codes.rs @@ -281,6 +281,7 @@ E0535: include_str!("./error_codes/E0535.md"), E0536: include_str!("./error_codes/E0536.md"), E0537: include_str!("./error_codes/E0537.md"), E0538: include_str!("./error_codes/E0538.md"), +E0539: include_str!("./error_codes/E0539.md"), E0541: include_str!("./error_codes/E0541.md"), E0550: include_str!("./error_codes/E0550.md"), E0551: include_str!("./error_codes/E0551.md"), @@ -570,7 +571,6 @@ E0753: include_str!("./error_codes/E0753.md"), E0521, // borrowed data escapes outside of closure E0523, // E0526, // shuffle indices are not constant - E0539, // incorrect meta item E0540, // multiple rustc_deprecated attributes E0542, // missing 'since' E0543, // missing 'reason' diff --git a/src/librustc_error_codes/error_codes/E0539.md b/src/librustc_error_codes/error_codes/E0539.md new file mode 100644 index 0000000000000..69555453514fe --- /dev/null +++ b/src/librustc_error_codes/error_codes/E0539.md @@ -0,0 +1,42 @@ +An invalid meta-item was used inside an attribute. + +Erroneous code example: + +```compile_fail,E0539 +#[rustc_deprecated(reason)] // error! +#[unstable(feature = "deprecated_fn", issue = "123")] +fn deprecated() {} + +#[unstable(feature = "unstable_struct", issue)] // error! +struct Unstable; + +#[rustc_const_unstable(feature)] // error! +const fn unstable_fn() {} + +#[stable(feature = "stable_struct", since)] // error! +struct Stable; + +#[rustc_const_stable(feature)] // error! +const fn stable_fn() {} +``` + +Meta items are the key-value pairs inside of an attribute. +To fix these issues you need to give required key-value pairs. + +``` +#[rustc_deprecated(since = "1.39.0", reason = "reason")] // ok! +#[unstable(feature = "deprecated_fn", issue = "123")] +fn deprecated() {} + +#[unstable(feature = "unstable_struct", issue = "123")] // ok! +struct Unstable; + +#[rustc_const_unstable(feature = "unstable_fn", issue = "124")] // ok! +const fn unstable_fn() {} + +#[stable(feature = "stable_struct", since = "1.39.0")] // ok! +struct Stable; + +#[rustc_const_stable(feature = "stable_fn", since = "1.39.0")] // ok! +const fn stable_fn() {} +``` diff --git a/src/test/ui/stability-attribute/stability-attribute-sanity.stderr b/src/test/ui/stability-attribute/stability-attribute-sanity.stderr index d0ca170503796..3c5da3f144035 100644 --- a/src/test/ui/stability-attribute/stability-attribute-sanity.stderr +++ b/src/test/ui/stability-attribute/stability-attribute-sanity.stderr @@ -108,4 +108,5 @@ LL | fn deprecated_without_unstable_or_stable() { } error: aborting due to 18 previous errors -For more information about this error, try `rustc --explain E0541`. +Some errors have detailed explanations: E0539, E0541. +For more information about an error, try `rustc --explain E0539`. From 95365672108a76871583dea6fc1fe1b523a47ab0 Mon Sep 17 00:00:00 2001 From: unexge Date: Sat, 2 May 2020 23:10:34 +0300 Subject: [PATCH 2/3] Add `#![feature(staged_api)]` attribute to E0539 error examples --- src/librustc_error_codes/error_codes/E0539.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustc_error_codes/error_codes/E0539.md b/src/librustc_error_codes/error_codes/E0539.md index 69555453514fe..a9224c4182190 100644 --- a/src/librustc_error_codes/error_codes/E0539.md +++ b/src/librustc_error_codes/error_codes/E0539.md @@ -3,6 +3,8 @@ An invalid meta-item was used inside an attribute. Erroneous code example: ```compile_fail,E0539 +#![feature(staged_api)] + #[rustc_deprecated(reason)] // error! #[unstable(feature = "deprecated_fn", issue = "123")] fn deprecated() {} @@ -24,6 +26,8 @@ Meta items are the key-value pairs inside of an attribute. To fix these issues you need to give required key-value pairs. ``` +#![feature(staged_api)] + #[rustc_deprecated(since = "1.39.0", reason = "reason")] // ok! #[unstable(feature = "deprecated_fn", issue = "123")] fn deprecated() {} From ef813ca95a674a19f15ce53ce432d2fb185d7fe2 Mon Sep 17 00:00:00 2001 From: unexge Date: Sun, 3 May 2020 00:25:45 +0300 Subject: [PATCH 3/3] Add stability attribute to E0539 error examples --- src/librustc_error_codes/error_codes/E0539.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustc_error_codes/error_codes/E0539.md b/src/librustc_error_codes/error_codes/E0539.md index a9224c4182190..df2d7d910bb36 100644 --- a/src/librustc_error_codes/error_codes/E0539.md +++ b/src/librustc_error_codes/error_codes/E0539.md @@ -4,6 +4,7 @@ Erroneous code example: ```compile_fail,E0539 #![feature(staged_api)] +#![stable(since = "1.0.0", feature = "test")] #[rustc_deprecated(reason)] // error! #[unstable(feature = "deprecated_fn", issue = "123")] @@ -27,6 +28,7 @@ To fix these issues you need to give required key-value pairs. ``` #![feature(staged_api)] +#![stable(since = "1.0.0", feature = "test")] #[rustc_deprecated(since = "1.39.0", reason = "reason")] // ok! #[unstable(feature = "deprecated_fn", issue = "123")]