rust/tests/ui/hygiene
Matthias Krüger ea6daca3cb
Rollup merge of #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 https://github.com/rust-lang/rust/issues/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:

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 https://github.com/rust-lang/rust/issues/66359#issuecomment-1718480774 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
2023-12-15 20:19:53 +01:00
..
auxiliary
arguments.rs
arguments.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
assoc_item_ctxt.rs
assoc_item_ctxt.stderr
assoc_ty_bindings.rs
cross-crate-codegen-attrs.rs
cross-crate-define-and-use.rs Stabilize type_name_of_val 2023-12-05 14:49:09 -05:00
cross-crate-fields.rs
cross-crate-glob-hygiene.rs
cross-crate-glob-hygiene.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
cross-crate-methods.rs
cross-crate-name-collision.rs
cross-crate-name-hiding-2.rs
cross-crate-name-hiding-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
cross-crate-name-hiding.rs
cross-crate-name-hiding.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
cross-crate-redefine.rs
cross-crate-redefine.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
cross-crate-variants.rs
dollar-crate-modern.rs
duplicate_lifetimes.rs
duplicate_lifetimes.stderr
eager-from-opaque-2.rs
eager-from-opaque.rs
expansion-info-reset.rs
expansion-info-reset.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
extern-prelude-from-opaque-fail-2018.rs
extern-prelude-from-opaque-fail-2018.stderr When encountering struct fn call literal with private fields, suggest all builders 2023-11-19 17:47:41 +00:00
extern-prelude-from-opaque-fail.rs
extern-prelude-from-opaque-fail.stderr
fields-definition.rs
fields-definition.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
fields-move.rs
fields-move.stderr
fields-numeric-borrowck.rs
fields-numeric-borrowck.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
fields.rs
fields.stderr
for-loop.rs
for-loop.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
format-args.rs
generate-mod.rs
generate-mod.stderr
generic_params.rs
globs.rs
globs.stderr
hir-res-hygiene.rs
hygiene-dodging-1.rs
hygiene.rs
hygienic-label-1.rs
hygienic-label-1.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
hygienic-label-2.rs
hygienic-label-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
hygienic-label-3.rs
hygienic-label-3.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
hygienic-label-4.rs
hygienic-label-4.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
hygienic-labels-in-let.rs
hygienic-labels.rs
impl_items-2.rs
impl_items-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
impl_items.rs
impl_items.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
intercrate.rs
intercrate.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-15221.rs
issue-32922.rs
issue-40847.rs
issue-44128.rs
issue-47311.rs
issue-47312.rs
issue-61574-const-parameters.rs
issue-77523-def-site-async-await.rs
items.rs
lambda-var-hygiene.rs
legacy_interaction.rs
lexical.rs
local_inner_macros.rs
macro-metavars-legacy.rs
macro-metavars-transparent.rs
missing-self-diag.rs
missing-self-diag.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
nested_macro_privacy.rs
nested_macro_privacy.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
nested-dollar-crate.rs
no_implicit_prelude-2018.rs
no_implicit_prelude-2018.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
no_implicit_prelude-2021.rs
no_implicit_prelude.rs
no_implicit_prelude.stderr
panic-location.rs
panic-location.run.stderr
pattern-macro.rs
pattern-macro.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
prelude-import-hygiene.rs
privacy-early.rs
privacy-early.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
privacy.rs
privacy.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
rustc-macro-transparency.rs
rustc-macro-transparency.stderr
specialization.rs
stdlib-prelude-from-opaque-early.rs
stdlib-prelude-from-opaque-late.rs
thread-local-not-in-prelude.rs
trait_items-2.rs
trait_items.rs
trait_items.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
traits-in-scope.rs
transparent-basic.rs
unpretty-debug.rs
unpretty-debug.stdout Improve print_tts by changing tokenstream::Spacing. 2023-12-11 09:19:09 +11:00
wrap_unhygienic_example.rs
xcrate.rs