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

This comment has been minimized.

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
rust-timer added a commit that referenced this pull request Jan 17, 2026
Rollup merge of #151222 - reflect-references, r=oli-obk

feat: Support references in reflection type info

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

Based on #151119 implementation for pointers for consistency

r? oli-obk
@oli-obk
Copy link
Contributor

oli-obk commented Jan 18, 2026

Needs a rebase

@SpriteOvO SpriteOvO added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 18, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 19, 2026

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.

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-author Status: This is awaiting some action (such as code changes or more information) from the author. 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