Skip to content

Commit

Permalink
Auto merge of rust-lang#77083 - KodrAus:revert/const-type-id, r=RalfJung
Browse files Browse the repository at this point in the history
revert const_type_id stabilization

This reverts rust-lang#72488, which is currently on beta and scheduled to stabilize in `1.47.0`, based on rust-lang#75923 (comment)

It turns out we might not be quite ready to stabilize `TypeId` in const contexts before having a chance to rework its internals. Since `TypeId` is a bit of an oddity we want to be careful about how those internals are currently being relied on while making changes. That will be easier to do without having to also consider compile-time contexts.

r? `@eddyb`
  • Loading branch information
bors committed Sep 24, 2020
2 parents c351775 + 0e2db57 commit 7b240a1
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion library/core/src/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.46.0")]
#[rustc_const_unstable(feature = "const_type_id", issue = "77125")]
pub const fn of<T: ?Sized + 'static>() -> TypeId {
TypeId { t: intrinsics::type_id::<T>() }
}
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ extern "rust-intrinsic" {
/// crate it is invoked in.
///
/// The stabilized version of this intrinsic is [`crate::any::TypeId::of`].
#[rustc_const_stable(feature = "const_type_id", since = "1.46.0")]
#[rustc_const_unstable(feature = "const_type_id", issue = "77125")]
pub fn type_id<T: ?Sized + 'static>() -> u64;

/// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited:
Expand Down
1 change: 1 addition & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
#![feature(const_slice_ptr_len)]
#![feature(const_size_of_val)]
#![feature(const_align_of_val)]
#![feature(const_type_id)]
#![feature(const_type_name)]
#![feature(const_likely)]
#![feature(const_unreachable_unchecked)]
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/consts/const-typeid-of-rpass.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// run-pass
#![feature(const_type_id)]
#![feature(core_intrinsics)]

use std::any::TypeId;
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/consts/issue-73976-monomorphic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// 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};
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/consts/issue-73976-polymorphic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// 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};
Expand Down
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: constant pattern depends on a generic parameter
--> $DIR/issue-73976-polymorphic.rs:19:37
--> $DIR/issue-73976-polymorphic.rs:20:37
|
LL | matches!(GetTypeId::<T>::VALUE, GetTypeId::<T>::VALUE)
| ^^^^^^^^^^^^^^^^^^^^^

error: constant pattern depends on a generic parameter
--> $DIR/issue-73976-polymorphic.rs:31:42
--> $DIR/issue-73976-polymorphic.rs:32:42
|
LL | matches!(GetTypeNameLen::<T>::VALUE, GetTypeNameLen::<T>::VALUE)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: constant pattern depends on a generic parameter
--> $DIR/issue-73976-polymorphic.rs:19:37
--> $DIR/issue-73976-polymorphic.rs:20:37
|
LL | matches!(GetTypeId::<T>::VALUE, GetTypeId::<T>::VALUE)
| ^^^^^^^^^^^^^^^^^^^^^

error: constant pattern depends on a generic parameter
--> $DIR/issue-73976-polymorphic.rs:31:42
--> $DIR/issue-73976-polymorphic.rs:32:42
|
LL | matches!(GetTypeNameLen::<T>::VALUE, GetTypeNameLen::<T>::VALUE)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down

0 comments on commit 7b240a1

Please sign in to comment.