From cac16c9793ef78b16f1da948bb3cd55599591ffb Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Sat, 23 May 2020 15:17:19 +1000 Subject: [PATCH 1/4] stabilize const_type_id feature --- library/core/src/any.rs | 2 +- library/core/src/intrinsics.rs | 2 +- library/core/src/lib.rs | 1 - src/test/ui/consts/const-typeid-of-rpass.rs | 1 - src/test/ui/consts/const-typeid-of.rs | 8 -------- src/test/ui/consts/const-typeid-of.stderr | 10 ---------- 6 files changed, 2 insertions(+), 22 deletions(-) delete mode 100644 src/test/ui/consts/const-typeid-of.rs delete mode 100644 src/test/ui/consts/const-typeid-of.stderr diff --git a/library/core/src/any.rs b/library/core/src/any.rs index 79b6304958d51..f112d73cdca82 100644 --- a/library/core/src/any.rs +++ b/library/core/src/any.rs @@ -435,7 +435,7 @@ impl TypeId { /// assert_eq!(is_string(&"cookie monster".to_string()), true); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature = "const_type_id", issue = "41875")] + #[rustc_const_stable(feature = "const_type_id", since = "1.45.0")] pub const fn of() -> TypeId { TypeId { t: intrinsics::type_id::() } } diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 71780361d298e..b5dd92ecb1574 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -1024,7 +1024,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is /// [`std::any::TypeId::of`](../../std/any/struct.TypeId.html#method.of) - #[rustc_const_unstable(feature = "const_type_id", issue = "41875")] + #[rustc_const_stable(feature = "const_type_id", since = "1.45.0")] pub fn type_id() -> u64; /// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited: diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index e4b499a80229c..c2bd5d16088fd 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -145,7 +145,6 @@ #![feature(maybe_uninit_slice)] #![feature(external_doc)] #![feature(associated_type_bounds)] -#![feature(const_type_id)] #![feature(const_caller_location)] #![feature(slice_ptr_get)] #![feature(no_niche)] // rust-lang/rust#68303 diff --git a/src/test/ui/consts/const-typeid-of-rpass.rs b/src/test/ui/consts/const-typeid-of-rpass.rs index 225acb60ac44d..c49141050b20f 100644 --- a/src/test/ui/consts/const-typeid-of-rpass.rs +++ b/src/test/ui/consts/const-typeid-of-rpass.rs @@ -1,6 +1,5 @@ // run-pass #![feature(core_intrinsics)] -#![feature(const_type_id)] use std::any::TypeId; diff --git a/src/test/ui/consts/const-typeid-of.rs b/src/test/ui/consts/const-typeid-of.rs deleted file mode 100644 index 3829c481da837..0000000000000 --- a/src/test/ui/consts/const-typeid-of.rs +++ /dev/null @@ -1,8 +0,0 @@ -use std::any::TypeId; - -struct A; - -fn main() { - const A_ID: TypeId = TypeId::of::(); - //~^ ERROR `std::any::TypeId::of` is not yet stable as a const fn -} diff --git a/src/test/ui/consts/const-typeid-of.stderr b/src/test/ui/consts/const-typeid-of.stderr deleted file mode 100644 index 05347fbc81950..0000000000000 --- a/src/test/ui/consts/const-typeid-of.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: `std::any::TypeId::of` is not yet stable as a const fn - --> $DIR/const-typeid-of.rs:6:26 - | -LL | const A_ID: TypeId = TypeId::of::(); - | ^^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(const_type_id)]` to the crate attributes to enable - -error: aborting due to previous error - From e3856616ee2a894c7811a7017d98fafa7ba84dd8 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 30 Jun 2020 10:21:22 +1000 Subject: [PATCH 2/4] bump const type id stabilization to 1.46.0 --- library/core/src/any.rs | 2 +- library/core/src/intrinsics.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/any.rs b/library/core/src/any.rs index f112d73cdca82..b28471337c6be 100644 --- a/library/core/src/any.rs +++ b/library/core/src/any.rs @@ -435,7 +435,7 @@ impl TypeId { /// assert_eq!(is_string(&"cookie monster".to_string()), true); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_type_id", since = "1.45.0")] + #[rustc_const_stable(feature = "const_type_id", since = "1.46.0")] pub const fn of() -> TypeId { TypeId { t: intrinsics::type_id::() } } diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index b5dd92ecb1574..585e54342b773 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -1024,7 +1024,7 @@ extern "rust-intrinsic" { /// /// The stabilized version of this intrinsic is /// [`std::any::TypeId::of`](../../std/any/struct.TypeId.html#method.of) - #[rustc_const_stable(feature = "const_type_id", since = "1.45.0")] + #[rustc_const_stable(feature = "const_type_id", since = "1.46.0")] pub fn type_id() -> u64; /// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited: From a99d2cbfe7072218c67fbfe1fda2ea55f46c46f2 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 28 Jul 2020 13:33:08 +1000 Subject: [PATCH 3/4] remove unstable const_type_id feature --- src/test/ui/consts/issue-73976-monomorphic.rs | 1 - src/test/ui/consts/issue-73976-polymorphic.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/src/test/ui/consts/issue-73976-monomorphic.rs b/src/test/ui/consts/issue-73976-monomorphic.rs index 7706a97f23b48..1db0fdc87c37e 100644 --- a/src/test/ui/consts/issue-73976-monomorphic.rs +++ b/src/test/ui/consts/issue-73976-monomorphic.rs @@ -5,7 +5,6 @@ // will be properly rejected. This test will ensure that monomorphic use of these // would not be wrongly rejected in patterns. -#![feature(const_type_id)] #![feature(const_type_name)] use std::any::{self, TypeId}; diff --git a/src/test/ui/consts/issue-73976-polymorphic.rs b/src/test/ui/consts/issue-73976-polymorphic.rs index 28b84518719a1..7cf20296062ab 100644 --- a/src/test/ui/consts/issue-73976-polymorphic.rs +++ b/src/test/ui/consts/issue-73976-polymorphic.rs @@ -5,7 +5,6 @@ // This test case should either run-pass or be rejected at compile time. // Currently we just disallow this usage and require pattern is monomorphic. -#![feature(const_type_id)] #![feature(const_type_name)] use std::any::{self, TypeId}; From 9d4818c6f96cd9a553b4266ca81585d2e82887b2 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Tue, 28 Jul 2020 14:37:31 +1000 Subject: [PATCH 4/4] update stderr for polymorphic ui test --- src/test/ui/consts/issue-73976-polymorphic.stderr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/ui/consts/issue-73976-polymorphic.stderr b/src/test/ui/consts/issue-73976-polymorphic.stderr index c90ce2bd06a67..971573e14aad8 100644 --- a/src/test/ui/consts/issue-73976-polymorphic.stderr +++ b/src/test/ui/consts/issue-73976-polymorphic.stderr @@ -1,23 +1,23 @@ error: could not evaluate constant pattern - --> $DIR/issue-73976-polymorphic.rs:20:37 + --> $DIR/issue-73976-polymorphic.rs:19:37 | LL | matches!(GetTypeId::::VALUE, GetTypeId::::VALUE) | ^^^^^^^^^^^^^^^^^^^^^ error: could not evaluate constant pattern - --> $DIR/issue-73976-polymorphic.rs:32:42 + --> $DIR/issue-73976-polymorphic.rs:31:42 | LL | matches!(GetTypeNameLen::::VALUE, GetTypeNameLen::::VALUE) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: could not evaluate constant pattern - --> $DIR/issue-73976-polymorphic.rs:20:37 + --> $DIR/issue-73976-polymorphic.rs:19:37 | LL | matches!(GetTypeId::::VALUE, GetTypeId::::VALUE) | ^^^^^^^^^^^^^^^^^^^^^ error: could not evaluate constant pattern - --> $DIR/issue-73976-polymorphic.rs:32:42 + --> $DIR/issue-73976-polymorphic.rs:31:42 | LL | matches!(GetTypeNameLen::::VALUE, GetTypeNameLen::::VALUE) | ^^^^^^^^^^^^^^^^^^^^^^^^^^