Repository navigation
Open
0 / 10 of 1 issue completedLabels
B-experimentalBlocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).Blocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-type_info#![feature(type_info)]#![feature(type_info)]T-langRelevant to the language teamRelevant to the language teamT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
This is a tracking issue for the project goal rust-lang/goals#406
The feature gate for the issue is #![feature(type_info)].
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.
Steps
- Implement the goal
- Discuss general reflection with the lang team
- Discuss Tracking issue for non_static_type_id #41875 and not requiring
'staticwith the lang team - Write an RFC
- Adjust documentation (see instructions on rustc-dev-guide)
- Style updates for any new syntax (nightly-style-procedure)
- Style team decision on new formatting
- Formatting for new syntax has been added to the Style Guide
- (non-blocking) Formatting has been implemented in
rustfmt
- Stabilization PR (see instructions on rustc-dev-guide)
Unresolved Questions
- Should we use fine grained (many) intrinsics for individual information or keep the one big intrinsic returning an enum of the information?
- what semver implications does all this have and what guarantees of semver do we retain?
- should we even do this at all? Reflection allows causing monomorphization time errors similar to
const { assert!(size_of::<T>(), 5) }, but for much more fine-grained details of a generic parameterT. - Is something lifetime-aware even possible at all?
- Should we use a non-const-eval based scheme (const generics based or even proc macro based?)
- Should free functions be used rather than methods on existing types? Tracking Issue for type_info #146922 (comment)
Implementation history
- Reflection MVP #146923
- Make
Type::ofsupport unsized types #151019 - Support arrays in type reflection #151031
- Support slices in type reflection #151118
- Support pointers in type reflection #151119
- Support primitives in type info reflection #151123
- feat: Support references in reflection type info #151222
- Support trait objects in type info reflection #151239
- Support ADT types in type info reflection #151142
- Reflection TypeId::trait_info_of #152003
- Reflection TypeKind::FnPtr #152173
- Do not require
'staticfor obtaining reflection information. #152381
Reacted by Cherry, Niclas Overby Ⓝ, Barrett Ray, Malek, Finn Bear, Yerkebulan Tulibergenov, Félix Fischer, 李冬冬, Hasan Mohsin, ZXY and 45 more
Reacted by Cherry, Niclas Overby Ⓝ, Barrett Ray, Malek, Finn Bear, Yerkebulan Tulibergenov, Félix Fischer, ZXY, Eyal Kalderon, Victor Nordam Suadicani and 10 more
Reacted by Alex
Reacted by Cherry, Niclas Overby Ⓝ, kamulos, Barrett Ray, Jeff Parsons, Malek, Meralis40, may, Frank King, Finn Bear and 31 more
Reacted by may, Finn Bear, Croxx, Elichai Turkel, Kirill Bezuglyi and Ltrlg
Metadata
Metadata
Assignees
Labels
B-experimentalBlocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).Blocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-type_info#![feature(type_info)]#![feature(type_info)]T-langRelevant to the language teamRelevant to the language teamT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Activity
Auto merge of #146923 - oli-obk:comptime-reflect, r=BoxyUwU
Auto merge of #146923 - oli-obk:comptime-reflect, r=BoxyUwU
Rollup merge of rust-lang#146923 - comptime-reflect, r=BoxyUwU
Rollup merge of rust-lang#146923 - comptime-reflect, r=BoxyUwU
Auto merge of #146923 - oli-obk:comptime-reflect, r=BoxyUwU
Auto merge of #146923 - oli-obk:comptime-reflect, r=BoxyUwU
Auto merge of #146923 - oli-obk:comptime-reflect, r=BoxyUwU
Auto merge of #146923 - oli-obk:comptime-reflect, r=BoxyUwU
Rollup merge of rust-lang#151019 - type-of-unsized, r=oli-obk
Rollup merge of rust-lang#151019 - type-of-unsized, r=oli-obk
75 remaining items
Unrolled build for #161401 in rollup 161505
Rollup merge of #161401 - yara-blue:remove-typekind-fields2, r=oli-obk
Rollup merge of rust-lang#161896 - yara-blue:reflection-refactor-arra…
Rollup merge of rust-lang#161896 - yara-blue:reflection-refactor-arra…
Rollup merge of rust-lang#161896 - yara-blue:reflection-refactor-arra…
Rollup merge of rust-lang#162294 - yara-blue:reflection-refactor-ptrs…
Rollup merge of rust-lang#162294 - yara-blue:reflection-refactor-ptrs…
Rollup merge of rust-lang#162294 - yara-blue:reflection-refactor-ptrs…
Unrolled build for #162294 in rollup 162434
Rollup merge of rust-lang#161896 - yara-blue:reflection-refactor-arra…
Unrolled build for #161896 in rollup 162445
Rollup merge of #162294 - yara-blue:reflection-refactor-ptrs, r=oli-obk
yara-blue commentedon Oct 27, 2026
unresolved question:
Should we turn the reflection methods into plain functions taking a
TypeIdas argument so we do not polluteTypeIdand we can have a nicer API in the (far) future?Context:
The entry point to reflection is methods on
TypeId. For various reasons, we're making the API fine grained and targeted. We'll end up with a wide and shallow API with many methods onTypeId. This is not nice to use directly, however we intend for end-users to use an ergonomic wrapper crate. We'll ensure there is at least one of those. We're doing this for the usual reasons (1).At some point, potentially many years in the future (2), the ecosystem may coalesce on a single nice ergonomic wrapper for all use cases. If we end up stabilizing a lot of reflection methods on
TypeIdany future API usingTypeIdas the entry point will have it's methods drowned out by the existing stable ones. Instead could keepTypeId"clean" at the cost of worse ergonomics now.(1): faster iteration, more accessible to ppl outside the compiler, less code in the compiler, avoid stabilizing a nice API that turns out to be bad later etc etc.
(2): we may even have reflection synthesize new code at some point. That could very well change what an ergonomic API looks like.
Tess4552 commentedon Oct 28, 2026
Before stabilizing, we should consider what the methods querying doc comments should return. Would we want to merge and transform different doc comments together and/or beautify them?
It could look as follows:
To me it seems to make sense to expose a slice of (non-transformed) str to keep the const time machine minimal
Rollup merge of rust-lang#165094 - Tess4552:reflection-type-id-docs, …