-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Stabilize type_name_of_val
#118234
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Stabilize type_name_of_val
#118234
Conversation
No rustbot, I said that already @rustbot label -T-libs -T-compiler |
cc implementer @lcnr |
Given that it's intended for diagnostics and the actual content isn't specified, I don't think is an issue at all. It can always be changed in the future. Big 👍 on stabilization, though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FCP proposal: #66359 (comment)
de3848f
to
5222274
Compare
Make the following API stable: // in core::any pub fn type_name_of_val<T: ?Sized>(_val: &T) -> &'static str Const stability is not added because this relies on `type_name` which is also not const. That has a blocking issue. Fixes rust-lang#66359
5222274
to
b225aab
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@bors r+ |
…lnay 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-api
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#117824 (Stabilize `ptr::{from_ref, from_mut}`) - rust-lang#118234 (Stabilize `type_name_of_val`) - rust-lang#118944 (Move type relations into submodule `relate` in rustc_infer, and notify when it has changed) - rust-lang#118977 (Simplify `src-script.js` code) - rust-lang#118985 (Remove `@JohnTitor` from diagnostics pings) - rust-lang#118986 (Simplify JS code a little bit) - rust-lang#118988 (rustdoc: add regression test for JS data file loading) r? `@ghost` `@rustbot` modify labels: rollup
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-api
Make the following API stable:
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 #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 #66359.
There were two main concerns in the tracking issue:
type_name_of
andtype_name_of_val
seem like the only mentioned options. Differences in opinion here come fromstd::mem::{size_of, align_of, size_of_val, align_of_val}
. This PR leaves the name astype_name_of_val
, but I can change if desired since it is pretty verbose.&dyn
: I don't think that havingtype_name_of_val
function resolve those is worth the headache it would be, see Tracking issue forany::type_name_of_val
#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-api