Skip to content

Conversation

@BD103
Copy link
Contributor

@BD103 BD103 commented Jan 14, 2026

Tracking issue: #146922

This PR adds support for inspecting pointers *const T and *mut T through type reflection. It does so by adding the new Pointer struct + variant:

pub struct Pointer {
    /// The type of the value being pointed to.
    pub ty: TypeId,
    /// Whether this pointer is mutable or not.
    pub mutable: bool,
}

This can be gathered using Type::of, for example:

match const { Type::of::<*const u8>() }.kind {
    TypeKind::Pointer(pointer) => {
        assert_eq!(pointer.ty, TypeId::of::<u8>());
        assert!(!pointer.mutable);
    }
    _ => unreachable!(),
}

@rustbot
Copy link
Collaborator

rustbot commented Jan 14, 2026

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

The reflection data structures are tied exactly to the implementation
in the compiler. Make sure to also adjust rustc_const_eval/src/const_eval/type_info.rs

cc @oli-obk

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 14, 2026
@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 14, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 14, 2026

r? @JonathanBrouwer

rustbot has assigned @JonathanBrouwer.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@BD103
Copy link
Contributor Author

BD103 commented Jan 14, 2026

r? @oli-obk

@rustbot rustbot assigned oli-obk and unassigned JonathanBrouwer Jan 14, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 14, 2026

oli-obk is not on the review rotation at the moment.
They may take a while to respond.

@SpriteOvO SpriteOvO added F-type_info #![feature(type_info)] A-type-system Area: Type system labels Jan 14, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 16, 2026

☔ The latest upstream changes (presumably #151210) made this pull request unmergeable. Please resolve the merge conflicts.

Zalathar added a commit to Zalathar/rust that referenced this pull request Jan 17, 2026
feat: Support references in reflection type info

Tracking issue: rust-lang#146922 `#![feature(type_info)]`

Based on rust-lang#151119 implementation for pointers for consistency

r? oli-obk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-type-system Area: Type system F-type_info #![feature(type_info)] S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants