Skip to content

Commit d94f60f

Browse files
committed
Stabilize const TypeId::of and type_name
1 parent 6c0a912 commit d94f60f

21 files changed

+19
-34
lines changed

compiler/rustc_mir_transform/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// tidy-alphabetical-start
2+
#![cfg_attr(bootstrap, feature(const_type_name))]
23
#![feature(array_windows)]
34
#![feature(assert_matches)]
45
#![feature(box_patterns)]
5-
#![feature(const_type_name)]
66
#![feature(cow_is_borrowed)]
77
#![feature(file_buffered)]
88
#![feature(if_let_guard)]

library/core/src/any.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ unsafe impl Send for TypeId {}
725725
unsafe impl Sync for TypeId {}
726726

727727
#[stable(feature = "rust1", since = "1.0.0")]
728-
#[rustc_const_unstable(feature = "const_type_id", issue = "77125")]
728+
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
729729
impl const PartialEq for TypeId {
730730
#[inline]
731731
fn eq(&self, other: &Self) -> bool {
@@ -773,7 +773,7 @@ impl TypeId {
773773
/// ```
774774
#[must_use]
775775
#[stable(feature = "rust1", since = "1.0.0")]
776-
#[rustc_const_unstable(feature = "const_type_id", issue = "77125")]
776+
#[rustc_const_stable(feature = "const_type_id", since = "CURRENT_RUSTC_VERSION")]
777777
pub const fn of<T: ?Sized + 'static>() -> TypeId {
778778
const { intrinsics::type_id::<T>() }
779779
}
@@ -852,7 +852,7 @@ impl fmt::Debug for TypeId {
852852
/// ```
853853
#[must_use]
854854
#[stable(feature = "type_name", since = "1.38.0")]
855-
#[rustc_const_unstable(feature = "const_type_name", issue = "63084")]
855+
#[rustc_const_stable(feature = "const_type_name", since = "CURRENT_RUSTC_VERSION")]
856856
pub const fn type_name<T: ?Sized>() -> &'static str {
857857
const { intrinsics::type_name::<T>() }
858858
}
@@ -892,7 +892,7 @@ pub const fn type_name<T: ?Sized>() -> &'static str {
892892
/// ```
893893
#[must_use]
894894
#[stable(feature = "type_name_of_val", since = "1.76.0")]
895-
#[rustc_const_unstable(feature = "const_type_name", issue = "63084")]
895+
#[rustc_const_stable(feature = "const_type_name", since = "CURRENT_RUSTC_VERSION")]
896896
pub const fn type_name_of_val<T: ?Sized>(_val: &T) -> &'static str {
897897
type_name::<T>()
898898
}

tests/mir-opt/gvn_const_eval_polymorphic.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
//! evaluated to the string "crate_name::generic::<T>", and
1111
//! `no_optimize` was incorrectly optimized to `false`.
1212
13-
#![feature(const_type_name)]
14-
1513
fn generic<T>() {}
1614

1715
const fn type_name_contains_i32<T>(_: &T) -> bool {

tests/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: generic parameters may not be used in const operations
2-
--> $DIR/intrinsics-type_name-as-const-argument.rs:14:45
2+
--> $DIR/intrinsics-type_name-as-const-argument.rs:13:45
33
|
44
LL | T: Trait<{ std::intrinsics::type_name::<T>() }>,
55
| ^ cannot perform const operation using `T`
@@ -8,7 +8,7 @@ LL | T: Trait<{ std::intrinsics::type_name::<T>() }>,
88
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
99

1010
error: `&'static str` is forbidden as the type of a const generic parameter
11-
--> $DIR/intrinsics-type_name-as-const-argument.rs:9:22
11+
--> $DIR/intrinsics-type_name-as-const-argument.rs:8:22
1212
|
1313
LL | trait Trait<const S: &'static str> {}
1414
| ^^^^^^^^^^^^

tests/ui/const-generics/intrinsics-type_name-as-const-argument.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#![cfg_attr(full, allow(incomplete_features))]
55
#![cfg_attr(full, feature(adt_const_params, unsized_const_params, generic_const_exprs))]
66
#![feature(core_intrinsics)]
7-
#![feature(const_type_name)]
87

98
trait Trait<const S: &'static str> {}
109
//[min]~^ ERROR `&'static str` is forbidden as the type of a const generic parameter

tests/ui/const-generics/issues/issue-90318.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(const_type_id)]
21
#![feature(generic_const_exprs)]
32
#![feature(const_trait_impl, const_cmp)]
43
#![feature(core_intrinsics)]

tests/ui/const-generics/issues/issue-90318.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: overly complex generic constant
2-
--> $DIR/issue-90318.rs:15:8
2+
--> $DIR/issue-90318.rs:14:8
33
|
44
LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
55
| ^^-----------------^^^^^^^^^^^^^^^^^^^^^^^^
@@ -10,7 +10,7 @@ LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
1010
= note: this operation may be supported in the future
1111

1212
error: overly complex generic constant
13-
--> $DIR/issue-90318.rs:22:8
13+
--> $DIR/issue-90318.rs:21:8
1414
|
1515
LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
1616
| ^^-----------------^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/consts/const-fn-type-name-any.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//@ run-pass
22

3-
#![feature(const_type_name)]
43
#![allow(dead_code)]
54

65
const fn type_name_wrapper<T>(_: &T) -> &'static str {

tests/ui/consts/const-fn-type-name.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@ run-pass
22

33
#![feature(core_intrinsics)]
4-
#![feature(const_type_name)]
54
#![allow(dead_code)]
65

76
const fn type_name_wrapper<T>(_: &T) -> &'static str {

tests/ui/consts/const-typeid-of-rpass.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
//@ run-pass
2-
#![feature(const_type_id)]
3-
#![feature(core_intrinsics)]
42

53
use std::any::TypeId;
64

0 commit comments

Comments
 (0)