This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit 52cc7c0
authored
Unrolled build for rust-lang#118234
Rollup merge of rust-lang#118234 - tgross35:type_name_of_value, r=dtolnay
Stabilize `type_name_of_val`
Make the following API stable:
```rust
// in core::any
pub fn type_name_of_val<T: ?Sized>(_val: &T) -> &'static str
```
This is a convenience method to get the type name of a value, as opposed to `type_name` that takes a type as a generic.
Const stability is not added because this relies on `type_name` which is also not const. That has a blocking issue rust-lang#97156.
Wording was also changed to direct most of the details to `type_name` so we don't have as much duplicated documentation.
Fixes tracking issue rust-lang#66359.
There were two main concerns in the tracking issue:
1. Naming: `type_name_of` and `type_name_of_val` seem like the only mentioned options. Differences in opinion here come from `std::mem::{size_of, align_of, size_of_val, align_of_val}`. This PR leaves the name as `type_name_of_val`, but I can change if desired since it is pretty verbose.
2. What this displays for `&dyn`: I don't think that having `type_name_of_val` function resolve those is worth the headache it would be, see rust-lang#66359 (comment) for some workarounds. I also amended the docs wording to leave it open-ended, in case we have means to change that behavior in the future.
``@rustbot`` label -T-libs +T-libs-api +needs-fcp
r? libs-apiFile tree
2 files changed
+18
-22
lines changed- library/core/src
- tests/ui/hygiene
2 files changed
+18
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
695 | 695 | | |
696 | 696 | | |
697 | 697 | | |
698 | | - | |
| 698 | + | |
| 699 | + | |
699 | 700 | | |
700 | 701 | | |
701 | 702 | | |
702 | 703 | | |
703 | 704 | | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
714 | 708 | | |
715 | | - | |
716 | | - | |
| 709 | + | |
| 710 | + | |
717 | 711 | | |
718 | | - | |
719 | | - | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
720 | 715 | | |
721 | 716 | | |
722 | 717 | | |
723 | 718 | | |
724 | 719 | | |
725 | 720 | | |
726 | | - | |
727 | 721 | | |
728 | 722 | | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
733 | 730 | | |
734 | 731 | | |
735 | | - | |
| 732 | + | |
736 | 733 | | |
737 | 734 | | |
738 | 735 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
0 commit comments