Reflection TypeId::trait_info_of rust-lang/rust#152003

Merged

50 comments and reviews loaded in 2.21s

9SonSteroids Avatar
9SonSteroids on 2026-02-02 16:31:33 UTC · edited
9SonSteroids Avatar
9SonSteroids on 2026-02-02 16:31:33 UTC · edited
View on GitHub

View all comments

This is for #146922.

As #151236 was requested to be remade by someone I implemented the functionality as TypeId::trait_info_of which additionally allows getting the vtable pointer to build dyn Objects in recursive reflection.

It allows checking if a TypeId implements a trait. Since this is my first PR feel free to tell me if there are any formal issues.

🎉3
🚀2
👀1
rustbot Avatar
rustbot on 2026-02-02 16:32:43 UTC
rustbot Avatar
rustbot on 2026-02-02 16:32:43 UTC
View on GitHub

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

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

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 Avatar
rustbot on 2026-02-02 16:32:47 UTC
rustbot Avatar
rustbot on 2026-02-02 16:32:47 UTC
View on GitHub

r? @joboet

rustbot has assigned @joboet.
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 Avatar
coolcatcoder on 2026-02-02 23:36:40 UTC
coolcatcoder Avatar
coolcatcoder on 2026-02-02 23:36:40 UTC
View on GitHub

Lovely, great job!

❤️1
programmerjake Avatar
programmerjake commented on 2026-02-03 02:13:46 UTC
library/core/src/any.rs · outdated
814 ) -> Option<TraitImpl<T>> {
815 if let Some(vtable) = crate::intrinsics::type_id_vtable(self, const { TypeId::of::<T>() }) {
816 // SAFETY: Vtable was aquired for T, therefore it is DynMetadata<T>, the intrinsic doesn't know it because it
817 // designed to work even with 2 TypeIds.
programmerjake Avatar programmerjake on 2026-02-03 02:13:46 UTC
View on GitHub

because it designed to work even with 2 TypeIds

that's missing is after it, also it's confusingly worded.

programmerjake Avatar
programmerjake commented on 2026-02-03 02:16:11 UTC
library/coretests/tests/mem/type_info.rs · outdated
307 }
308
309 const {
310 assert!(TypeId::of::<Garlic>().trait_info_of::<dyn Blah>().is_some());
programmerjake Avatar programmerjake on 2026-02-03 02:16:11 UTC
View on GitHub

there should probably be some tests of what happens when you pass something that's not a dyn Trait to trait_info_of, e.g. TypeId::of::<i32>().trait_info_of::<u32>()

9SonSteroids Avatar 9SonSteroids on 2026-02-03 10:07:18 UTC · edited
View on GitHub

u32 is not a valid generic parameter because T is bounded with T: ptr::Pointee<Metadata = ptr::DynMetadata<T>> + ?Sized + 'static. However I added a test for const { TypeId::of::<i32>().trait_info_of_trait_type_id(TypeId::of::<u32>()) } which correctly returns None.

👍2
SpriteOvO Avatar
SpriteOvO commented on 2026-02-03 03:13:52 UTC
compiler/rustc_const_eval/src/interpret/mod.rs · outdated
16 16 mod step;
17 17 mod traits;
18 mod util;
18 pub(crate) mod util;
SpriteOvO Avatar SpriteOvO on 2026-02-03 02:23:08 UTC
View on GitHub

Looks like this visibility change is not necessary.

9SonSteroids Avatar 9SonSteroids on 2026-02-03 10:11:35 UTC
View on GitHub

We use crate::interpret::util::type_implements_dyn_trait in rustc_const_eval/src/const_eval/machine.rs

oli-obk Avatar oli-obk on 2026-02-09 16:38:39 UTC
View on GitHub

Keep the module private and reexport what you need publicly below

library/core/src/intrinsics/mod.rs · outdated
2861 _id: crate::any::TypeId,
2862 _trait: crate::any::TypeId,
2863 ) -> Option<ptr::DynMetadata<*const ()>> {
2864 panic!("`TypeId::implements_trait` can only be called at compile-time")
SpriteOvO Avatar SpriteOvO on 2026-02-03 03:06:09 UTC
View on GitHub
Suggested change
panic!("`TypeId::implements_trait` can only be called at compile-time")
panic!("`TypeId::trait_info_of` can only be called at compile-time")
theemathas Avatar
theemathas on 2026-02-03 03:19:18 UTC
theemathas Avatar
theemathas on 2026-02-03 03:19:18 UTC
View on GitHub

The documentation of DynMetadata says:

It is possible to name this struct with a type parameter that is not a dyn trait object (for example DynMetadata<u64>) but not to obtain a meaningful value of that struct.

The trait_info_of_trait_type_id produces a TraitImpl<*const ()>, which can be used to produce a DynMetadata<*const ()>, violating this documentation. Is this a problem?

👍1
rust-log-analyzer Avatar
rust-log-analyzer on 2026-02-03 03:20:31 UTC · hidden as outdated
rust-log-analyzer Avatar
rust-log-analyzer on 2026-02-03 03:20:31 UTC · hidden as outdated
View on GitHub

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
checking C++ file formatting
spellchecking files
building external tool typos from package typos-cli@1.38.1
finished building tool typos
error: `aquired` should be `acquired`
    ╭▸ library/core/src/any.rs:816:35
    │
816 │             // SAFETY: Vtable was aquired for T, therefore it is DynMetadata<T>, the intrinsic doesn't know it because it
    ╰╴                                  ━━━━━━━
error: `retreive` should be `retrieve`
   ╭▸ library/core/src/mem/type_info.rs:21:45
   │
21 │ /// Info of a trait implementation, you can retreive the vtable with [Self::get_vtable]
   ╰╴                                            ━━━━━━━━
rerun tidy with `--extra-checks=spellcheck --bless` to fix typos
tidy [extra_checks]: checks with external tool 'typos' failed
tidy [extra_checks]: FAIL
tidy: The following check failed: extra_checks
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy --root-path=/checkout --cargo-path=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo --output-dir=/checkout/obj/build --concurrency=4 --npm-path=/node/bin/yarn --extra-checks=py,cpp,js,spellcheck` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1612:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1364:29

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:02:34
  local time: Tue Feb  3 03:20:19 UTC 2026
  network time: Tue, 03 Feb 2026 03:20:19 GMT
##[error]Process completed with exit code 1.
##[group]Run echo "disk usage:"
theemathas Avatar
theemathas on 2026-02-03 03:25:32 UTC
theemathas Avatar
theemathas on 2026-02-03 03:25:32 UTC
View on GitHub

Trying to create a vtable for a DST results in an ICE with this PR.

#![feature(type_info)]

use std::any::TypeId;

trait Trait {}
impl Trait for [i32] {}

fn main() {
    const { TypeId::of::<[i32]>().trait_info_of_trait_type_id(TypeId::of::<dyn Trait>()) };
}
Error output
thread 'rustc' (77522) panicked at compiler/rustc_middle/src/ty/vtable.rs:105:5:
can't create a vtable for an unsized type
stack backtrace:
   0: __rustc::rust_begin_unwind
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/panicking.rs:689:5
   1: core::panicking::panic_fmt
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/panicking.rs:80:14
   2: vtable_allocation_provider
             at /Users/timch/rust/compiler/rustc_middle/src/ty/vtable.rs:105:5
   3: {closure#0}
             at /Users/timch/rust/compiler/rustc_query_impl/src/plumbing.rs:294:9
      [... omitted 36 frames ...]
   4: query_get_at<rustc_query_system::query::caches::DefaultCache<(rustc_middle::ty::Ty, core::option::Option<rustc_type_ir::predicate::ExistentialTraitRef<rustc_middle::ty::context::TyCtxt>>), rustc_middle::query::erase::ErasedData<[u8; 8]>>>
             at /Users/timch/rust/compiler/rustc_middle/src/query/inner.rs:31:17
   5: vtable_allocation
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:426:42
   6: vtable_allocation
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:415:35
   7: collect_alloc
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:1291:32
   8: collect_const_value
   9: collect_items_of_instance
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:1356:13
  10: items_of_instance
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:1379:41
  11: {closure#0}
             at /Users/timch/rust/compiler/rustc_query_impl/src/plumbing.rs:294:9
      [... omitted 36 frames ...]
  12: query_get_at<rustc_query_system::query::caches::DefaultCache<(rustc_middle::ty::instance::Instance, rustc_middle::mir::mono::CollectionMode), rustc_middle::query::erase::ErasedData<[u8; 32]>>>
             at /Users/timch/rust/compiler/rustc_middle/src/query/inner.rs:31:17
  13: items_of_instance
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:426:42
  14: items_of_instance
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:415:35
  15: {closure#0}
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:481:49
  16: maybe_grow<(), rustc_monomorphize::collector::collect_items_rec::{closure_env#0}>
             at /Users/timch/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/stacker-0.1.21/src/lib.rs:57:9
  17: ensure_sufficient_stack<(), rustc_monomorphize::collector::collect_items_rec::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/stack.rs:21:5
  18: collect_items_rec
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:480:13
  19: collect_items_root
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:371:5
  20: {closure#0}
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:1824:13
  21: {closure#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:181:30
  22: call_once<(), rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/panic/unwind_safe.rs:274:9
  23: do_call<core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>, ()>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/panicking.rs:581:40
  24: catch_unwind<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/panicking.rs:544:19
  25: catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>, ()>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/panic.rs:359:14
  26: run<(), rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:23:9
  27: {closure#1}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:181:23
  28: {closure#0}<rustc_middle::mir::mono::MonoItem, rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure_env#1}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/iter/traits/iterator.rs:829:29
  29: fold<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global, (), core::iter::traits::iterator::Iterator::for_each::call::{closure_env#0}<rustc_middle::mir::mono::MonoItem, rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure_env#1}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/alloc/src/vec/into_iter.rs:329:25
  30: for_each<alloc::vec::into_iter::IntoIter<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure_env#1}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/iter/traits/iterator.rs:832:14
  31: {closure#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:180:27
  32: parallel_guard<(), rustc_data_structures::sync::parallel::par_for_each_in::{closure_env#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:39:15
  33: par_for_each_in<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:175:5
  34: {closure#1}
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:1823:9
  35: run<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure_env#1}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/profiling.rs:844:9
  36: time<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure_env#1}>
             at /Users/timch/rust/compiler/rustc_session/src/utils.rs:17:50
  37: collect_crate_mono_items
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:1822:14
  38: collect_and_partition_mono_items
             at /Users/timch/rust/compiler/rustc_monomorphize/src/partitioning.rs:1138:30
  39: {closure#0}
             at /Users/timch/rust/compiler/rustc_query_impl/src/plumbing.rs:294:9
      [... omitted 33 frames ...]
  40: query_get_at<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 24]>>>
             at /Users/timch/rust/compiler/rustc_middle/src/query/inner.rs:31:17
  41: collect_and_partition_mono_items
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:426:42
  42: collect_and_partition_mono_items
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:415:35
  43: codegen_crate<rustc_codegen_llvm::LlvmCodegenBackend>
             at /Users/timch/rust/compiler/rustc_codegen_ssa/src/base.rs:695:56
  44: codegen_crate
             at /Users/timch/rust/compiler/rustc_codegen_llvm/src/lib.rs:354:18
  45: {closure#0}
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1264:29
  46: run<alloc::boxed::Box<dyn core::any::Any, alloc::alloc::Global>, rustc_interface::passes::start_codegen::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/profiling.rs:844:9
  47: time<alloc::boxed::Box<dyn core::any::Any, alloc::alloc::Global>, rustc_interface::passes::start_codegen::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_session/src/utils.rs:17:50
  48: start_codegen
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1252:28
  49: codegen_and_build_linker
             at /Users/timch/rust/compiler/rustc_interface/src/queries.rs:33:43
  50: {closure#2}
             at /Users/timch/rust/compiler/rustc_driver_impl/src/lib.rs:391:18
  51: {closure#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1018:27
  52: {closure#1}<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context.rs:1643:37
  53: {closure#0}<rustc_middle::ty::context::{impl#20}::enter::{closure_env#1}<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context/tls.rs:60:9
  54: try_with<core::cell::Cell<*const ()>, rustc_middle::ty::context::tls::enter_context::{closure_env#0}<rustc_middle::ty::context::{impl#20}::enter::{closure_env#1}<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/thread/local.rs:513:12
  55: with<core::cell::Cell<*const ()>, rustc_middle::ty::context::tls::enter_context::{closure_env#0}<rustc_middle::ty::context::{impl#20}::enter::{closure_env#1}<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/thread/local.rs:477:20
  56: enter_context<rustc_middle::ty::context::{impl#20}::enter::{closure_env#1}<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context/tls.rs:57:9
  57: enter<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context.rs:1643:9
  58: create_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context.rs:1850:13
  59: {closure#2}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:985:9
  60: call_once<rustc_interface::passes::create_and_enter_global_ctxt::{closure_env#2}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, (&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy, alloc::alloc::Global>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2})>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/ops/function.rs:250:5
  61: call_once<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy, alloc::alloc::Global>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}), dyn core::ops::function::FnOnce<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy, alloc::alloc::Global>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}), Output=core::option::Option<rustc_interface::queries::Linker>>, alloc::alloc::Global>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/alloc/src/boxed.rs:2206:9
  62: create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1026:5
  63: {closure#0}
             at /Users/timch/rust/compiler/rustc_driver_impl/src/lib.rs:348:22
  64: {closure#0}<(), rustc_driver_impl::run_compiler::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_interface/src/interface.rs:532:80
  65: call_once<(), rustc_interface::interface::run_compiler::{closure#1}::{closure_env#0}<(), rustc_driver_impl::run_compiler::{closure_env#0}>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/panic/unwind_safe.rs:274:9
  66: do_call<core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler::{closure#1}::{closure_env#0}<(), rustc_driver_impl::run_compiler::{closure_env#0}>>, ()>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/panicking.rs:581:40
  67: catch_unwind<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler::{closure#1}::{closure_env#0}<(), rustc_driver_impl::run_compiler::{closure_env#0}>>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/panicking.rs:544:19
  68: catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler::{closure#1}::{closure_env#0}<(), rustc_driver_impl::run_compiler::{closure_env#0}>>, ()>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/panic.rs:359:14
  69: {closure#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_interface/src/interface.rs:532:23
  70: {closure#0}<rustc_interface::interface::run_compiler::{closure_env#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>, ()>
             at /Users/timch/rust/compiler/rustc_interface/src/util.rs:204:17
  71: {closure#0}<rustc_interface::util::run_in_thread_pool_with_globals::{closure_env#0}<rustc_interface::interface::run_compiler::{closure_env#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>, ()>, ()>
             at /Users/timch/rust/compiler/rustc_interface/src/util.rs:158:24
  72: set<rustc_span::SessionGlobals, rustc_interface::util::run_in_thread_with_globals::{closure#0}::{closure#0}::{closure_env#0}<rustc_interface::util::run_in_thread_pool_with_globals::{closure_env#0}<rustc_interface::interface::run_compiler::{closure_env#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>, ()>, ()>, ()>
             at /Users/timch/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/scoped-tls-1.0.1/src/lib.rs:137:9
  73: create_session_globals_then<(), rustc_interface::util::run_in_thread_with_globals::{closure#0}::{closure#0}::{closure_env#0}<rustc_interface::util::run_in_thread_pool_with_globals::{closure_env#0}<rustc_interface::interface::run_compiler::{closure_env#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>, ()>, ()>>
             at /Users/timch/rust/compiler/rustc_span/src/lib.rs:142:21
  74: {closure#0}<rustc_interface::util::run_in_thread_pool_with_globals::{closure_env#0}<rustc_interface::interface::run_compiler::{closure_env#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>, ()>, ()>
             at /Users/timch/rust/compiler/rustc_interface/src/util.rs:154:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/Users/timch/foo/rustc-ice-2026-02-03T03_23_29-9322.txt` to your bug report

note: rustc 1.95.0-dev running on aarch64-apple-darwin

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [vtable_allocation] vtable const allocation for <[i32] as Trait>
#1 [items_of_instance] collecting items used by `main`
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: could not compile `foo` (bin "foo")
theemathas Avatar
theemathas on 2026-02-03 03:38:54 UTC
theemathas Avatar
theemathas on 2026-02-03 03:38:54 UTC
View on GitHub

Failure to compute the layout of the type also results in an ICE with this PR.

#![feature(type_info)]

use std::any::TypeId;

trait Trait {}
impl Trait for [u8; 1 << 63] {}

pub fn main() {
    const { TypeId::of::<[u8; 1 << 63]>().trait_info_of_trait_type_id(TypeId::of::<dyn Trait>()) };
}
Error output
thread 'rustc' (91122) panicked at compiler/rustc_middle/src/ty/vtable.rs:104:10:
failed to build vtable representation: SizeOverflow([u8; 9223372036854775808_usize])
stack backtrace:
   0: __rustc::rust_begin_unwind
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/panicking.rs:689:5
   1: core::panicking::panic_fmt
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/panicking.rs:80:14
   2: core::result::unwrap_failed
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/result.rs:1867:5
   3: expect<rustc_abi::layout::ty::TyAndLayout<rustc_middle::ty::Ty>, &rustc_middle::ty::layout::LayoutError>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/result.rs:1185:23
   4: vtable_allocation_provider
             at /Users/timch/rust/compiler/rustc_middle/src/ty/vtable.rs:104:10
   5: {closure#0}
             at /Users/timch/rust/compiler/rustc_query_impl/src/plumbing.rs:294:9
      [... omitted 36 frames ...]
   6: query_get_at<rustc_query_system::query::caches::DefaultCache<(rustc_middle::ty::Ty, core::option::Option<rustc_type_ir::predicate::ExistentialTraitRef<rustc_middle::ty::context::TyCtxt>>), rustc_middle::query::erase::ErasedData<[u8; 8]>>>
             at /Users/timch/rust/compiler/rustc_middle/src/query/inner.rs:31:17
   7: vtable_allocation
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:426:42
   8: vtable_allocation
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:415:35
   9: collect_alloc
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:1291:32
  10: collect_const_value
  11: collect_items_of_instance
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:1356:13
  12: items_of_instance
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:1379:41
  13: {closure#0}
             at /Users/timch/rust/compiler/rustc_query_impl/src/plumbing.rs:294:9
      [... omitted 36 frames ...]
  14: query_get_at<rustc_query_system::query::caches::DefaultCache<(rustc_middle::ty::instance::Instance, rustc_middle::mir::mono::CollectionMode), rustc_middle::query::erase::ErasedData<[u8; 32]>>>
             at /Users/timch/rust/compiler/rustc_middle/src/query/inner.rs:31:17
  15: items_of_instance
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:426:42
  16: items_of_instance
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:415:35
  17: {closure#0}
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:481:49
  18: maybe_grow<(), rustc_monomorphize::collector::collect_items_rec::{closure_env#0}>
             at /Users/timch/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/stacker-0.1.21/src/lib.rs:57:9
  19: ensure_sufficient_stack<(), rustc_monomorphize::collector::collect_items_rec::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/stack.rs:21:5
  20: collect_items_rec
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:480:13
  21: collect_items_root
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:371:5
  22: {closure#0}
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:1824:13
  23: {closure#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:181:30
  24: call_once<(), rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/panic/unwind_safe.rs:274:9
  25: do_call<core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>, ()>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/panicking.rs:581:40
  26: catch_unwind<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/panicking.rs:544:19
  27: catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>, ()>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/panic.rs:359:14
  28: run<(), rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure#1}::{closure_env#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:23:9
  29: {closure#1}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:181:23
  30: {closure#0}<rustc_middle::mir::mono::MonoItem, rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure_env#1}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/iter/traits/iterator.rs:829:29
  31: fold<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global, (), core::iter::traits::iterator::Iterator::for_each::call::{closure_env#0}<rustc_middle::mir::mono::MonoItem, rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure_env#1}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/alloc/src/vec/into_iter.rs:329:25
  32: for_each<alloc::vec::into_iter::IntoIter<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_data_structures::sync::parallel::par_for_each_in::{closure#0}::{closure_env#1}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/iter/traits/iterator.rs:832:14
  33: {closure#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:180:27
  34: parallel_guard<(), rustc_data_structures::sync::parallel::par_for_each_in::{closure_env#0}<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:39:15
  35: par_for_each_in<rustc_middle::mir::mono::MonoItem, alloc::vec::Vec<rustc_middle::mir::mono::MonoItem, alloc::alloc::Global>, rustc_monomorphize::collector::collect_crate_mono_items::{closure#1}::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/sync/parallel.rs:175:5
  36: {closure#1}
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:1823:9
  37: run<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure_env#1}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/profiling.rs:844:9
  38: time<(), rustc_monomorphize::collector::collect_crate_mono_items::{closure_env#1}>
             at /Users/timch/rust/compiler/rustc_session/src/utils.rs:17:50
  39: collect_crate_mono_items
             at /Users/timch/rust/compiler/rustc_monomorphize/src/collector.rs:1822:14
  40: collect_and_partition_mono_items
             at /Users/timch/rust/compiler/rustc_monomorphize/src/partitioning.rs:1138:30
  41: {closure#0}
             at /Users/timch/rust/compiler/rustc_query_impl/src/plumbing.rs:294:9
      [... omitted 33 frames ...]
  42: query_get_at<rustc_query_system::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 24]>>>
             at /Users/timch/rust/compiler/rustc_middle/src/query/inner.rs:31:17
  43: collect_and_partition_mono_items
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:426:42
  44: collect_and_partition_mono_items
             at /Users/timch/rust/compiler/rustc_middle/src/query/plumbing.rs:415:35
  45: codegen_crate<rustc_codegen_llvm::LlvmCodegenBackend>
             at /Users/timch/rust/compiler/rustc_codegen_ssa/src/base.rs:695:56
  46: codegen_crate
             at /Users/timch/rust/compiler/rustc_codegen_llvm/src/lib.rs:354:18
  47: {closure#0}
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1264:29
  48: run<alloc::boxed::Box<dyn core::any::Any, alloc::alloc::Global>, rustc_interface::passes::start_codegen::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_data_structures/src/profiling.rs:844:9
  49: time<alloc::boxed::Box<dyn core::any::Any, alloc::alloc::Global>, rustc_interface::passes::start_codegen::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_session/src/utils.rs:17:50
  50: start_codegen
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1252:28
  51: codegen_and_build_linker
             at /Users/timch/rust/compiler/rustc_interface/src/queries.rs:33:43
  52: {closure#2}
             at /Users/timch/rust/compiler/rustc_driver_impl/src/lib.rs:391:18
  53: {closure#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1018:27
  54: {closure#1}<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context.rs:1643:37
  55: {closure#0}<rustc_middle::ty::context::{impl#20}::enter::{closure_env#1}<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context/tls.rs:60:9
  56: try_with<core::cell::Cell<*const ()>, rustc_middle::ty::context::tls::enter_context::{closure_env#0}<rustc_middle::ty::context::{impl#20}::enter::{closure_env#1}<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/thread/local.rs:513:12
  57: with<core::cell::Cell<*const ()>, rustc_middle::ty::context::tls::enter_context::{closure_env#0}<rustc_middle::ty::context::{impl#20}::enter::{closure_env#1}<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/thread/local.rs:477:20
  58: enter_context<rustc_middle::ty::context::{impl#20}::enter::{closure_env#1}<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>, core::option::Option<rustc_interface::queries::Linker>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context/tls.rs:57:9
  59: enter<rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, core::option::Option<rustc_interface::queries::Linker>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context.rs:1643:9
  60: create_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_interface::passes::create_and_enter_global_ctxt::{closure#2}::{closure_env#0}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>>
             at /Users/timch/rust/compiler/rustc_middle/src/ty/context.rs:1850:13
  61: {closure#2}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:985:9
  62: call_once<rustc_interface::passes::create_and_enter_global_ctxt::{closure_env#2}<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>, (&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy, alloc::alloc::Global>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2})>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/ops/function.rs:250:5
  63: call_once<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy, alloc::alloc::Global>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}), dyn core::ops::function::FnOnce<(&rustc_session::session::Session, rustc_middle::ty::context::CurrentGcx, alloc::sync::Arc<rustc_data_structures::jobserver::Proxy, alloc::alloc::Global>, &std::sync::once_lock::OnceLock<rustc_middle::ty::context::GlobalCtxt>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_middle::arena::Arena>, &rustc_data_structures::sync::worker_local::WorkerLocal<rustc_hir::Arena>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}), Output=core::option::Option<rustc_interface::queries::Linker>>, alloc::alloc::Global>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/alloc/src/boxed.rs:2206:9
  64: create_and_enter_global_ctxt<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure_env#2}>
             at /Users/timch/rust/compiler/rustc_interface/src/passes.rs:1026:5
  65: {closure#0}
             at /Users/timch/rust/compiler/rustc_driver_impl/src/lib.rs:348:22
  66: {closure#0}<(), rustc_driver_impl::run_compiler::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_interface/src/interface.rs:532:80
  67: call_once<(), rustc_interface::interface::run_compiler::{closure#1}::{closure_env#0}<(), rustc_driver_impl::run_compiler::{closure_env#0}>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/core/src/panic/unwind_safe.rs:274:9
  68: do_call<core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler::{closure#1}::{closure_env#0}<(), rustc_driver_impl::run_compiler::{closure_env#0}>>, ()>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/panicking.rs:581:40
  69: catch_unwind<(), core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler::{closure#1}::{closure_env#0}<(), rustc_driver_impl::run_compiler::{closure_env#0}>>>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/panicking.rs:544:19
  70: catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<rustc_interface::interface::run_compiler::{closure#1}::{closure_env#0}<(), rustc_driver_impl::run_compiler::{closure_env#0}>>, ()>
             at /rustc/9b1f8ff42d110b0ca138116745be921df5dc97e7/library/std/src/panic.rs:359:14
  71: {closure#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>
             at /Users/timch/rust/compiler/rustc_interface/src/interface.rs:532:23
  72: {closure#0}<rustc_interface::interface::run_compiler::{closure_env#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>, ()>
             at /Users/timch/rust/compiler/rustc_interface/src/util.rs:204:17
  73: {closure#0}<rustc_interface::util::run_in_thread_pool_with_globals::{closure_env#0}<rustc_interface::interface::run_compiler::{closure_env#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>, ()>, ()>
             at /Users/timch/rust/compiler/rustc_interface/src/util.rs:158:24
  74: set<rustc_span::SessionGlobals, rustc_interface::util::run_in_thread_with_globals::{closure#0}::{closure#0}::{closure_env#0}<rustc_interface::util::run_in_thread_pool_with_globals::{closure_env#0}<rustc_interface::interface::run_compiler::{closure_env#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>, ()>, ()>, ()>
             at /Users/timch/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/scoped-tls-1.0.1/src/lib.rs:137:9
  75: create_session_globals_then<(), rustc_interface::util::run_in_thread_with_globals::{closure#0}::{closure#0}::{closure_env#0}<rustc_interface::util::run_in_thread_pool_with_globals::{closure_env#0}<rustc_interface::interface::run_compiler::{closure_env#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>, ()>, ()>>
             at /Users/timch/rust/compiler/rustc_span/src/lib.rs:142:21
  76: {closure#0}<rustc_interface::util::run_in_thread_pool_with_globals::{closure_env#0}<rustc_interface::interface::run_compiler::{closure_env#1}<(), rustc_driver_impl::run_compiler::{closure_env#0}>, ()>, ()>
             at /Users/timch/rust/compiler/rustc_interface/src/util.rs:154:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please make sure that you have updated to the latest nightly

note: please attach the file at `/Users/timch/foo/rustc-ice-2026-02-03T03_37_20-10469.txt` to your bug report

note: rustc 1.95.0-dev running on aarch64-apple-darwin

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C split-debuginfo=unpacked -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [vtable_allocation] vtable const allocation for <[u8; ValTree(Leaf(0x8000000000000000): usize)] as Trait>
#1 [items_of_instance] collecting items used by `main`
#2 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: could not compile `foo` (bin "foo")
oli-obk Avatar
oli-obk on 2026-02-03 08:10:44 UTC
oli-obk Avatar
oli-obk on 2026-02-03 08:10:44 UTC
View on GitHub

Do any of the issues mentioned so far apply to the existing functions on nightly, too? If so, we should address them there first and add tests for them

theemathas Avatar
theemathas on 2026-02-03 08:27:06 UTC · edited
theemathas Avatar
theemathas on 2026-02-03 08:27:06 UTC · edited
View on GitHub

@oli-obk

type_info gives a reasonable error when faced with layout computation errors

Code & Error 1
#![feature(type_info)]

fn main() {
    dbg!(const {
        std::any::TypeId::of::<[u8; 1<<63]>().info()
    });
}
error[E0080]: values of the type `[u8; 9223372036854775808]` are too big for the target architecture
  --> src/main.rs:5:9
   |
 5 |         std::any::TypeId::of::<[u8; 1<<63]>().info()
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#0}` failed inside this call
   |
note: inside `type_info::<impl TypeId>::info`
  --> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/type_info.rs:25:9
   |
25 |         type_of(self)
   |         ^^^^^^^^^^^^^ the failure occurred here

For more information about this error, try `rustc --explain E0080`.
Code & Error 2
#![feature(type_info)]

trait Apply {
    type Output<T>;
}
struct Identity;
impl Apply for Identity {
    type Output<T> = T;
}

struct Thing<A: Apply>(<A as Apply>::Output<Self>);

/*
Effectively:
struct Thing_Identity(Thing_Identity);
*/

fn main() {
    dbg!(const {
        std::any::TypeId::of::<Thing<Identity>>().info()
    });
}
error[E0391]: cycle detected when computing layout of `Thing<Identity>`
   |
   = note: ...which requires computing layout of `<Identity as Apply>::Output<Thing<Identity>>`...
   = note: ...which again requires computing layout of `Thing<Identity>`, completing the cycle
note: cycle used when const-evaluating + checking `main::{constant#0}`
  --> src/main.rs:19:16
   |
19 |       dbg!(const {
   |  ________________^
20 | |         std::any::TypeId::of::<Thing<Identity>>().info()
21 | |     });
   | |_____^
   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information

error[E0080]: a cycle occurred during layout computation
  --> src/main.rs:20:9
   |
20 |         std::any::TypeId::of::<Thing<Identity>>().info()
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `main::{constant#0}` failed inside this call
   |
note: inside `type_info::<impl TypeId>::info`
  --> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/type_info.rs:25:9
   |
25 |         type_of(self)
   |         ^^^^^^^^^^^^^ the failure occurred here

Some errors have detailed explanations: E0080, E0391.
For more information about an error, try `rustc --explain E0080`.

try_as_dyn has a similar issue with this PR with regards to layout computation errors. I've filed this as #152030.

I think neither type_info nor try_as_dyn will attempt to create a vtable for a DST.

9SonSteroids Avatar
9SonSteroids on 2026-02-03 10:29:39 UTC
9SonSteroids Avatar
9SonSteroids on 2026-02-03 10:29:39 UTC
View on GitHub

Trying to create a vtable for a DST results in an ICE with this PR.

#![feature(type_info)]

use std::any::TypeId;

trait Trait {}
impl Trait for [i32] {}

fn main() {
    const { TypeId::of::<[i32]>().trait_info_of_trait_type_id(TypeId::of::<dyn Trait>()) };
}

Error output

According to my understanding DST's cannot be converted to dyn, right? So returning None would be correct?

9SonSteroids Avatar
9SonSteroids on 2026-02-03 11:19:02 UTC
9SonSteroids Avatar
9SonSteroids on 2026-02-03 11:19:02 UTC
View on GitHub

Failure to compute the layout of the type also results in an ICE with this PR.

#![feature(type_info)]

use std::any::TypeId;

trait Trait {}
impl Trait for [u8; 1 << 63] {}

pub fn main() {
    const { TypeId::of::<[u8; 1 << 63]>().trait_info_of_trait_type_id(TypeId::of::<dyn Trait>()) };
}

Error output

I don't get this ICE on arch linux, x86_64 cpu. I added a ui test for this.

9SonSteroids Avatar
9SonSteroids on 2026-02-03 11:34:22 UTC
9SonSteroids Avatar
9SonSteroids on 2026-02-03 11:34:22 UTC
View on GitHub

violating this documentation. Is this a p

This is not a problem because both functions return None when attempting to get the vtable of a non dyn Type.

9SonSteroids Avatar
9SonSteroids on 2026-02-03 11:37:07 UTC
9SonSteroids Avatar
9SonSteroids on 2026-02-03 11:37:07 UTC
View on GitHub

bors r+

😕1
theemathas Avatar
theemathas on 2026-02-03 14:25:28 UTC
theemathas Avatar
theemathas on 2026-02-03 14:25:28 UTC
View on GitHub

According to my understanding DST's cannot be converted to dyn, right? So returning None would be correct?

Yes

I don't get this ICE on arch linux, x86_64 cpu. I added a ui test for this.

Your latest commit calls .info() in trait_info_of_trait_type_id. It seems that the .info() call failed before getting to call the intrinsic, which avoids the ICE.

This is not a problem because both functions return None when attempting to get the vtable of a non dyn Type.

That's not how it works. Here's code that produces a DynMetadata<*const ()> at run time.

#![feature(type_info, ptr_metadata)]

use std::{any::TypeId, ptr::DynMetadata};

struct Thing;
trait Trait {}
impl Trait for Thing {}

pub fn main() {
    let metadata: DynMetadata<*const ()> =
        const { TypeId::of::<Thing>().trait_info_of_trait_type_id(TypeId::of::<dyn Trait>()) }
            .unwrap()
            .get_vtable();
    println!("{metadata:?}");
}
rust-log-analyzer Avatar
rust-log-analyzer on 2026-02-03 15:29:30 UTC · hidden as outdated
rust-log-analyzer Avatar
rust-log-analyzer on 2026-02-03 15:29:30 UTC · hidden as outdated
View on GitHub

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

Click to see the possible cause of the failure (guessed by this bot)
REPOSITORY                                   TAG       IMAGE ID       CREATED      SIZE
ghcr.io/dependabot/dependabot-updater-core   latest    bcec0b4e062b   7 days ago   783MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:b662be51f7b8ef7e2c8464428f14e49cb79c36aa9afb7ecb9221dfe0f507050c
deleted: sha256:bcec0b4e062b5ffe11cc1c2729558c0cd96621c0271ab5e97ff3a56e0c25045a
deleted: sha256:64e147d5e54d9be8b8aa322e511cda02296eda4b8b8d063c6a314833aca50e29
deleted: sha256:5cba409bb463f4e7fa1a19f695450170422582c1bc7c0e934d893b4e5f558bc6
deleted: sha256:cddc6ebd344b0111eaab170ead1dfda24acdfe865ed8a12599a34d338fa8e28b
deleted: sha256:2412c3f334d79134573cd45e657fb6cc0abd75bef3881458b0d498d936545c8d
---
test [ui] tests/ui/asm/aarch64/type-f16.rs ... ignored, only executed when the architecture is aarch64
test [ui] tests/ui/array-slice-vec/vector-no-ann.rs ... ok
test [ui] tests/ui/array-slice-vec/vector-slice-matching-8498.rs ... ok
test [ui] tests/ui/asm/aarch64/arm64ec-sve.rs ... ok
test [ui] tests/ui/asm/aarch64v8r.rs#hf ... ok
test [ui] tests/ui/asm/aarch64v8r.rs#sf ... ok
test [ui] tests/ui/asm/aarch64v8r.rs#r82 ... 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/binary_asm_labels_allowed.rs ... ignored, only executed when the architecture is aarch64
test [ui] tests/ui/asm/arm-low-dreg.rs ... ok
test [ui] tests/ui/asm/cfg.rs#reva ... ignored, only executed when the architecture is x86_64
---
test [ui] tests/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs#thin2 ... ok
test [ui] tests/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs#thin0 ... ok
test [ui] tests/ui/extern/issue-95829.rs ... ok
test [ui] tests/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs#thin3 ... ok
test [ui] tests/ui/extern/lgamma-linkage.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/windows-tcb-trash-13259.rs ... ok
test [ui] tests/ui/feature-gates/allow-features-empty.rs ... ok
test [ui] tests/ui/feature-gates/allow-features.rs ... ok
---
test [ui] tests/ui/imports/ambiguous-9.rs ... ok
test [ui] tests/ui/imports/ambiguous-import-visibility-module.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-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-panic-non-prelude-core-glob.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-non-prelude-std-glob.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-pick-core.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-pick-std.rs ... ok
---
test [ui] tests/ui/zero-sized/zero-sized-btreemap-insert.rs ... ok

failures:

---- [ui] tests/ui/reflection/trait_info_of_too_big.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/reflection/trait_info_of_too_big/trait_info_of_too_big.stderr`
diff of stderr:

- error[E0080]: values of the type `[u8; 9223372036854775808]` are too big for the target architecture
-   --> $DIR/trait_info_of_too_big.rs:13:5
+ error[E0080]: attempt to shift left by `63_i32`, which would overflow
+   --> $DIR/trait_info_of_too_big.rs:8:21
3    |
- LL |     TypeId::of::<[u8; 1 << 63]>().trait_info_of_trait_type_id(TypeId::of::<dyn Trait>());
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call
+ LL | impl Trait for [u8; 1 << 63] {}
+    |                     ^^^^^^^ evaluation of `<[u8; 1 << 63] as Trait>::{constant#0}` failed here
+ 
+ error[E0080]: attempt to shift left by `63_i32`, which would overflow
+   --> $DIR/trait_info_of_too_big.rs:13:23
6    |
- note: inside `TypeId::trait_info_of_trait_type_id`
-   --> $SRC_DIR/core/src/any.rs:LL:COL
- note: inside `type_info::<impl TypeId>::info`
-   --> $SRC_DIR/core/src/mem/type_info.rs:LL:COL
+ LL |     TypeId::of::<[u8; 1 << 63]>().trait_info_of_trait_type_id(TypeId::of::<dyn Trait>());
+    |                       ^^^^^^^ evaluation of `_::{constant#0}::{constant#0}` failed here
11 
- error[E0080]: values of the type `[u8; 9223372036854775808]` are too big for the target architecture
-   --> $DIR/trait_info_of_too_big.rs:17:5
+ error[E0080]: attempt to shift left by `63_i32`, which would overflow
+   --> $DIR/trait_info_of_too_big.rs:17:23
14    |
15 LL |     TypeId::of::<[u8; 1 << 63]>().trait_info_of::<dyn Trait>();
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call
-    |
- note: inside `TypeId::trait_info_of::<dyn Trait>`
-   --> $SRC_DIR/core/src/any.rs:LL:COL
- note: inside `TypeId::trait_info_of_trait_type_id`
-   --> $SRC_DIR/core/src/any.rs:LL:COL
- note: inside `type_info::<impl TypeId>::info`
-   --> $SRC_DIR/core/src/mem/type_info.rs:LL:COL
+    |                       ^^^^^^^ evaluation of `_::{constant#0}::{constant#0}` failed here
24 
- error: aborting due to 2 previous errors
+ error: aborting due to 3 previous errors
26 
27 For more information about this error, try `rustc --explain E0080`.
28 

Note: some mismatched output was normalized before being compared
-   --> /checkout/tests/ui/reflection/trait_info_of_too_big.rs:8:21
-   --> /checkout/tests/ui/reflection/trait_info_of_too_big.rs:13:23
-   --> /checkout/tests/ui/reflection/trait_info_of_too_big.rs:17:23
+ error[E0080]: attempt to shift left by `63_i32`, which would overflow
+   --> $DIR/trait_info_of_too_big.rs:8:21
+ LL | impl Trait for [u8; 1 << 63] {}
+    |                     ^^^^^^^ evaluation of `<[u8; 1 << 63] as Trait>::{constant#0}` failed here
+ 
+ error[E0080]: attempt to shift left by `63_i32`, which would overflow
+   --> $DIR/trait_info_of_too_big.rs:13:23
+    |
+    |                       ^^^^^^^ evaluation of `_::{constant#0}::{constant#0}` failed here
+ error[E0080]: attempt to shift left by `63_i32`, which would overflow
+   --> $DIR/trait_info_of_too_big.rs:17:23
+    |                       ^^^^^^^ evaluation of `_::{constant#0}::{constant#0}` failed here
+ error: aborting due to 3 previous errors


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args reflection/trait_info_of_too_big.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/reflection/trait_info_of_too_big.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=i686-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/reflection/trait_info_of_too_big" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/i686-unknown-linux-gnu/native/rust-test-helpers" "-Clinker=x86_64-linux-gnu-gcc"
stdout: none
--- stderr -------------------------------
error[E0080]: attempt to shift left by `63_i32`, which would overflow
##[error]  --> /checkout/tests/ui/reflection/trait_info_of_too_big.rs:8:21
   |
LL | impl Trait for [u8; 1 << 63] {}
   |                     ^^^^^^^ evaluation of `<[u8; 1 << 63] as Trait>::{constant#0}` failed here

error[E0080]: attempt to shift left by `63_i32`, which would overflow
##[error]  --> /checkout/tests/ui/reflection/trait_info_of_too_big.rs:13:23
   |
LL |     TypeId::of::<[u8; 1 << 63]>().trait_info_of_trait_type_id(TypeId::of::<dyn Trait>());
   |                       ^^^^^^^ evaluation of `_::{constant#0}::{constant#0}` failed here

error[E0080]: attempt to shift left by `63_i32`, which would overflow
##[error]  --> /checkout/tests/ui/reflection/trait_info_of_too_big.rs:17:23
   |
LL |     TypeId::of::<[u8; 1 << 63]>().trait_info_of::<dyn Trait>();
   |                       ^^^^^^^ evaluation of `_::{constant#0}::{constant#0}` failed here

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0080`.
------------------------------------------
9SonSteroids Avatar
9SonSteroids on 2026-02-03 17:02:55 UTC
9SonSteroids Avatar
9SonSteroids on 2026-02-03 17:02:55 UTC
View on GitHub

According to my understanding DST's cannot be converted to dyn, right? So returning None would be correct?

Yes

I don't get this ICE on arch linux, x86_64 cpu. I added a ui test for this.

Your latest commit calls .info() in trait_info_of_trait_type_id. It seems that the .info() call failed before getting to call the intrinsic, which avoids the ICE.

This is not a problem because both functions return None when attempting to get the vtable of a non dyn Type.

That's not how it works. Here's code that produces a DynMetadata<*const ()> at run time.

#![feature(type_info, ptr_metadata)]

use std::{any::TypeId, ptr::DynMetadata};

struct Thing;
trait Trait {}
impl Trait for Thing {}

pub fn main() {
    let metadata: DynMetadata<*const ()> =
        const { TypeId::of::<Thing>().trait_info_of_trait_type_id(TypeId::of::<dyn Trait>()) }
            .unwrap()
            .get_vtable();
    println!("{metadata:?}");
}

So what should we do? The trait_info_of_trait_type_id vtable is for unknown dyn type. We could make this function just return a bool.

9SonSteroids Avatar
9SonSteroids on 2026-02-03 17:05:54 UTC
9SonSteroids Avatar
9SonSteroids on 2026-02-03 17:05:54 UTC
View on GitHub

The job x86_64-gnu-llvm-20 failed! Check out the build log: (web) (plain enhanced) (plain)
Click to see the possible cause of the failure (guessed by this bot)

REPOSITORY                                   TAG       IMAGE ID       CREATED      SIZE
ghcr.io/dependabot/dependabot-updater-core   latest    bcec0b4e062b   7 days ago   783MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:b662be51f7b8ef7e2c8464428f14e49cb79c36aa9afb7ecb9221dfe0f507050c
deleted: sha256:bcec0b4e062b5ffe11cc1c2729558c0cd96621c0271ab5e97ff3a56e0c25045a
deleted: sha256:64e147d5e54d9be8b8aa322e511cda02296eda4b8b8d063c6a314833aca50e29
deleted: sha256:5cba409bb463f4e7fa1a19f695450170422582c1bc7c0e934d893b4e5f558bc6
deleted: sha256:cddc6ebd344b0111eaab170ead1dfda24acdfe865ed8a12599a34d338fa8e28b
deleted: sha256:2412c3f334d79134573cd45e657fb6cc0abd75bef3881458b0d498d936545c8d
---
test [ui] tests/ui/asm/aarch64/type-f16.rs ... ignored, only executed when the architecture is aarch64
test [ui] tests/ui/array-slice-vec/vector-no-ann.rs ... ok
test [ui] tests/ui/array-slice-vec/vector-slice-matching-8498.rs ... ok
test [ui] tests/ui/asm/aarch64/arm64ec-sve.rs ... ok
test [ui] tests/ui/asm/aarch64v8r.rs#hf ... ok
test [ui] tests/ui/asm/aarch64v8r.rs#sf ... ok
test [ui] tests/ui/asm/aarch64v8r.rs#r82 ... 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/binary_asm_labels_allowed.rs ... ignored, only executed when the architecture is aarch64
test [ui] tests/ui/asm/arm-low-dreg.rs ... ok
test [ui] tests/ui/asm/cfg.rs#reva ... ignored, only executed when the architecture is x86_64
---
test [ui] tests/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs#thin2 ... ok
test [ui] tests/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs#thin0 ... ok
test [ui] tests/ui/extern/issue-95829.rs ... ok
test [ui] tests/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs#thin3 ... ok
test [ui] tests/ui/extern/lgamma-linkage.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/windows-tcb-trash-13259.rs ... ok
test [ui] tests/ui/feature-gates/allow-features-empty.rs ... ok
test [ui] tests/ui/feature-gates/allow-features.rs ... ok
---
test [ui] tests/ui/imports/ambiguous-9.rs ... ok
test [ui] tests/ui/imports/ambiguous-import-visibility-module.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-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-panic-non-prelude-core-glob.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-non-prelude-std-glob.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-pick-core.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-pick-std.rs ... ok
---
test [ui] tests/ui/zero-sized/zero-sized-btreemap-insert.rs ... ok

failures:

---- [ui] tests/ui/reflection/trait_info_of_too_big.rs stdout ----
Saved the actual stderr to `/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/reflection/trait_info_of_too_big/trait_info_of_too_big.stderr`
diff of stderr:

- error[E0080]: values of the type `[u8; 9223372036854775808]` are too big for the target architecture
-   --> $DIR/trait_info_of_too_big.rs:13:5
+ error[E0080]: attempt to shift left by `63_i32`, which would overflow
+   --> $DIR/trait_info_of_too_big.rs:8:21
3    |
- LL |     TypeId::of::<[u8; 1 << 63]>().trait_info_of_trait_type_id(TypeId::of::<dyn Trait>());
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call
+ LL | impl Trait for [u8; 1 << 63] {}
+    |                     ^^^^^^^ evaluation of `<[u8; 1 << 63] as Trait>::{constant#0}` failed here
+ 
+ error[E0080]: attempt to shift left by `63_i32`, which would overflow
+   --> $DIR/trait_info_of_too_big.rs:13:23
6    |
- note: inside `TypeId::trait_info_of_trait_type_id`
-   --> $SRC_DIR/core/src/any.rs:LL:COL
- note: inside `type_info::<impl TypeId>::info`
-   --> $SRC_DIR/core/src/mem/type_info.rs:LL:COL
+ LL |     TypeId::of::<[u8; 1 << 63]>().trait_info_of_trait_type_id(TypeId::of::<dyn Trait>());
+    |                       ^^^^^^^ evaluation of `_::{constant#0}::{constant#0}` failed here
11 
- error[E0080]: values of the type `[u8; 9223372036854775808]` are too big for the target architecture
-   --> $DIR/trait_info_of_too_big.rs:17:5
+ error[E0080]: attempt to shift left by `63_i32`, which would overflow
+   --> $DIR/trait_info_of_too_big.rs:17:23
14    |
15 LL |     TypeId::of::<[u8; 1 << 63]>().trait_info_of::<dyn Trait>();
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call
-    |
- note: inside `TypeId::trait_info_of::<dyn Trait>`
-   --> $SRC_DIR/core/src/any.rs:LL:COL
- note: inside `TypeId::trait_info_of_trait_type_id`
-   --> $SRC_DIR/core/src/any.rs:LL:COL
- note: inside `type_info::<impl TypeId>::info`
-   --> $SRC_DIR/core/src/mem/type_info.rs:LL:COL
+    |                       ^^^^^^^ evaluation of `_::{constant#0}::{constant#0}` failed here
24 
- error: aborting due to 2 previous errors
+ error: aborting due to 3 previous errors
26 
27 For more information about this error, try `rustc --explain E0080`.
28 

Note: some mismatched output was normalized before being compared
-   --> /checkout/tests/ui/reflection/trait_info_of_too_big.rs:8:21
-   --> /checkout/tests/ui/reflection/trait_info_of_too_big.rs:13:23
-   --> /checkout/tests/ui/reflection/trait_info_of_too_big.rs:17:23
+ error[E0080]: attempt to shift left by `63_i32`, which would overflow
+   --> $DIR/trait_info_of_too_big.rs:8:21
+ LL | impl Trait for [u8; 1 << 63] {}
+    |                     ^^^^^^^ evaluation of `<[u8; 1 << 63] as Trait>::{constant#0}` failed here
+ 
+ error[E0080]: attempt to shift left by `63_i32`, which would overflow
+   --> $DIR/trait_info_of_too_big.rs:13:23
+    |
+    |                       ^^^^^^^ evaluation of `_::{constant#0}::{constant#0}` failed here
+ error[E0080]: attempt to shift left by `63_i32`, which would overflow
+   --> $DIR/trait_info_of_too_big.rs:17:23
+    |                       ^^^^^^^ evaluation of `_::{constant#0}::{constant#0}` failed here
+ error: aborting due to 3 previous errors


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args reflection/trait_info_of_too_big.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/reflection/trait_info_of_too_big.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=i686-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/reflection/trait_info_of_too_big" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/i686-unknown-linux-gnu/native/rust-test-helpers" "-Clinker=x86_64-linux-gnu-gcc"
stdout: none
--- stderr -------------------------------
error[E0080]: attempt to shift left by `63_i32`, which would overflow
##[error]  --> /checkout/tests/ui/reflection/trait_info_of_too_big.rs:8:21
   |
LL | impl Trait for [u8; 1 << 63] {}
   |                     ^^^^^^^ evaluation of `<[u8; 1 << 63] as Trait>::{constant#0}` failed here

error[E0080]: attempt to shift left by `63_i32`, which would overflow
##[error]  --> /checkout/tests/ui/reflection/trait_info_of_too_big.rs:13:23
   |
LL |     TypeId::of::<[u8; 1 << 63]>().trait_info_of_trait_type_id(TypeId::of::<dyn Trait>());
   |                       ^^^^^^^ evaluation of `_::{constant#0}::{constant#0}` failed here

error[E0080]: attempt to shift left by `63_i32`, which would overflow
##[error]  --> /checkout/tests/ui/reflection/trait_info_of_too_big.rs:17:23
   |
LL |     TypeId::of::<[u8; 1 << 63]>().trait_info_of::<dyn Trait>();
   |                       ^^^^^^^ evaluation of `_::{constant#0}::{constant#0}` failed here

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0080`.
------------------------------------------

Guess I have to adapt it to from 1 << 63 to 1 << bitness-1

programmerjake Avatar
programmerjake on 2026-02-03 19:45:18 UTC
programmerjake Avatar
programmerjake on 2026-02-03 19:45:18 UTC
View on GitHub

Guess I have to adapt it to from 1 << 63 to 1 << bitness-1

you can use [u8; usize::MAX]

rust-log-analyzer Avatar
rust-log-analyzer on 2026-02-04 06:58:41 UTC · hidden as outdated
rust-log-analyzer Avatar
rust-log-analyzer on 2026-02-04 06:58:41 UTC · hidden as outdated
View on GitHub

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/type-check-2-2.rs ... ok
test [ui] tests/ui/asm/aarch64/type-check-3.rs ... ok
test [ui] tests/ui/asm/aarch64/type-f16.rs ... ok
test [ui] tests/ui/asm/aarch64/sym.rs ... ok
test [ui] tests/ui/asm/aarch64v8r.rs#hf ... ok
test [ui] tests/ui/asm/aarch64v8r.rs#sf ... ok
test [ui] tests/ui/asm/aarch64v8r.rs#r82 ... 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/arm-low-dreg.rs ... ok
test [ui] tests/ui/asm/binary_asm_labels_allowed.rs ... ok
test [ui] tests/ui/asm/cfg.rs#reva ... ignored, only executed when the architecture is x86_64
---
test [ui] tests/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs#fat3 ... ok
test [ui] tests/ui/extern/issue-64655-extern-rust-must-allow-unwind.rs#thin1 ... ok
test [ui] tests/ui/extern/issue-95829.rs ... ok
test [ui] tests/ui/extern/issue-80074.rs ... ok
test [ui] tests/ui/extern/lgamma-linkage.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/windows-tcb-trash-13259.rs ... ok
test [ui] tests/ui/extern/no-mangle-associated-fn.rs ... ok
test [ui] tests/ui/feature-gates/allow-features.rs ... ok
---
test [ui] tests/ui/imports/ambiguous-9.rs ... ok
test [ui] tests/ui/imports/ambiguous-import-visibility-module.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-glob-vs-multiouter.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-globvsglob.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-non-prelude-core-glob.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-no-implicit-prelude.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-non-prelude-std-glob.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-pick-core.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-pick-std.rs ... ok
---
test [ui] tests/ui/zero-sized/zero-sized-btreemap-insert.rs ... ok

failures:

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

- error[E0080]: values of the type `[u8; 9223372036854775808]` are too big for the target architecture
-   --> $DIR/trait_info_of_too_big.rs:13:5
+ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture
+   --> $DIR/trait_info_of_too_big.rs:14:5
3    |
- LL |     TypeId::of::<[u8; 1 << 63]>().trait_info_of_trait_type_id(TypeId::of::<dyn Trait>());
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call
+ LL |     TypeId::of::<[u8; usize::MAX]>().trait_info_of_trait_type_id(TypeId::of::<dyn Trait>());
+    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call
6    |
7 note: inside `TypeId::trait_info_of_trait_type_id`
8   --> $SRC_DIR/core/src/any.rs:LL:COL

9 note: inside `type_info::<impl TypeId>::info`
10   --> $SRC_DIR/core/src/mem/type_info.rs:LL:COL
11 
- error[E0080]: values of the type `[u8; 9223372036854775808]` are too big for the target architecture
-   --> $DIR/trait_info_of_too_big.rs:17:5
+ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture
+   --> $DIR/trait_info_of_too_big.rs:18:5
14    |
- LL |     TypeId::of::<[u8; 1 << 63]>().trait_info_of::<dyn Trait>();
-    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call
+ LL |     TypeId::of::<[u8; usize::MAX]>().trait_info_of::<dyn Trait>();
+    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call
17    |
18 note: inside `TypeId::trait_info_of::<dyn Trait>`
19   --> $SRC_DIR/core/src/any.rs:LL:COL

Note: some mismatched output was normalized before being compared
-   --> /checkout/tests/ui/reflection/trait_info_of_too_big.rs:14:5
-   --> /checkout/tests/ui/reflection/trait_info_of_too_big.rs:18:5
+ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture
+   --> $DIR/trait_info_of_too_big.rs:14:5
+ LL |     TypeId::of::<[u8; usize::MAX]>().trait_info_of_trait_type_id(TypeId::of::<dyn Trait>());
+    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call
+ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture
+   --> $DIR/trait_info_of_too_big.rs:18:5
+ LL |     TypeId::of::<[u8; usize::MAX]>().trait_info_of::<dyn Trait>();
+    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args reflection/trait_info_of_too_big.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/reflection/trait_info_of_too_big.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/reflection/trait_info_of_too_big" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture
##[error]  --> /checkout/tests/ui/reflection/trait_info_of_too_big.rs:14:5
   |
LL |     TypeId::of::<[u8; usize::MAX]>().trait_info_of_trait_type_id(TypeId::of::<dyn Trait>());
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call
   |
note: inside `TypeId::trait_info_of_trait_type_id`
  --> /rustc/FAKE_PREFIX/library/core/src/any.rs:842:11
note: inside `type_info::<impl TypeId>::info`
  --> /rustc/FAKE_PREFIX/library/core/src/mem/type_info.rs:40:8

error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture
##[error]  --> /checkout/tests/ui/reflection/trait_info_of_too_big.rs:18:5
   |
LL |     TypeId::of::<[u8; usize::MAX]>().trait_info_of::<dyn Trait>();
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `_::{constant#0}` failed inside this call
   |
note: inside `TypeId::trait_info_of::<dyn Trait>`
  --> /rustc/FAKE_PREFIX/library/core/src/any.rs:818:27
note: inside `TypeId::trait_info_of_trait_type_id`
  --> /rustc/FAKE_PREFIX/library/core/src/any.rs:842:11
rust-bors Avatar
rust-bors on 2026-02-07 03:55:32 UTC · hidden as outdated
rust-bors Avatar
rust-bors on 2026-02-07 03:55:32 UTC · hidden as outdated
View on GitHub

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

joboet Avatar
joboet on 2026-02-07 15:09:40 UTC
joboet Avatar
joboet on 2026-02-07 15:09:40 UTC
View on GitHub

r? compiler
This is outside my area of expertise...

rustbot Avatar
rustbot on 2026-02-09 10:50:31 UTC · hidden as outdated
rustbot Avatar
rustbot on 2026-02-09 10:50:31 UTC · hidden as outdated
View on GitHub

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 Avatar
rustbot on 2026-02-09 10:50:32 UTC · hidden as resolved
rustbot Avatar
rustbot on 2026-02-09 10:50:32 UTC · hidden as resolved
View on GitHub

⚠️ Warning ⚠️

  • The following commits have merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

    You can start a rebase with the following commands:

    $ # rebase
    $ git pull --rebase https://github.com/rust-lang/rust.git main
    $ git push --force-with-lease
    
rust-log-analyzer Avatar
rust-log-analyzer on 2026-02-09 13:34:12 UTC · hidden as outdated
rust-log-analyzer Avatar
rust-log-analyzer on 2026-02-09 13:34:12 UTC · hidden as outdated
View on GitHub

The job pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
REPOSITORY                                   TAG       IMAGE ID       CREATED      SIZE
ghcr.io/dependabot/dependabot-updater-core   latest    b72a662c47e3   9 days ago   790MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:57ef9cc45f72cc4258ee1baa8243bc3cd55c0a0e570b6768c37346247be35f0d
deleted: sha256:b72a662c47e31df2e7bf59368b2b83be239f02a1baa721393717711a1a719df9
deleted: sha256:3e13ccd80f19769f39008cfc6549938e1ea4905f47b028c1df2dd6085191386c
deleted: sha256:842807995a512b2c5a9b241a3aecdbe79af6b0642d96fa5460cfcf0c9d8be295
deleted: sha256:0f9074b9f46f4570eb7cb4b65fcb3c3d909f9b1d14ca66b30508117b6deda303
deleted: sha256:2ca99cb9251d19157c56b5d91c8961bb4b35196a5ca9b4ffdccbf24abbfe2a5f
rust-bors Avatar
rust-bors on 2026-02-15 03:11:46 UTC · hidden as outdated
rust-bors Avatar
rust-bors on 2026-02-15 03:11:46 UTC · hidden as outdated
View on GitHub

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

theemathas Avatar
theemathas on 2026-02-15 04:14:34 UTC
theemathas Avatar
theemathas on 2026-02-15 04:14:34 UTC
View on GitHub

This PR probably has nontrivial interactions with #150161 and #152381

rustbot Avatar
rustbot on 2026-02-15 23:08:18 UTC · hidden as outdated
rustbot Avatar
rustbot on 2026-02-15 23:08:18 UTC · hidden as outdated
View on GitHub

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 Avatar
rustbot on 2026-02-15 23:08:18 UTC · hidden as resolved
rustbot Avatar
rustbot on 2026-02-15 23:08:18 UTC · hidden as resolved
View on GitHub

⚠️ Warning ⚠️

  • The following commits have merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

    You can start a rebase with the following commands:

    $ # rebase
    $ git pull --rebase https://github.com/rust-lang/rust.git main
    $ git push --force-with-lease
    
programmerjake Avatar
programmerjake commented on 2026-02-16 00:57:20 UTC
library/core/src/mem/type_info.rs · outdated
2 2 //! runtime or const-eval processable way.
3 3
4 4 use crate::any::TypeId;
5
programmerjake Avatar programmerjake on 2026-02-16 00:57:20 UTC
View on GitHub
Suggested change

why the blank line?

oli-obk Avatar
oli-obk requested changes on 2026-02-16 13:57:52 UTC
library/core/src/intrinsics/mod.rs · resolved
2872 pub const fn type_id_vtable(
2873 _id: crate::any::TypeId,
2874 _trait: crate::any::TypeId,
2875 ) -> Option<ptr::DynMetadata<*const ()>> {
oli-obk Avatar oli-obk on 2026-02-16 13:57:19 UTC
View on GitHub

Can we nix the vtable_for intrinsic now and replace all its uses with calls to one of the new TypeId methods?

9SonSteroids Avatar 9SonSteroids on 2026-02-16 15:42:51 UTC
View on GitHub

Which TypeId methods could replace it?

oli-obk Avatar oli-obk on 2026-02-16 16:38:24 UTC
View on GitHub

trait_info_of plus accessing the metadata field directly

9SonSteroids Avatar 9SonSteroids on 2026-02-17 13:02:52 UTC
View on GitHub

TypeId::trait_info_of uses this intrinsic so it would result in recursion

oli-obk Avatar oli-obk on 2026-02-17 18:50:19 UTC
View on GitHub

No. I want try_as_dyn to call trait_info_of. As the try_as_dyn functions are the only users of vtable_for

👍1
rustbot Avatar
rustbot on 2026-02-16 13:57:55 UTC
rustbot Avatar
rustbot on 2026-02-16 13:57:55 UTC
View on GitHub

Reminder, once the PR becomes ready for a review, use @rustbot ready.

rustbot Avatar
rustbot on 2026-02-16 15:37:25 UTC · hidden as outdated
rustbot Avatar
rustbot on 2026-02-16 15:37:25 UTC · hidden as outdated
View on GitHub

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 Avatar
rustbot on 2026-02-16 15:42:05 UTC · hidden as outdated
rustbot Avatar
rustbot on 2026-02-16 15:42:05 UTC · hidden as outdated
View on GitHub

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 Avatar
rustbot on 2026-02-16 15:42:06 UTC · hidden as resolved
rustbot Avatar
rustbot on 2026-02-16 15:42:06 UTC · hidden as resolved
View on GitHub

⚠️ Warning ⚠️

  • The following commits have merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

    You can start a rebase with the following commands:

    $ # rebase
    $ git pull --rebase https://github.com/rust-lang/rust.git main
    $ git push --force-with-lease
    
rustbot Avatar
rustbot on 2026-02-17 13:10:07 UTC · hidden as outdated
rustbot Avatar
rustbot on 2026-02-17 13:10:07 UTC · hidden as outdated
View on GitHub

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.

rust-log-analyzer Avatar
rust-log-analyzer on 2026-02-18 15:53:52 UTC · hidden as outdated
rust-log-analyzer Avatar
rust-log-analyzer on 2026-02-18 15:53:52 UTC · hidden as outdated
View on GitHub

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)
REPOSITORY                                   TAG       IMAGE ID       CREATED       SIZE
ghcr.io/dependabot/dependabot-updater-core   latest    afc745c7535d   3 weeks ago   783MB
=> Removing docker images...
Deleted Images:
untagged: ghcr.io/dependabot/dependabot-updater-core:latest
untagged: ghcr.io/dependabot/dependabot-updater-core@sha256:faae3d3a1dedd24cde388bb506bbacc0f7ed1eae99ebac129af66acd8540c84a
deleted: sha256:afc745c7535da1bb12f92c273b9a7e9c52c3f12c5873714b2542da259c6d9769
deleted: sha256:64e147d5e54d9be8b8aa322e511cda02296eda4b8b8d063c6a314833aca50e29
deleted: sha256:5cba409bb463f4e7fa1a19f695450170422582c1bc7c0e934d893b4e5f558bc6
deleted: sha256:cddc6ebd344b0111eaab170ead1dfda24acdfe865ed8a12599a34d338fa8e28b
deleted: sha256:2412c3f334d79134573cd45e657fb6cc0abd75bef3881458b0d498d936545c8d
---
test [ui] tests/ui/abi/abi-sysv64-register-usage.rs ... ignored, ignored when the architecture is aarch64
test [ui] tests/ui/abi/abi-typo-unstable.rs#feature_disabled ... ok
test [ui] tests/ui/abi/abi-typo-unstable.rs#feature_enabled ... ok
test [ui] tests/ui/abi/anon-extern-mod.rs ... ok
test [ui] tests/ui/abi/avr-sram.rs#disable_sram ... ok
test [ui] tests/ui/abi/arm-unadjusted-intrinsic.rs#aarch64 ... ok
test [ui] tests/ui/abi/avr-sram.rs#has_sram ... ok
test [ui] tests/ui/abi/avr-sram.rs#no_sram ... ok
test [ui] tests/ui/abi/arm-unadjusted-intrinsic.rs#arm ... ok
test [ui] tests/ui/abi/bad-custom.rs ... ok
test [ui] tests/ui/abi/c-stack-as-value.rs ... ok
test [ui] tests/ui/abi/c-zst.rs#aarch64-darwin ... ok
test [ui] tests/ui/abi/c-zst.rs#powerpc-linux ... 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/aarch64/type-check-2-2.rs ... ok
test [ui] tests/ui/asm/aarch64/type-f16.rs ... ok
test [ui] tests/ui/asm/aarch64v8r.rs#r82 ... ok
test [ui] tests/ui/asm/aarch64v8r.rs#hf ... ok
test [ui] tests/ui/asm/aarch64v8r.rs#sf ... ok
test [ui] tests/ui/asm/aarch64/sym.rs ... ok
test [ui] tests/ui/asm/arm-low-dreg.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/asm-with-nested-closure.rs ... ok
test [ui] tests/ui/asm/bad-template.rs#x86_64 ... ok
---
test [ui] tests/ui/const-generics/ogca/basic-fail.rs ... ok
test [ui] tests/ui/const-generics/ogca/basic.rs ... ok
test [ui] tests/ui/const-generics/occurs-check/unused-substs-5.rs ... ok
test [ui] tests/ui/const-generics/occurs-check/unused-substs-4.rs ... ok
test [ui] tests/ui/const-generics/ogca/coherence-ambiguous.rs ... ok
test [ui] tests/ui/const-generics/ogca/rhs-but-not-root.rs ... ok
test [ui] tests/ui/const-generics/opaque_types2.rs ... ok
test [ui] tests/ui/const-generics/opaque_types.rs ... ok
test [ui] tests/ui/const-generics/outer-lifetime-in-const-generic-default.rs ... ok
test [ui] tests/ui/const-generics/overlapping_impls.rs ... ok
test [ui] tests/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs#full ... 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/issue-64655-extern-rust-must-allow-unwind.rs#thin1 ... 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/feature-gates/allow-features-empty.rs ... ok
---
test [ui] tests/ui/feature-gates/feature-gate-log_syntax2.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-macro-metavar-expr-concat.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-marker_trait_attr.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-may-dangle.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-mgca-type-const-syntax.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-min-generic-const-args.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-movrs_target_feature.rs ... ignored, only executed when the architecture is x86_64
test [ui] tests/ui/feature-gates/feature-gate-more-maybe-bounds.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-min_const_fn.rs ... ok
test [ui] tests/ui/feature-gates/feature-gate-naked_functions_rustic_abi.rs ... ignored, only executed when the architecture is x86_64
---
test [ui] tests/ui/imports/ambiguous-7.rs ... ok
test [ui] tests/ui/imports/ambiguous-import-visibility-module.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-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-panic-non-prelude-core-glob.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-pick-core.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-non-prelude-std-glob.rs ... ok
test [ui] tests/ui/imports/ambiguous-panic-pick-std.rs ... ok
---
test [ui] tests/ui/layout/post-mono-layout-cycle.rs ... ok
test [ui] tests/ui/layout/randomize.rs#randomize-layout ... ok
test [ui] tests/ui/layout/randomize.rs#normal ... ok
test [ui] tests/ui/layout/null-pointer-optimization.rs ... ok
test [ui] tests/ui/layout/rigid-alias-due-to-broken-impl.rs ... ok
test [ui] tests/ui/layout/size-of-val-raw-too-big.rs ... ignored, only executed when the pointer width is 32bit (Layout computation rejects this layout for different reasons on 64-bit.)
test [ui] tests/ui/layout/reprc-power-alignment.rs ... ok
test [ui] tests/ui/layout/struct.rs ... ok
test [ui] tests/ui/layout/rigid-alias-no-params.rs ... ok
test [ui] tests/ui/layout/rust-call-abi-not-a-tuple-ice-81974.rs ... ok
---
test [ui] tests/ui/zero-sized/zero-sized-btreemap-insert.rs ... ok

failures:

---- [ui] tests/ui/limits/vtable-try-as-dyn.rs#full-debuginfo stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/limits/vtable-try-as-dyn.full-debuginfo/vtable-try-as-dyn.full-debuginfo.stderr`
diff of stderr:

- error: values of the type `[u8; usize::MAX]` are too big for the target architecture
+ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture
+   --> $SRC_DIR/core/src/any.rs:LL:COL
+    |
+    = note: evaluation of `std::any::try_as_dyn::<[u8; usize::MAX], dyn Trait>::{constant#0}` failed inside this call
+ note: inside `TypeId::trait_info_of::<dyn Trait>`
+   --> $SRC_DIR/core/src/any.rs:LL:COL
+ note: inside `TypeId::trait_info_of_trait_type_id`
+   --> $SRC_DIR/core/src/any.rs:LL:COL
+ note: inside `type_info::<impl TypeId>::info`
+   --> $SRC_DIR/core/src/mem/type_info.rs:LL:COL
2 
+ note: the above error was encountered while instantiating `fn try_as_dyn::<[u8; usize::MAX], dyn Trait>`
+   --> $DIR/vtable-try-as-dyn.rs:14:13
+    |
+ LL |     let _ = std::any::try_as_dyn::<[u8; usize::MAX], dyn Trait>(x);
+    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ 
3 error: aborting due to 1 previous error
4 
+ For more information about this error, try `rustc --explain E0080`.
---
-   --> /rustc/FAKE_PREFIX/library/core/src/any.rs:818:27
-   --> /rustc/FAKE_PREFIX/library/core/src/any.rs:842:11
-   --> /rustc/FAKE_PREFIX/library/core/src/mem/type_info.rs:40:8
-   --> /checkout/tests/ui/limits/vtable-try-as-dyn.rs:14:13
+ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture
+   --> $SRC_DIR/core/src/any.rs:LL:COL
+    |
+    = note: evaluation of `std::any::try_as_dyn::<[u8; usize::MAX], dyn Trait>::{constant#0}` failed inside this call
+ note: inside `TypeId::trait_info_of::<dyn Trait>`
+   --> $SRC_DIR/core/src/any.rs:LL:COL
+ note: inside `TypeId::trait_info_of_trait_type_id`
+   --> $SRC_DIR/core/src/any.rs:LL:COL
+ note: inside `type_info::<impl TypeId>::info`
+   --> $SRC_DIR/core/src/mem/type_info.rs:LL:COL
+ note: the above error was encountered while instantiating `fn try_as_dyn::<[u8; usize::MAX], dyn Trait>`
+   --> $DIR/vtable-try-as-dyn.rs:14:13
+    |
+ LL |     let _ = std::any::try_as_dyn::<[u8; usize::MAX], dyn Trait>(x);
+    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ 
+ For more information about this error, try `rustc --explain E0080`.


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args limits/vtable-try-as-dyn.rs`

error in revision `full-debuginfo`: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/limits/vtable-try-as-dyn.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--cfg" "full_debuginfo" "--check-cfg" "cfg(test,FALSE,no_debuginfo,full_debuginfo)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/limits/vtable-try-as-dyn.full-debuginfo" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--crate-type=lib" "--emit=mir" "-C" "debuginfo=2"
stdout: none
--- stderr -------------------------------
error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture
##[error]  --> /rustc/FAKE_PREFIX/library/core/src/any.rs:1016:16
   |
   = note: evaluation of `std::any::try_as_dyn::<[u8; usize::MAX], dyn Trait>::{constant#0}` failed inside this call
note: inside `TypeId::trait_info_of::<dyn Trait>`
  --> /rustc/FAKE_PREFIX/library/core/src/any.rs:818:27
note: inside `TypeId::trait_info_of_trait_type_id`
  --> /rustc/FAKE_PREFIX/library/core/src/any.rs:842:11
note: inside `type_info::<impl TypeId>::info`
  --> /rustc/FAKE_PREFIX/library/core/src/mem/type_info.rs:40:8

note: the above error was encountered while instantiating `fn try_as_dyn::<[u8; usize::MAX], dyn Trait>`
  --> /checkout/tests/ui/limits/vtable-try-as-dyn.rs:14:13
   |
LL |     let _ = std::any::try_as_dyn::<[u8; usize::MAX], dyn Trait>(x);
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0080`.
------------------------------------------

---- [ui] tests/ui/limits/vtable-try-as-dyn.rs#full-debuginfo stdout end ----
---- [ui] tests/ui/limits/vtable-try-as-dyn.rs#no-debuginfo stdout ----
Saved the actual stderr to `/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/limits/vtable-try-as-dyn.no-debuginfo/vtable-try-as-dyn.no-debuginfo.stderr`
diff of stderr:

- error: values of the type `[u8; usize::MAX]` are too big for the target architecture
+ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture
+   --> $SRC_DIR/core/src/any.rs:LL:COL
+    |
+    = note: evaluation of `std::any::try_as_dyn::<[u8; usize::MAX], dyn Trait>::{constant#0}` failed inside this call
+ note: inside `TypeId::trait_info_of::<dyn Trait>`
+   --> $SRC_DIR/core/src/any.rs:LL:COL
+ note: inside `TypeId::trait_info_of_trait_type_id`
+   --> $SRC_DIR/core/src/any.rs:LL:COL
+ note: inside `type_info::<impl TypeId>::info`
+   --> $SRC_DIR/core/src/mem/type_info.rs:LL:COL
2 
+ note: the above error was encountered while instantiating `fn try_as_dyn::<[u8; usize::MAX], dyn Trait>`
+   --> $DIR/vtable-try-as-dyn.rs:14:13
+    |
+ LL |     let _ = std::any::try_as_dyn::<[u8; usize::MAX], dyn Trait>(x);
+    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ 
3 error: aborting due to 1 previous error
4 
+ For more information about this error, try `rustc --explain E0080`.
---
-   --> /rustc/FAKE_PREFIX/library/core/src/any.rs:818:27
-   --> /rustc/FAKE_PREFIX/library/core/src/any.rs:842:11
-   --> /rustc/FAKE_PREFIX/library/core/src/mem/type_info.rs:40:8
-   --> /checkout/tests/ui/limits/vtable-try-as-dyn.rs:14:13
+ error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture
+   --> $SRC_DIR/core/src/any.rs:LL:COL
+    |
+    = note: evaluation of `std::any::try_as_dyn::<[u8; usize::MAX], dyn Trait>::{constant#0}` failed inside this call
+ note: inside `TypeId::trait_info_of::<dyn Trait>`
+   --> $SRC_DIR/core/src/any.rs:LL:COL
+ note: inside `TypeId::trait_info_of_trait_type_id`
+   --> $SRC_DIR/core/src/any.rs:LL:COL
+ note: inside `type_info::<impl TypeId>::info`
+   --> $SRC_DIR/core/src/mem/type_info.rs:LL:COL
+ note: the above error was encountered while instantiating `fn try_as_dyn::<[u8; usize::MAX], dyn Trait>`
+   --> $DIR/vtable-try-as-dyn.rs:14:13
+    |
+ LL |     let _ = std::any::try_as_dyn::<[u8; usize::MAX], dyn Trait>(x);
+    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ 
+ For more information about this error, try `rustc --explain E0080`.


The actual stderr differed from the expected stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args limits/vtable-try-as-dyn.rs`

error in revision `no-debuginfo`: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/limits/vtable-try-as-dyn.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--target=aarch64-unknown-linux-gnu" "--cfg" "no_debuginfo" "--check-cfg" "cfg(test,FALSE,no_debuginfo,full_debuginfo)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/ui/limits/vtable-try-as-dyn.no-debuginfo" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Lnative=/checkout/obj/build/aarch64-unknown-linux-gnu/native/rust-test-helpers" "--crate-type=lib" "--emit=mir" "-C" "debuginfo=0"
stdout: none
--- stderr -------------------------------
error[E0080]: values of the type `[u8; usize::MAX]` are too big for the target architecture
##[error]  --> /rustc/FAKE_PREFIX/library/core/src/any.rs:1016:16
   |
   = note: evaluation of `std::any::try_as_dyn::<[u8; usize::MAX], dyn Trait>::{constant#0}` failed inside this call
note: inside `TypeId::trait_info_of::<dyn Trait>`
  --> /rustc/FAKE_PREFIX/library/core/src/any.rs:818:27
note: inside `TypeId::trait_info_of_trait_type_id`
  --> /rustc/FAKE_PREFIX/library/core/src/any.rs:842:11
note: inside `type_info::<impl TypeId>::info`
  --> /rustc/FAKE_PREFIX/library/core/src/mem/type_info.rs:40:8

note: the above error was encountered while instantiating `fn try_as_dyn::<[u8; usize::MAX], dyn Trait>`
  --> /checkout/tests/ui/limits/vtable-try-as-dyn.rs:14:13
   |
LL |     let _ = std::any::try_as_dyn::<[u8; usize::MAX], dyn Trait>(x);
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0080`.
rust-bors Avatar
rust-bors on 2026-02-19 10:14:12 UTC · hidden as outdated
rust-bors Avatar
rust-bors on 2026-02-19 10:14:12 UTC · hidden as outdated
View on GitHub

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

rustbot Avatar
rustbot on 2026-02-19 14:20:19 UTC · hidden as outdated
rustbot Avatar
rustbot on 2026-02-19 14:20:19 UTC · hidden as outdated
View on GitHub

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 Avatar
rustbot on 2026-02-19 14:20:20 UTC · hidden as resolved
rustbot Avatar
rustbot on 2026-02-19 14:20:20 UTC · hidden as resolved
View on GitHub

⚠️ Warning ⚠️

  • The following commits have merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged.

    You can start a rebase with the following commands:

    $ # rebase
    $ git pull --rebase https://github.com/rust-lang/rust.git main
    $ git push --force-with-lease
    
oli-obk Avatar
oli-obk commented on 2026-02-20 08:53:20 UTC
compiler/rustc_const_eval/src/const_eval/machine.rs · resolved
601 602 }
602 603 }
603 604
605 sym::type_id_vtable => {
oli-obk Avatar oli-obk on 2026-02-20 08:53:20 UTC
View on GitHub

move this to the intrinsics, miri will want to execute it, too

programmerjake Avatar programmerjake on 2026-02-20 09:14:56 UTC
View on GitHub

I could be wrong, but doesn't miri try to emulate runtime with extra error checking? I expect there won't be a TypeId -> vtable mapping at runtime, so miri shouldn't have one available to programs either.

9SonSteroids Avatar 9SonSteroids on 2026-02-20 09:31:43 UTC · edited
View on GitHub

I think we need this here in the machine to execute the code

programmerjake Avatar programmerjake on 2026-02-20 10:04:02 UTC
View on GitHub

yeah, I'm advocating for having this in const_eval and not in miri. (though I'm not very familiar with const_eval or miri's internals, so I could easily be wrong)

oli-obk Avatar oli-obk on 2026-02-21 21:34:20 UTC
View on GitHub

yes, I had a brainfart here. You're both correct, this intrinsic is only ever executed in const code

oli-obk Avatar
oli-obk commented on 2026-02-20 08:56:29 UTC
library/core/src/mem/type_info.rs · resolved
18 20
21 /// Info of a trait implementation, you can retrieve the vtable with [Self::get_vtable]
22 #[derive(Debug, PartialEq, Eq)]
23 pub struct TraitImpl<T: PointeeSized> {
oli-obk Avatar oli-obk on 2026-02-20 08:56:29 UTC
View on GitHub

make it unstable, too

also, do you think we'll add more information here? if so, make it non-exhaustive, if not, remove it and just retunr DynMetadata in all places it is used

9SonSteroids Avatar 9SonSteroids on 2026-02-20 09:49:41 UTC
View on GitHub

Ok, I made it non_exhaustive

rustbot Avatar
rustbot on 2026-02-20 09:16:58 UTC
rustbot Avatar
rustbot on 2026-02-20 09:16:58 UTC
View on GitHub

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.

oli-obk Avatar
oli-obk on 2026-02-21 21:35:12 UTC
oli-obk Avatar
oli-obk on 2026-02-21 21:35:12 UTC
View on GitHub

@bors r+ rollup

rust-bors Avatar
rust-bors on 2026-02-21 21:35:15 UTC
rust-bors Avatar
rust-bors on 2026-02-21 21:35:15 UTC
View on GitHub

📌 Commit b865873 has been approved by oli-obk

It is now in the queue for this repository.

oli-obk Avatar
oli-obk on 2026-02-21 21:35:41 UTC
oli-obk Avatar
oli-obk on 2026-02-21 21:35:41 UTC
View on GitHub

@bors r- there was still an unresolved comment

oli-obk Avatar
oli-obk on 2026-02-23 08:21:20 UTC
oli-obk Avatar
oli-obk on 2026-02-23 08:21:20 UTC
View on GitHub

@bors r+

🎉1
rust-bors Avatar
rust-bors on 2026-02-23 08:21:22 UTC
rust-bors Avatar
rust-bors on 2026-02-23 08:21:22 UTC
View on GitHub

📌 Commit 04e9918 has been approved by oli-obk

It is now in the queue for this repository.