Skip to content

Conversation

@coolcatcoder
Copy link

@coolcatcoder coolcatcoder commented Jan 17, 2026

This is for #146922.

It allows checking if a TypeId implements a trait.

(I've never used git from the terminal before, so that was a fun challenge. I hope I did everything correctly.)
(I haven't added any tests yet, I'll do that soon.)
(Zulip.)

@rustbot
Copy link
Collaborator

rustbot commented Jan 17, 2026

Some changes occurred to the intrinsics. Make sure the CTFE / Miri interpreter
gets adapted for the changes, if necessary.

cc @rust-lang/miri, @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

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 17, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 17, 2026

r? @chenyukang

rustbot has assigned @chenyukang.
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

@coolcatcoder
Copy link
Author

Also, because this pull request is pretty much just copying and pasting from vtable_for's implementation, should we de-duplicate the code by putting the implementation in one location that both intrinsics can call?

@rust-log-analyzer

This comment has been minimized.

@xonx4l
Copy link
Contributor

xonx4l commented Jan 17, 2026

Also, because this pull request is pretty much just copying and pasting from vtable_for's implementation, should we de-duplicate the code by putting the implementation in one location that both intrinsics can call?

Sure , This way it's easier to maintain.

@rustbot
Copy link
Collaborator

rustbot commented Jan 17, 2026

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

@SpriteOvO SpriteOvO added the F-type_info #![feature(type_info)] label Jan 17, 2026
@rustbot

This comment was marked as outdated.

@rustbot rustbot added O-unix Operating system: Unix-like T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Jan 17, 2026
@rustbot

This comment has been minimized.

@rustbot rustbot added has-merge-commits PR has merge commits, merge with caution. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 17, 2026
@coolcatcoder

This comment was marked as off-topic.

@coolcatcoder

This comment was marked as off-topic.

@coolcatcoder

This comment was marked as off-topic.

@coolcatcoder

This comment was marked as off-topic.

@SpriteOvO

This comment was marked as off-topic.

@coolcatcoder

This comment was marked as off-topic.

@SpriteOvO SpriteOvO force-pushed the type_id_implements_trait branch from f603826 to 2f97f63 Compare January 17, 2026 11:13
@rustbot rustbot removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. has-merge-commits PR has merge commits, merge with caution. labels Jan 17, 2026
@rustbot rustbot assigned oli-obk and unassigned chenyukang Jan 27, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 27, 2026

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

@coolcatcoder coolcatcoder force-pushed the type_id_implements_trait branch from b40e9b3 to 820765b Compare January 27, 2026 04:28
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@SpriteOvO
Copy link
Member

Since #151239 has been merged, this PR is no longer blocked.

@rustbot label -S-blocked

@rustbot rustbot removed the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Jan 28, 2026
@coolcatcoder coolcatcoder force-pushed the type_id_implements_trait branch from 820765b to f2ee714 Compare January 28, 2026 22:41
@rustbot rustbot added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Jan 28, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 28, 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.

@rustbot
Copy link
Collaborator

rustbot commented Jan 28, 2026

⚠️ Warning ⚠️

@rust-log-analyzer

This comment has been minimized.

@coolcatcoder
Copy link
Author

I think I managed to fix my latest failed rebase.
(Rebasing is really difficult... but I'm slowly but surely learning how to do it properly.)

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test [ui] tests/ui/asm/aarch64/ttbr0_el2.rs ... ok
test [ui] tests/ui/asm/aarch64/may_unwind.rs ... ok
test [ui] tests/ui/asm/aarch64/type-check-2.rs ... ok
test [ui] tests/ui/asm/aarch64/type-check-3.rs ... ok
test [ui] tests/ui/asm/aarch64v8r.rs#sf ... ok
test [ui] tests/ui/asm/aarch64v8r.rs#hf ... ok
test [ui] tests/ui/asm/aarch64/type-f16.rs ... ok
test [ui] tests/ui/asm/arm-low-dreg.rs ... ok
test [ui] tests/ui/asm/asm-with-nested-closure.rs ... ok
test [ui] tests/ui/asm/binary_asm_labels.rs ... ignored, only executed when the architecture is x86_64
test [ui] tests/ui/asm/bad-template.rs#aarch64 ... ok
---
test [ui] tests/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs#fat2 ... ok
test [ui] tests/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs#fat3 ... ok
test [ui] tests/ui/extern/issue-80074.rs ... ok
test [ui] tests/ui/extern/issue-95829.rs ... ok
test [ui] tests/ui/extern/lgamma-linkage.rs ... ok
test [ui] tests/ui/extern/no-mangle-associated-fn.rs ... ok
test [ui] tests/ui/extern/not-in-block.rs ... ok
test [ui] tests/ui/extern/unsized-extern-derefmove.rs ... ok
test [ui] tests/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs#thin1 ... ok
test [ui] tests/ui/extern/windows-tcb-trash-13259.rs ... ok
---
test [ui] tests/ui/imports/ambiguous-6.rs ... ok
test [ui] tests/ui/imports/ambiguous-4.rs ... ok
test [ui] tests/ui/imports/ambiguous-7.rs ... ok
test [ui] tests/ui/imports/ambiguous-9.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-glob-vs-multiouter.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-globvsglob.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-no-implicit-prelude.rs ... ok
test [ui] tests/ui/imports/ambiguous-8.rs ... ok
test [ui] tests/ui/imports/ambiguous-glob-vs-expanded-extern.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-non-prelude-core-glob.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-non-prelude-std-glob.rs ... ok
---

failures:

---- [ui] tests/ui/reflection/dump.rs#bit64 stdout ----
Saved the actual run.stdout to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/reflection/dump.bit64/dump.bit64.run.stdout`
diff of run.stdout:

20     size: Some(
21         2,
22     ),
+     id: TypeId(0x5a16e6fbf8293c4c38740f6ab3f64621),
23 }
24 Type {
25     kind: Array(

31     size: Some(
32         2,
33     ),
+     id: TypeId(0xe09e770f1c1da76825e6290f984ddaf7),
34 }
35 Type {
36     kind: Int(

42     size: Some(
43         1,
44     ),
+     id: TypeId(0x12427c993eca190c841e0d92c5b7a45d),
45 }
46 Type {
47     kind: Int(

53     size: Some(
54         4,
55     ),
+     id: TypeId(0x56ced5e4a15bd89050bb9674fa2df013),
56 }
57 Type {
58     kind: Int(

64     size: Some(
65         8,
66     ),
+     id: TypeId(0xae6c4318bb07632e00428affbea41961),
67 }
68 Type {
69     kind: Int(

75     size: Some(
76         16,
77     ),
+     id: TypeId(0xc7164498f3902dde0d8194a7b9733e79),
78 }
79 Type {
80     kind: Int(

86     size: Some(
87         8,
88     ),
+     id: TypeId(0x1e5f92831c560aac8658b980a22e60b0),
89 }
90 Type {
91     kind: Int(

97     size: Some(
98         1,
99     ),
+     id: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb),
100 }
101 Type {
102     kind: Int(

108     size: Some(
109         4,
110     ),
+     id: TypeId(0x1378bb1c0a0202683eb65e7c11f2e4d7),
111 }
112 Type {
113     kind: Int(

119     size: Some(
120         8,
121     ),
+     id: TypeId(0x9ed91be891e304132cb86891e578f4a5),
122 }
123 Type {
124     kind: Int(

130     size: Some(
131         16,
132     ),
+     id: TypeId(0x7bf7411d57d603e9fb393892a9c3f362),
133 }
134 Type {
135     kind: Int(

141     size: Some(
142         8,
143     ),
+     id: TypeId(0x763d199bccd319899208909ed1a860c6),
144 }
145 Type {
146     kind: Other,

147     size: Some(
148         4,
149     ),
+     id: TypeId(0x78c34ce87517aee8f0d54cc3ea348028),
150 }
151 Type {
152     kind: Other,

153     size: Some(
154         24,
155     ),
+     id: TypeId(0x8ed28b76f102b777afcc7a07749d45fe),
156 }
157 Type {
158     kind: Reference(

164     size: Some(
165         16,
166     ),
+     id: TypeId(0x4d13f2e9be6854d4529cc187d26d3e83),
167 }
168 Type {
169     kind: Reference(

175     size: Some(
176         16,
177     ),
+     id: TypeId(0xb98b1b7157a6417863eb502cd6cb5d6d),
178 }
179 Type {
180     kind: Reference(

186     size: Some(
187         16,
188     ),
+     id: TypeId(0x03f6aa200663725e076283e0711c66aa),
189 }
190 Type {
191     kind: Str(

192         Str,
193     ),
194     size: None,
+     id: TypeId(0x474ccf3b5db264ef53916706f7d7bb2c),
195 }
196 Type {
197     kind: Slice(

200         },
201     ),
202     size: None,
+     id: TypeId(0x641e3def269c37acc6dcb92bf8c5f196),
203 }
204 Type {
205     kind: Reference(

211     size: Some(
212         8,
213     ),
+     id: TypeId(0x8a8d25435c9aa1ed611bd54eddb095c4),
214 }
215 Type {
216     kind: Reference(

222     size: Some(
223         8,
224     ),
+     id: TypeId(0x57bb24072c78596db60e68f83b5de67b),
225 }
226 


The actual run.stdout differed from the expected run.stdout

error in revision `bit64`: 1 errors occurred comparing run output.
status: exit status: 0
command: cd "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/reflection/dump.bit64" && RUSTC="/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" RUST_TEST_THREADS="4" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/reflection/dump.bit64/a"
--- stdout -------------------------------
Type {
    kind: Tuple(
        Tuple {
            fields: [
                Field {
                    ty: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb),
                    offset: 0,
                },
                Field {
                    ty: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb),
                    offset: 1,
                },
                Field {
                    ty: TypeId(0x41223169ff28813ba79b7268a2a968d9),
                    offset: 2,
                },
            ],
        },
    ),
    size: Some(
        2,
    ),
    id: TypeId(0x5a16e6fbf8293c4c38740f6ab3f64621),
}
Type {
    kind: Array(
        Array {
            element_ty: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb),
            len: 2,
        },
    ),
    size: Some(
        2,
    ),
    id: TypeId(0xe09e770f1c1da76825e6290f984ddaf7),
}
Type {
    kind: Int(
        Int {
            bits: 8,
            signed: true,
        },
    ),
    size: Some(
        1,
    ),
    id: TypeId(0x12427c993eca190c841e0d92c5b7a45d),
}
Type {
    kind: Int(
        Int {
            bits: 32,
            signed: true,
        },
    ),
    size: Some(
        4,
    ),
    id: TypeId(0x56ced5e4a15bd89050bb9674fa2df013),
}
Type {
    kind: Int(
        Int {
            bits: 64,
            signed: true,
        },
    ),
    size: Some(
        8,
    ),
    id: TypeId(0xae6c4318bb07632e00428affbea41961),
}
Type {
    kind: Int(
        Int {
            bits: 128,
            signed: true,
        },
    ),
    size: Some(
        16,
    ),
    id: TypeId(0xc7164498f3902dde0d8194a7b9733e79),
}
Type {
    kind: Int(
        Int {
            bits: 64,
            signed: true,
        },
    ),
    size: Some(
        8,
    ),
    id: TypeId(0x1e5f92831c560aac8658b980a22e60b0),
}
Type {
    kind: Int(
        Int {
            bits: 8,
            signed: false,
        },
    ),
    size: Some(
        1,
    ),
    id: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb),
}
Type {
    kind: Int(
        Int {
            bits: 32,
            signed: false,
        },
    ),
    size: Some(
        4,
    ),
    id: TypeId(0x1378bb1c0a0202683eb65e7c11f2e4d7),
}
Type {
    kind: Int(
        Int {
            bits: 64,
            signed: false,
        },
    ),
    size: Some(
        8,
    ),
    id: TypeId(0x9ed91be891e304132cb86891e578f4a5),
}
Type {
    kind: Int(
        Int {
            bits: 128,
            signed: false,
        },
    ),
    size: Some(
        16,
    ),
    id: TypeId(0x7bf7411d57d603e9fb393892a9c3f362),
}
Type {
    kind: Int(
        Int {
            bits: 64,
            signed: false,
        },
    ),
    size: Some(
        8,
    ),
    id: TypeId(0x763d199bccd319899208909ed1a860c6),
}
Type {
    kind: Other,
    size: Some(
        4,
    ),
    id: TypeId(0x78c34ce87517aee8f0d54cc3ea348028),
}
Type {
    kind: Other,
    size: Some(
        24,
    ),
    id: TypeId(0x8ed28b76f102b777afcc7a07749d45fe),
}
Type {
    kind: Reference(
        Reference {
            pointee: TypeId(0xda1b6da9bd297bb2900de9303aadea79),
            mutable: false,
        },
    ),
    size: Some(
        16,
    ),
    id: TypeId(0x4d13f2e9be6854d4529cc187d26d3e83),
}
Type {
    kind: Reference(
        Reference {
            pointee: TypeId(0x474ccf3b5db264ef53916706f7d7bb2c),
            mutable: false,
        },
    ),
    size: Some(
        16,
    ),
    id: TypeId(0xb98b1b7157a6417863eb502cd6cb5d6d),
}
Type {
    kind: Reference(
        Reference {
            pointee: TypeId(0x641e3def269c37acc6dcb92bf8c5f196),
            mutable: false,
        },
    ),
    size: Some(
        16,
    ),
    id: TypeId(0x03f6aa200663725e076283e0711c66aa),
}
Type {
    kind: Str(
        Str,
    ),
    size: None,
    id: TypeId(0x474ccf3b5db264ef53916706f7d7bb2c),
}
Type {
    kind: Slice(
        Slice {
            element_ty: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb),
        },
    ),
    size: None,
    id: TypeId(0x641e3def269c37acc6dcb92bf8c5f196),
}
Type {
    kind: Reference(
        Reference {
            pointee: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb),
            mutable: false,
        },
    ),
    size: Some(
        8,
    ),
    id: TypeId(0x8a8d25435c9aa1ed611bd54eddb095c4),
}
Type {
    kind: Reference(
        Reference {
            pointee: TypeId(0x0596b48cc04376e64d5c788c2aa46bdb),
            mutable: true,
        },
    ),
    size: Some(
        8,
    ),
    id: TypeId(0x57bb24072c78596db60e68f83b5de67b),
}
------------------------------------------
stderr: none

---- [ui] tests/ui/reflection/dump.rs#bit64 stdout end ----

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

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. 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.

8 participants