Skip to content

Conversation

@BD103
Copy link
Contributor

@BD103 BD103 commented Jan 14, 2026

Tracking issue: #146922

This PR adds support for inspecting slices [T] through type reflection. It does so by adding the new Slice struct + variant, which is very similar to Array but without the len field:

pub struct Slice {
    pub element_ty: TypeId,
}

Here is an example reflecting a slice:

match const { Type::of::<[u8]>() }.kind {
    TypeKind::Slice(slice) => assert_eq!(slice.element_ty, TypeId::of::<u8>()),
    _ => unreachable!(),
}

In addition to this, I also re-arranged the type info unit tests.

r? @oli-obk

@rustbot
Copy link
Collaborator

rustbot commented Jan 14, 2026

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

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

@rustbot rustbot added 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. labels 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 A-type-system Area: Type system F-type_info #![feature(type_info)] labels Jan 14, 2026
@rust-bors

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Jan 18, 2026

Needs a rebase. Otherwise lgtm

@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.

4 participants