Skip to content

Commit

Permalink
Rollup merge of rust-lang#65794 - Centril:unimpl-internal, r=varkor
Browse files Browse the repository at this point in the history
gate rustc_on_unimplemented under rustc_attrs

Move `rustc_on_implemented` from the `on_implemented` gate to `rustc_attrs` as it is internal.

Closes rust-lang#29628

r? @varkor
  • Loading branch information
JohnTitor authored Nov 6, 2019
2 parents 3f0e164 + 1c7595f commit 09287e0
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 190 deletions.
154 changes: 0 additions & 154 deletions src/doc/unstable-book/src/language-features/on-unimplemented.md

This file was deleted.

2 changes: 1 addition & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
#![feature(unsize)]
#![feature(unsized_locals)]
#![feature(allocator_internals)]
#![feature(on_unimplemented)]
#![cfg_attr(bootstrap, feature(on_unimplemented))]
#![feature(rustc_const_unstable)]
#![feature(slice_partition_dedup)]
#![feature(maybe_uninit_extra, maybe_uninit_slice)]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
#![feature(nll)]
#![feature(exhaustive_patterns)]
#![feature(no_core)]
#![feature(on_unimplemented)]
#![cfg_attr(bootstrap, feature(on_unimplemented))]
#![feature(optin_builtin_traits)]
#![feature(prelude_import)]
#![feature(repr_simd, platform_intrinsics)]
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ position that needs that trait. For example, when the following code is
compiled:
```compile_fail
#![feature(on_unimplemented)]
#![feature(rustc_attrs)]
fn foo<T: Index<u8>>(x: T){}
Expand Down Expand Up @@ -639,7 +639,7 @@ position that needs that trait. For example, when the following code is
compiled:
```compile_fail
#![feature(on_unimplemented)]
#![feature(rustc_attrs)]
fn foo<T: Index<u8>>(x: T){}
Expand Down Expand Up @@ -669,7 +669,7 @@ position that needs that trait. For example, when the following code is
compiled:
```compile_fail
#![feature(on_unimplemented)]
#![feature(rustc_attrs)]
fn foo<T: Index<u8>>(x: T){}
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@
#![feature(never_type)]
#![feature(nll)]
#![cfg_attr(bootstrap, feature(non_exhaustive))]
#![feature(on_unimplemented)]
#![cfg_attr(bootstrap, feature(on_unimplemented))]
#![feature(optin_builtin_traits)]
#![feature(panic_info_message)]
#![feature(panic_internals)]
Expand Down
3 changes: 0 additions & 3 deletions src/libsyntax/feature_gate/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ declare_features! (
/// Allows using `rustc_*` attributes (RFC 572).
(active, rustc_attrs, "1.0.0", Some(29642), None),

/// Allows using `#[on_unimplemented(..)]` on traits.
(active, on_unimplemented, "1.0.0", Some(29628), None),

/// Allows using the `box $expr` syntax.
(active, box_syntax, "1.0.0", Some(49733), None),

Expand Down
15 changes: 7 additions & 8 deletions src/libsyntax/feature_gate/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ macro_rules! experimental {
}

const IMPL_DETAIL: &str = "internal implementation detail";
const INTERAL_UNSTABLE: &str = "this is an internal attribute that will never be stable";
const INTERNAL_UNSTABLE: &str = "this is an internal attribute that will never be stable";

pub type BuiltinAttribute = (Symbol, AttributeType, AttributeTemplate, AttributeGate);

Expand Down Expand Up @@ -418,14 +418,14 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
linkage, Whitelisted, template!(NameValueStr: "external|internal|..."),
"the `linkage` attribute is experimental and not portable across platforms",
),
rustc_attr!(rustc_std_internal_symbol, Whitelisted, template!(Word), INTERAL_UNSTABLE),
rustc_attr!(rustc_std_internal_symbol, Whitelisted, template!(Word), INTERNAL_UNSTABLE),

// ==========================================================================
// Internal attributes, Macro related:
// ==========================================================================

rustc_attr!(rustc_builtin_macro, Whitelisted, template!(Word), IMPL_DETAIL),
rustc_attr!(rustc_proc_macro_decls, Normal, template!(Word), INTERAL_UNSTABLE),
rustc_attr!(rustc_proc_macro_decls, Normal, template!(Word), INTERNAL_UNSTABLE),
rustc_attr!(
rustc_macro_transparency, Whitelisted,
template!(NameValueStr: "transparent|semitransparent|opaque"),
Expand All @@ -436,25 +436,24 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
// Internal attributes, Diagnostics related:
// ==========================================================================

gated!(
rustc_attr!(
rustc_on_unimplemented, Whitelisted,
template!(
List: r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#,
NameValueStr: "message"
),
on_unimplemented,
experimental!(rustc_on_unimplemented),
INTERNAL_UNSTABLE
),
// Whitelists "identity-like" conversion methods to suggest on type mismatch.
rustc_attr!(rustc_conversion_suggestion, Whitelisted, template!(Word), INTERAL_UNSTABLE),
rustc_attr!(rustc_conversion_suggestion, Whitelisted, template!(Word), INTERNAL_UNSTABLE),

// ==========================================================================
// Internal attributes, Const related:
// ==========================================================================

rustc_attr!(rustc_promotable, Whitelisted, template!(Word), IMPL_DETAIL),
rustc_attr!(rustc_allow_const_fn_ptr, Whitelisted, template!(Word), IMPL_DETAIL),
rustc_attr!(rustc_args_required_const, Whitelisted, template!(List: "N"), INTERAL_UNSTABLE),
rustc_attr!(rustc_args_required_const, Whitelisted, template!(List: "N"), INTERNAL_UNSTABLE),

// ==========================================================================
// Internal attributes, Layout related:
Expand Down
3 changes: 3 additions & 0 deletions src/libsyntax/feature_gate/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ declare_features! (
/// + `__register_diagnostic`
/// +`__build_diagnostic_array`
(removed, rustc_diagnostic_macros, "1.38.0", None, None, None),
/// Allows using `#[on_unimplemented(..)]` on traits.
/// (Moved to `rustc_attrs`.)
(removed, on_unimplemented, "1.40.0", None, None, None),

// -------------------------------------------------------------------------
// feature-group-end: removed features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// revisions: cfail1 cfail2
// build-pass (FIXME(62277): could be check-pass?)

#![feature(on_unimplemented)]
#![feature(rustc_attrs)]
#![deny(unused_attributes)]

#[rustc_on_unimplemented = "invalid"]
Expand Down
9 changes: 0 additions & 9 deletions src/test/ui/feature-gates/feature-gate-on-unimplemented.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/ui/on-unimplemented/bad-annotation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ignore-tidy-linelength

#![feature(on_unimplemented)]
#![feature(rustc_attrs)]

#![allow(unused)]

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/on-unimplemented/expected-comma-found-token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// access to the variable, whether that mutable access be used
// for direct assignment or for taking mutable ref. Issue #6801.

#![feature(on_unimplemented)]
#![feature(rustc_attrs)]

#[rustc_on_unimplemented(
message="the message"
Expand Down
8 changes: 8 additions & 0 deletions src/test/ui/on-unimplemented/feature-gate-on-unimplemented.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Test that `#[rustc_on_unimplemented]` is gated by `rustc_attrs` feature gate.

#[rustc_on_unimplemented = "test error `{Self}` with `{Bar}`"]
//~^ ERROR this is an internal attribute that will never be stable
trait Foo<Bar>
{}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error[E0658]: the `#[rustc_on_unimplemented]` attribute is an experimental feature
--> $DIR/feature-gate-on-unimplemented.rs:4:1
error[E0658]: this is an internal attribute that will never be stable
--> $DIR/feature-gate-on-unimplemented.rs:3:1
|
LL | #[rustc_on_unimplemented = "test error `{Self}` with `{Bar}`"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/29628
= help: add `#![feature(on_unimplemented)]` to the crate attributes to enable
= note: for more information, see https://github.com/rust-lang/rust/issues/29642
= help: add `#![feature(rustc_attrs)]` to the crate attributes to enable

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/on-unimplemented/multiple-impls.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Test if the on_unimplemented message override works

#![feature(on_unimplemented)]
#![feature(rustc_attrs)]


struct Foo<T>(T);
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/on-unimplemented/on-impl.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Test if the on_unimplemented message override works

#![feature(on_unimplemented)]
#![feature(rustc_attrs)]


#[rustc_on_unimplemented = "invalid"]
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/on-unimplemented/on-trait.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ignore-tidy-linelength

#![feature(on_unimplemented)]
#![feature(rustc_attrs)]

pub mod Bar {
#[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}` in `{Foo}`"]
Expand Down

0 comments on commit 09287e0

Please sign in to comment.