Repository navigation
Reflection add TypeId::name - #164981
Reflection add TypeId::name#164981yara-blue wants to merge 3 commits into
Conversation
|
The reflection data structures are tied exactly to the implementation cc @oli-obk Some changes occurred to the CTFE machinery Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter |
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
r? @oli-obk |
This comment has been minimized.
This comment has been minimized.
534f5b2 to
4a89ddb
Compare
| } | ||
|
|
||
| pub fn type_name<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> String { | ||
| fn inner<'tcx>(ty: Ty<'tcx>, s: &mut String, tcx: TyCtxt<'tcx>) -> std::fmt::Result { |
There was a problem hiding this comment.
we can use try blocks in rustc ;)
at least I assume this is the reason for this inner function
There was a problem hiding this comment.
yay, I keep forgetting about all the nice goodies :3
d71fffe to
b4b9603
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
b4b9603 to
b2d3242
Compare
… r=oli-obk Reflection add TypeId::name This gets the "name" of an ADT or Trait without any generics unlike [`type_name`](https://doc.rust-lang.org/stable/std/any/fn.type_name.html). While this could have been made an argument to the existing Printer it is far simpler _and shorter_ to just duplicate a little code :3
…uwer Rollup of 22 pull requests Successful merges: - #165032 (stdarch subtree update) - #165072 (Submodule update of rustc-perf) - #144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - #162342 (More stdarch regression tests) - #163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - #164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - #164916 (CI: rfl: move job forward to Linux v7.3) - #164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - #164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - #165083 (Gate `z` inline asm template modifier) - #165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - #161131 (Check associated const binding types) - #161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - #164315 (make powerpc `Complex` ABI GCC-compatible) - #164476 (Avoid ICE on None from prepare_vtable_segments) - #164981 (Reflection add TypeId::name) - #165003 (follow up for global-alloc-reentry test) - #165020 (Bless mir-opt panic-abort tests) - #165066 (skip max_repr_align in Layout::eq_abi) - #165080 (Syntactically allow C-variadics in parenthesized argument lists) - #165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - #165082 (Remove stability note from `rust_splat`)
…uwer Rollup of 22 pull requests Successful merges: - #165032 (stdarch subtree update) - #165072 (Submodule update of rustc-perf) - #144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - #162342 (More stdarch regression tests) - #163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - #164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - #164916 (CI: rfl: move job forward to Linux v7.3) - #164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - #164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - #165083 (Gate `z` inline asm template modifier) - #165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - #161131 (Check associated const binding types) - #161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - #164315 (make powerpc `Complex` ABI GCC-compatible) - #164476 (Avoid ICE on None from prepare_vtable_segments) - #164981 (Reflection add TypeId::name) - #165003 (follow up for global-alloc-reentry test) - #165020 (Bless mir-opt panic-abort tests) - #165066 (skip max_repr_align in Layout::eq_abi) - #165080 (Syntactically allow C-variadics in parenthesized argument lists) - #165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - #165082 (Remove stability note from `rust_splat`)
…uwer Rollup of 22 pull requests Successful merges: - #165032 (stdarch subtree update) - #165072 (Submodule update of rustc-perf) - #144090 (Make `IoSlice` and `IoSliceMut` methods unstably const) - #162342 (More stdarch regression tests) - #163909 (std: Test the exit behavior of `abort` and `abort_immediate`) - #164766 (Unstably introduce MVP edition migration lint `unmarked_unchecked_type_aliases` together with bikeshed attribute `#[rustc_unchecked_type_alias]`) - #164916 (CI: rfl: move job forward to Linux v7.3) - #164924 (Remove `TypeKind` from `rustc_codegen_ssa`) - #164969 (perf: avoid allocating HashSet in is_distinct check on small SwitchInts) - #165083 (Gate `z` inline asm template modifier) - #165087 (Fix flaky CI test `named_temp_file_new_creates_file`) - #161131 (Check associated const binding types) - #161418 (give next-solver's `evaluate_const` its own `try_evaluate_const` logic) - #164315 (make powerpc `Complex` ABI GCC-compatible) - #164476 (Avoid ICE on None from prepare_vtable_segments) - #164981 (Reflection add TypeId::name) - #165003 (follow up for global-alloc-reentry test) - #165020 (Bless mir-opt panic-abort tests) - #165066 (skip max_repr_align in Layout::eq_abi) - #165080 (Syntactically allow C-variadics in parenthesized argument lists) - #165081 (move `#[rustc_allow_const_fn_unstable]` attr check to attr parsing stage) - #165082 (Remove stability note from `rust_splat`)
… r=oli-obk Reflection add TypeId::name This gets the "name" of an ADT or Trait without any generics unlike [`type_name`](https://doc.rust-lang.org/stable/std/any/fn.type_name.html). While this could have been made an argument to the existing Printer it is far simpler _and shorter_ to just duplicate a little code :3
…uwer Rollup of 21 pull requests Successful merges: - #164851 (Add behavior tests for `Arc` and `Rc`) - #164989 (rustdoc: Fix performance regression for private documented items) - #165079 (Remove GenericArgRef) - #161781 (Don't emit InlineAsm terminator if input operand is `!`.) - #162754 (optimize large elements for slice rotating) - #163252 (Remove windows-targets dependency from the root workspace) - #163839 (Fix the floating point clobbers of RISC-V `clobber_abi`) - #165104 (Use getrandom instead of /scheme/rand on Redox OS) - #165132 (Implement `advance_back_by` on `Fuse`) - #165142 (Remove the unused generic Graphviz writer) - #163371 (Don't suggest replacing foreign format specifiers in `concat!` output) - #163802 (fix RegionEq direction in canonical query responses) - #163986 (omit unconditionally invoking crate level limits query) - #164920 (Point at prior token on `let` when expression is expected) - #164987 (use adt_async_drop_tys for nested ADTs in needs_async_drop) - #165061 (Use a fixed-length encoding for hash disambiguators in v0 symbols) - #165114 (use native interpreter impl for funnel shifts intrinsics) - #165119 (remove unnecessary fast path from borrowck) - #165122 (fix MaybeDangling validity logic for ZST at usize::MAX) - #165128 (Move `doc(keyword)` and `doc(attribute)` attributes checks from `rustc_passes` to `rustc_attr_parsing`) - #165129 (Fix ICE in prelude edition lint) Failed merges: - #164981 (Reflection add TypeId::name)
…uwer Rollup of 22 pull requests Successful merges: - #164851 (Add behavior tests for `Arc` and `Rc`) - #164989 (rustdoc: Fix performance regression for private documented items) - #165079 (Remove GenericArgRef) - #161781 (Don't emit InlineAsm terminator if input operand is `!`.) - #162754 (optimize large elements for slice rotating) - #163252 (Remove windows-targets dependency from the root workspace) - #163839 (Fix the floating point clobbers of RISC-V `clobber_abi`) - #165104 (Use getrandom instead of /scheme/rand on Redox OS) - #165132 (Implement `advance_back_by` on `Fuse`) - #165142 (Remove the unused generic Graphviz writer) - #165148 (ci: increase free disk space on macos-26 jobs) - #163371 (Don't suggest replacing foreign format specifiers in `concat!` output) - #163802 (fix RegionEq direction in canonical query responses) - #163986 (omit unconditionally invoking crate level limits query) - #164920 (Point at prior token on `let` when expression is expected) - #164987 (use adt_async_drop_tys for nested ADTs in needs_async_drop) - #165061 (Use a fixed-length encoding for hash disambiguators in v0 symbols) - #165114 (use native interpreter impl for funnel shifts intrinsics) - #165119 (remove unnecessary fast path from borrowck) - #165122 (fix MaybeDangling validity logic for ZST at usize::MAX) - #165128 (Move `doc(keyword)` and `doc(attribute)` attributes checks from `rustc_passes` to `rustc_attr_parsing`) - #165129 (Fix ICE in prelude edition lint) Failed merges: - #164981 (Reflection add TypeId::name) > [!WARNING] > This rollup conflicts with pending auto build #165205 and may need to be recreated if the pending build succeeds.
… r=oli-obk Reflection add TypeId::name This gets the "name" of an ADT or Trait without any generics unlike [`type_name`](https://doc.rust-lang.org/stable/std/any/fn.type_name.html). While this could have been made an argument to the existing Printer it is far simpler _and shorter_ to just duplicate a little code :3
…uwer Rollup of 22 pull requests Successful merges: - #164851 (Add behavior tests for `Arc` and `Rc`) - #164989 (rustdoc: Fix performance regression for private documented items) - #165079 (Remove GenericArgRef) - #161781 (Don't emit InlineAsm terminator if input operand is `!`.) - #162754 (optimize large elements for slice rotating) - #163252 (Remove windows-targets dependency from the root workspace) - #163839 (Fix the floating point clobbers of RISC-V `clobber_abi`) - #165104 (Use getrandom instead of /scheme/rand on Redox OS) - #165132 (Implement `advance_back_by` on `Fuse`) - #165142 (Remove the unused generic Graphviz writer) - #165148 (ci: increase free disk space on macos-26 jobs) - #163371 (Don't suggest replacing foreign format specifiers in `concat!` output) - #163802 (fix RegionEq direction in canonical query responses) - #163986 (omit unconditionally invoking crate level limits query) - #164920 (Point at prior token on `let` when expression is expected) - #164987 (use adt_async_drop_tys for nested ADTs in needs_async_drop) - #165061 (Use a fixed-length encoding for hash disambiguators in v0 symbols) - #165114 (use native interpreter impl for funnel shifts intrinsics) - #165119 (remove unnecessary fast path from borrowck) - #165122 (fix MaybeDangling validity logic for ZST at usize::MAX) - #165128 (Move `doc(keyword)` and `doc(attribute)` attributes checks from `rustc_passes` to `rustc_attr_parsing`) - #165129 (Fix ICE in prelude edition lint) Failed merges: - #164981 (Reflection add TypeId::name) > [!WARNING] > This rollup conflicts with pending auto build #165205 and may need to be recreated if the pending build succeeds.
…uwer Rollup of 22 pull requests Successful merges: - #164851 (Add behavior tests for `Arc` and `Rc`) - #164989 (rustdoc: Fix performance regression for private documented items) - #165079 (Remove GenericArgRef) - #161781 (Don't emit InlineAsm terminator if input operand is `!`.) - #162754 (optimize large elements for slice rotating) - #163252 (Remove windows-targets dependency from the root workspace) - #163839 (Fix the floating point clobbers of RISC-V `clobber_abi`) - #165104 (Use getrandom instead of /scheme/rand on Redox OS) - #165132 (Implement `advance_back_by` on `Fuse`) - #165142 (Remove the unused generic Graphviz writer) - #165148 (ci: increase free disk space on macos-26 jobs) - #163371 (Don't suggest replacing foreign format specifiers in `concat!` output) - #163802 (fix RegionEq direction in canonical query responses) - #163986 (omit unconditionally invoking crate level limits query) - #164920 (Point at prior token on `let` when expression is expected) - #164987 (use adt_async_drop_tys for nested ADTs in needs_async_drop) - #165061 (Use a fixed-length encoding for hash disambiguators in v0 symbols) - #165114 (use native interpreter impl for funnel shifts intrinsics) - #165119 (remove unnecessary fast path from borrowck) - #165122 (fix MaybeDangling validity logic for ZST at usize::MAX) - #165128 (Move `doc(keyword)` and `doc(attribute)` attributes checks from `rustc_passes` to `rustc_attr_parsing`) - #165129 (Fix ICE in prelude edition lint) Failed merges: - #164981 (Reflection add TypeId::name) > [!WARNING] > This rollup conflicts with pending auto build #165205 and may need to be recreated if the pending build succeeds.
Rollup of 19 pull requests Successful merges: - #160370 (rustdoc: notable trait badge and popover enhancements) - #163410 (Use a macro to reduce duplication in `core/src/num/f{16,32,64,128}.rs` (part 1)) - #164290 (virtual function elimination: only use `type.checked.load` for function pointers) - #165113 (Limit lldb string summary length) - #165146 (Stop using LLVM struct types for array/pointer offset GEPs (rebase)) - #165197 (Inline usages of `is_doc_keyword_or_attribute` and `is_rustc_doc_primitive`) - #165209 (Don't ICE when making diagnostic in `point_at_dyn_trait_in_field_def` if there's no `dyn Trait` field to point at) - #153633 (feat: improve `Cell` doc) - #164686 (Add regression test for new solver hang on cyclic projection bound) - #164937 (Add example for misaligned elements in `subslice_range`) - #164981 (Reflection add TypeId::name) - #165035 (Suggest `gca!` for path const args that use generic params) - #165106 (Windows: Disallow some special chars in bat script names) - #165120 (Add regression test for overlap check hang with unresolved type in where clause) - #165158 (Tiny optimization to `TypeErrCtxt::report_inference_failure()`) - #165184 (GCI: Check where-clauses of associated constants for well-formedness) - #165190 (Improve delayed bug comment and message on first_method_vtable_slot) - #165196 (inhabitedness: use try_normalize_erasing_regions on ADT fields) - #165206 (tests: clarify dead_code_pub_in_binary FIXME after Cargo workaround)
This comment has been minimized.
This comment has been minimized.
…uwer Rollup of 23 pull requests Successful merges: - #163410 (Use a macro to reduce duplication in `core/src/num/f{16,32,64,128}.rs` (part 1)) - #164290 (virtual function elimination: only use `type.checked.load` for function pointers) - #165113 (Limit lldb string summary length) - #165146 (Stop using LLVM struct types for array/pointer offset GEPs (rebase)) - #165197 (Inline usages of `is_doc_keyword_or_attribute` and `is_rustc_doc_primitive`) - #165209 (Don't ICE when making diagnostic in `point_at_dyn_trait_in_field_def` if there's no `dyn Trait` field to point at) - #165228 (Fix error output for invalid `SBValue` children) - #153633 (feat: improve `Cell` doc) - #164686 (Add regression test for new solver hang on cyclic projection bound) - #164730 (core: Rename `abort_immediate` to `crash`) - #164937 (Add example for misaligned elements in `subslice_range`) - #165019 (Add safety section for from_utf8_unchecked/from_raw_parts) - #165035 (Suggest `gca!` for path const args that use generic params) - #165106 (Windows: Disallow some special chars in bat script names) - #165120 (Add regression test for overlap check hang with unresolved type in where clause) - #165158 (Tiny optimization to `TypeErrCtxt::report_inference_failure()`) - #165184 (GCI: Check where-clauses of associated constants for well-formedness) - #165190 (Improve delayed bug comment and message on first_method_vtable_slot) - #165196 (inhabitedness: use try_normalize_erasing_regions on ADT fields) - #165206 (tests: clarify dead_code_pub_in_binary FIXME after Cargo workaround) - #165214 (add MaybeUninit::from_ref) - #165225 (LoongArch: Restore `feature(stdarch_loongarch)` for bootstrap) - #165235 (two LLVM backend cleanups) Failed merges: - #160370 (rustdoc: notable trait badge and popover enhancements) - #164981 (Reflection add TypeId::name)
|
Any news on that? |
…uwer Rollup of 23 pull requests Successful merges: - rust-lang/rust#163410 (Use a macro to reduce duplication in `core/src/num/f{16,32,64,128}.rs` (part 1)) - rust-lang/rust#164290 (virtual function elimination: only use `type.checked.load` for function pointers) - rust-lang/rust#165113 (Limit lldb string summary length) - rust-lang/rust#165146 (Stop using LLVM struct types for array/pointer offset GEPs (rebase)) - rust-lang/rust#165197 (Inline usages of `is_doc_keyword_or_attribute` and `is_rustc_doc_primitive`) - rust-lang/rust#165209 (Don't ICE when making diagnostic in `point_at_dyn_trait_in_field_def` if there's no `dyn Trait` field to point at) - rust-lang/rust#165228 (Fix error output for invalid `SBValue` children) - rust-lang/rust#153633 (feat: improve `Cell` doc) - rust-lang/rust#164686 (Add regression test for new solver hang on cyclic projection bound) - rust-lang/rust#164730 (core: Rename `abort_immediate` to `crash`) - rust-lang/rust#164937 (Add example for misaligned elements in `subslice_range`) - rust-lang/rust#165019 (Add safety section for from_utf8_unchecked/from_raw_parts) - rust-lang/rust#165035 (Suggest `gca!` for path const args that use generic params) - rust-lang/rust#165106 (Windows: Disallow some special chars in bat script names) - rust-lang/rust#165120 (Add regression test for overlap check hang with unresolved type in where clause) - rust-lang/rust#165158 (Tiny optimization to `TypeErrCtxt::report_inference_failure()`) - rust-lang/rust#165184 (GCI: Check where-clauses of associated constants for well-formedness) - rust-lang/rust#165190 (Improve delayed bug comment and message on first_method_vtable_slot) - rust-lang/rust#165196 (inhabitedness: use try_normalize_erasing_regions on ADT fields) - rust-lang/rust#165206 (tests: clarify dead_code_pub_in_binary FIXME after Cargo workaround) - rust-lang/rust#165214 (add MaybeUninit::from_ref) - rust-lang/rust#165225 (LoongArch: Restore `feature(stdarch_loongarch)` for bootstrap) - rust-lang/rust#165235 (two LLVM backend cleanups) Failed merges: - rust-lang/rust#160370 (rustdoc: notable trait badge and popover enhancements) - rust-lang/rust#164981 (Reflection add TypeId::name)
|
im a little short on time (fell and now my hand is stuck in a cast which slows everything down). The time I had went towards design work which took priority. That should not take more then a few days, so expect this (and get-variant) in before this weeks end! |
7a7157d to
aad012c
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
aad012c to
84d1523
Compare
This comment has been minimized.
This comment has been minimized.
84d1523 to
f383efb
Compare
View all comments
This gets the "name" of an ADT or Trait without any generics unlike
type_name.While this could have been made an argument to the existing Printer it is far simpler and shorter to just duplicate a little code :3