Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize const_type_id feature #72488

Merged
merged 4 commits into from
Jul 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/core/src/any.rs
Original file line number Diff line number Diff line change
@@ -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.46.0")]
pub const fn of<T: ?Sized + 'static>() -> TypeId {
TypeId { t: intrinsics::type_id::<T>() }
}
2 changes: 1 addition & 1 deletion library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
@@ -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.46.0")]
pub fn type_id<T: ?Sized + 'static>() -> u64;

/// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited:
1 change: 0 additions & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion src/test/ui/consts/const-typeid-of-rpass.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// run-pass
#![feature(core_intrinsics)]
#![feature(const_type_id)]

use std::any::TypeId;

8 changes: 0 additions & 8 deletions src/test/ui/consts/const-typeid-of.rs

This file was deleted.

10 changes: 0 additions & 10 deletions src/test/ui/consts/const-typeid-of.stderr

This file was deleted.

1 change: 0 additions & 1 deletion src/test/ui/consts/issue-73976-monomorphic.rs
Original file line number Diff line number Diff line change
@@ -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};
1 change: 0 additions & 1 deletion src/test/ui/consts/issue-73976-polymorphic.rs
Original file line number Diff line number Diff line change
@@ -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};
8 changes: 4 additions & 4 deletions src/test/ui/consts/issue-73976-polymorphic.stderr
Original file line number Diff line number Diff line change
@@ -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::<T>::VALUE, GetTypeId::<T>::VALUE)
| ^^^^^^^^^^^^^^^^^^^^^

error: could not evaluate constant pattern
--> $DIR/issue-73976-polymorphic.rs:32:42
--> $DIR/issue-73976-polymorphic.rs:31:42
|
LL | matches!(GetTypeNameLen::<T>::VALUE, GetTypeNameLen::<T>::VALUE)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: could not evaluate constant pattern
--> $DIR/issue-73976-polymorphic.rs:20:37
--> $DIR/issue-73976-polymorphic.rs:19:37
|
LL | matches!(GetTypeId::<T>::VALUE, GetTypeId::<T>::VALUE)
| ^^^^^^^^^^^^^^^^^^^^^

error: could not evaluate constant pattern
--> $DIR/issue-73976-polymorphic.rs:32:42
--> $DIR/issue-73976-polymorphic.rs:31:42
|
LL | matches!(GetTypeNameLen::<T>::VALUE, GetTypeNameLen::<T>::VALUE)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^