Reflection refactor ptrs - #162294
Conversation
|
Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter cc @rust-lang/miri, @RalfJung, @oli-obk, @lcnr The reflection data structures are tied exactly to the implementation cc @oli-obk Some changes occurred to the CTFE machinery Some changes occurred in compiler/rustc_attr_ir |
|
|
| FromFn, sym::from, from_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None; | ||
|
|
||
| // Experimental lang item for `Reflection and comptime`(https://goals.rust-lang.org/2025h2/reflection-and-comptime.html) | ||
| FnPtr, sym::FnPtr, fn_ptr, Target::Struct, GenericRequirement::None; |
There was a problem hiding this comment.
Note: I think adding a lang item is required to return a struct from a generic, please correct me if I'm wrong here.
| let variant_index = if let ty::FnPtr(sig, fn_header) = ty.kind() { | ||
| let (variant, variant_place) = ecx.project_downcast_named(dest, sym::Some)?; | ||
| let field_place = ecx.project_field(&variant_place, FieldIdx::ZERO)?; | ||
| let sig = sig.skip_binder(); // FIXME: handle lifetime bounds |
There was a problem hiding this comment.
the FIXME was pre-existing, itis copied from the CTFE code that wrote the FnPtr field in TypeKind::FnPtr(FnPtr). Not resolving that as part of this refactor.
52f2e49 to
b9b9421
Compare
There was a problem hiding this comment.
I originally did a straightforward port of these tests but decided to "uncouple" (testing only one "thing" per test) them also. Happy rewrite as a straightforward port.
This comment has been minimized.
This comment has been minimized.
b9b9421 to
06fa642
Compare
Tracking issue #146922
Part of the Refactoring to many methods reflection subgoal. See that for the full context. In short for various reasons we are moving from an enum
TypeKindwhere the variants hold the types information to one that just tells you the type kind. Separate methods onTypeIdprovide a way to get to the data that used to be in the variant.Since function pointers have a lot of fields it felt better to keep the
FnPtrstruct we have now then add an intrinsic for each field.r? @oli-obk