about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-02-21 19:01:12 +0100
committerGitHub <noreply@github.com>2025-02-21 19:01:12 +0100
commit28164f1229e02856070e61644c0f44ea39658fba (patch)
tree3c651ecbd2ecddf0ce83ab75f1042e3a9801caac /compiler/rustc_codegen_llvm/src
parent439561892e7e71398489876510b92556bf30f8c0 (diff)
parentd2ed8cf6619764e2a0af8a691c4ccb8c034b1e57 (diff)
downloadrust-28164f1229e02856070e61644c0f44ea39658fba.tar.gz
rust-28164f1229e02856070e61644c0f44ea39658fba.zip
Rollup merge of #136148 - kpreid:type-str, r=joboet
Optionally add type names to `TypeId`s.

This feature is intended to provide expensive but thorough help for developers who have an unexpected `TypeId` value and need to determine what type it actually is. It causes `impl Debug for TypeId` to print the type name in addition to the opaque ID hash, and in order to do so, adds a name field to `TypeId`. The cost of this is the increased size of `TypeId` and the need to store type names in the binary; therefore, it is an optional feature. It does not expose any new public API, only change the `Debug` implementation.

It may be enabled via `cargo -Zbuild-std -Zbuild-std-features=debug_typeid`. (Note that `-Zbuild-std-features` disables default features which you may wish to reenable in addition; see
<https://doc.rust-lang.org/cargo/reference/unstable.html#build-std-features>.)

Example usage and output:

```
fn main() {
    use std::any::{Any, TypeId};
    dbg!(TypeId::of::<usize>(), drop::<usize>.type_id());
}
```

```
TypeId::of::<usize>() = TypeId(0x763d199bccd319899208909ed1a860c6 = usize)
drop::<usize>.type_id() = TypeId(0xe6a34bd13f8c92dd47806da07b8cca9a = core::mem::drop<usize>)
```

Also added feature declarations for the existing `debug_refcell` feature so it is usable from the `rust.std-features` option of `config.toml`.

Related issues:

* #68379
* #61533
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions