rust-lang / rust-lang/rust

[ICE]: `ptr_metadata_ty_or_tail applied to unexpected type`

Open
#153,431 1 comment 0 reactions 1 assignee View on GitHub

@RaghavenderSingh is already working on this.

Since Mar 6, 2026.

C-bug fixed-by-next-solver I-ICE needs-triage S-has-bisection T-compiler
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

Code
trait Trait {
    type Assoc2;
}

struct Bar;
impl Trait for Bar {
    type Assoc2 = Result<(), <Bar as Trait>::Assoc2>;
}

struct Foo {
    field: <Bar as Trait>::Assoc2,
}

static BAR: u8 = 42;
static FOO2: &Foo = unsafe { std::mem::transmute(&BAR) };

fn main() {}

A mutant of tests/ui/type-alias-impl-trait/bad-transmute-itiat.rs

Meta

rustc --version --verbose:

rustc 1.96.0-nightly (b90dc1e59 2026-03-04)
binary: rustc
commit-hash: b90dc1e597db0bbc0cab0eccb39747b1a9d7e607
commit-date: 2026-03-04
host: x86_64-apple-darwin
release: 1.96.0-nightly
LLVM version: 22.1.0
Error output

Command: rustc

error[E0275]: overflow evaluating the requirement `<Bar as Trait>::Assoc2 == _`
 --> asdf.rs:7:19
  |
7 |     type Assoc2 = Result<(), <Bar as Trait>::Assoc2>;
  |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0275]: overflow evaluating the requirement `<Bar as Trait>::Assoc2 == _`
  --> asdf.rs:11:12
   |
11 |     field: <Bar as Trait>::Assoc2,
   |            ^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: /rustc-dev/b90dc1e597db0bbc0cab0eccb39747b1a9d7e607/compiler/rustc_middle/src/ty/sty.rs:1740:86: `ptr_metadata_ty_or_tail` applied to unexpected type: Foo (tail = ?1t)


thread 'rustc' (9080132) panicked at /rustc-dev/b90dc1e597db0bbc0cab0eccb39747b1a9d7e607/compiler/rustc_middle/src/ty/sty.rs:1740:86:
Box<dyn Any>
Backtrace

thread 'rustc' (9080132) panicked at /rustc-dev/b90dc1e597db0bbc0cab0eccb39747b1a9d7e607/compiler/rustc_middle/src/ty/sty.rs:1740:86:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
   3: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
   5: rustc_middle::util::bug::bug_fmt
   6: rustc_trait_selection::traits::project::confirm_builtin_candidate
   7: rustc_trait_selection::traits::project::opt_normalize_projection_term
   8: rustc_trait_selection::traits::project::normalize_projection_term
   9: rustc_traits::normalize_projection_ty::normalize_canonicalized_projection
  10: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::DefaultCache<rustc_type_ir::canonical::CanonicalQueryInput<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_type_ir::predicate::AliasTerm<rustc_middle::ty::context::TyCtxt>>>, rustc_middle::query::erase::ErasedData<[u8; 8]>>, false>
  11: <rustc_trait_selection::traits::query::normalize::QueryNormalizer>::try_fold_free_or_assoc
  12: <rustc_trait_selection::traits::query::normalize::QueryNormalizer as rustc_type_ir::fold::FallibleTypeFolder<rustc_middle::ty::context::TyCtxt>>::try_fold_ty
  13: <rustc_traits::normalize_erasing_regions::provide::{closure#0} as core::ops::function::FnOnce<(rustc_middle::ty::context::TyCtxt, rustc_middle::ty::PseudoCanonicalInput<rustc_middle::ty::generic_args::GenericArg>)>>::call_once
  14: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::DefaultCache<rustc_middle::ty::PseudoCanonicalInput<rustc_middle::ty::generic_args::GenericArg>, rustc_middle::query::erase::ErasedData<[u8; 8]>>, false>
  15: <rustc_middle::ty::normalize_erasing_regions::TryNormalizeAfterErasingRegionsFolder>::try_normalize_generic_arg_after_erasing_regions
  16: <rustc_middle::ty::context::TyCtxt>::try_normalize_erasing_regions::<rustc_middle::ty::Ty>
  17: rustc_ty_utils::layout::layout_of
      [... omitted 1 frame ...]
  18: rustc_ty_utils::layout::layout_of
      [... omitted 1 frame ...]
  19: rustc_hir_analysis::check::check::check_item_type
  20: rustc_hir_analysis::check::wfcheck::check_well_formed
      [... omitted 1 frame ...]
  21: rustc_hir_analysis::check::wfcheck::check_type_wf
      [... omitted 1 frame ...]
  22: rustc_hir_analysis::check_crate
  23: rustc_interface::passes::analysis
  24: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
  25: rustc_interface::passes::create_and_enter_global_ctxt::<core::option::Option<rustc_interface::queries::Linker>, rustc_driver_impl::run_compiler::{closure#0}::{closure#2}>
  26: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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 `/Volumes/T7/workspace/scratch_250918/rustc-ice-2026-03-05T05_18_01-87285.txt` to your bug report

note: rustc 1.96.0-nightly (b90dc1e59 2026-03-04) running on x86_64-apple-darwin

query stack during panic:
#0 [normalize_canonicalized_projection] normalizing `<Foo as core::ptr::metadata::Pointee>::Metadata`
#1 [try_normalize_generic_arg_after_erasing_regions] normalizing `<Foo as core::ptr::metadata::Pointee>::Metadata`
#2 [layout_of] computing layout of `&Foo`
#3 [layout_of] computing layout of `&'static Foo`
#4 [check_well_formed] checking that `FOO2` is well-formed
#5 [check_type_wf] checking that types are well-formed
#6 [analysis] running analysis passes on crate `asdf`
end of query stack
error: aborting due to 3 previous errors

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

Regression In

Regression in nightly-2025-07-02

Command: cargo bisect-rustc --start=2025-01-01 --end=2026-03-05 --regress ice --preserve --script rustc -- asdf.rs

Log

searched toolchains nightly-2025-01-01 through nightly-2026-03-05


********************************************************************************
Regression in nightly-2025-07-02
********************************************************************************

fetching https://static.rust-lang.org/dist/2025-07-01/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2025-07-01: 40 B / 40 B [================================================================] 100.00 % 847.05 KB/s converted 2025-07-01 to f26e58023071e71636a3c72ac3a2bf89b1f76706
fetching https://static.rust-lang.org/dist/2025-07-02/channel-rust-nightly-git-commit-hash.txt
nightly manifest 2025-07-02: 40 B / 40 B [================================================================] 100.00 % 921.52 KB/s converted 2025-07-02 to 71e4c005caa812a16fcb08d0bf1e6f1eda7c8381
looking for regression commit between 2025-07-01 and 2025-07-02
fetching (via remote github) commits from max(f26e58023071e71636a3c72ac3a2bf89b1f76706, 2025-06-29) to 71e4c005caa812a16fcb08d0bf1e6f1eda7c8381
ending github query because we found starting sha: f26e58023071e71636a3c72ac3a2bf89b1f76706
get_commits_between returning commits, len: 8
  commit[0] 2025-06-30: Auto merge of #143239 - GuillaumeGomez:subtree-update_cg_gcc_2025-06-30, r=GuillaumeGomez
  commit[1] 2025-06-30: Auto merge of #143254 - matthiaskrgr:rollup-7x8bxek, r=matthiaskrgr
  commit[2] 2025-07-01: Auto merge of #141875 - nnethercote:ByteSymbol, r=petrochenkov
  commit[3] 2025-07-01: Auto merge of #143267 - matthiaskrgr:rollup-suvzar6, r=matthiaskrgr
  commit[4] 2025-07-01: Auto merge of #142921 - JonathanBrouwer:rustc_attributes_parser, r=oli-obk
  commit[5] 2025-07-01: Auto merge of #143013 - bjorn3:split_exported_symbols, r=oli-obk
  commit[6] 2025-07-01: Auto merge of #142030 - oli-obk:wfck-less-hir, r=compiler-errors
  commit[7] 2025-07-01: Auto merge of #143287 - GuillaumeGomez:rollup-fdjcti9, r=GuillaumeGomez
ERROR: no CI builds available between f26e58023071e71636a3c72ac3a2bf89b1f76706 and 71e4c005caa812a16fcb08d0bf1e6f1eda7c8381 within last 167 days

Notes

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.