Skip to content

ICE: struct tail should have been computable, since we computed it in HIR #151308

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -Znext-solver=globally
#![feature(lazy_type_alias)]
trait Trait {
    type Associated;
}

trait Generic<T> {}

type TraitObject = dyn Generic<<i32 as Trait>::Associated>;

struct Wrap(TraitObject);

fn cast(x: *mut Wrap) {
    x as *mut Wrap;
}

original:

//@ check-pass

trait Trait {
    type Associated;
}

impl<K2> From<Vec<K2>> for <Vec<K2> as MyTrait>::Item {}

trait Generic<T> {}

type TraitObject = dyn Generic<<i32 as Trait>::Associated>;

struct Wrap(TraitObject);

fn cast(x: *mut Wrap) {
    x as *mut Wrap;
}

fn main() {}

Version information

rustc 1.95.0-nightly (621d76794 2026-01-18)
binary: rustc
commit-hash: 621d76794c76fc21c0a6151fbc090120e0230a91
commit-date: 2026-01-18
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 21.1.8

Possibly related line of code:

let structurally_normalize = |ty| {
ocx.structurally_normalize_ty(
&cause,
param_env,
ty,
)
.unwrap_or_else(|_| bug!("struct tail should have been computable, since we computed it in HIR"))
};
let tail = tcx.struct_tail_raw(
ty,
&cause,
structurally_normalize,

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(lazy_type_alias) -Znext-solver=globally

Program output

warning: the feature `lazy_type_alias` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:12
  |
1 | #![feature(lazy_type_alias)]
  |            ^^^^^^^^^^^^^^^
  |
  = note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information
  = note: `#[warn(incomplete_features)]` on by default

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.Ymn2UsCfVwpM/rustc_testrunner_tmpdir_reporting.x60PSTzhwL6s/mvce.rs:13:2
   |
13 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.Ymn2UsCfVwpM/rustc_testrunner_tmpdir_reporting.x60PSTzhwL6s/mvce.rs`

error[E0277]: the trait bound `i32: Trait` is not satisfied
 --> /tmp/icemaker_global_tempdir.Ymn2UsCfVwpM/rustc_testrunner_tmpdir_reporting.x60PSTzhwL6s/mvce.rs:7:32
  |
7 | type TraitObject = dyn Generic<<i32 as Trait>::Associated>;
  |                                ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `i32`
  |
help: this trait has no implementations, consider adding one
 --> /tmp/icemaker_global_tempdir.Ymn2UsCfVwpM/rustc_testrunner_tmpdir_reporting.x60PSTzhwL6s/mvce.rs:1:1
  |
1 | trait Trait {
  | ^^^^^^^^^^^

error[E0277]: the trait bound `i32: Trait` is not satisfied
 --> /tmp/icemaker_global_tempdir.Ymn2UsCfVwpM/rustc_testrunner_tmpdir_reporting.x60PSTzhwL6s/mvce.rs:9:13
  |
9 | struct Wrap(TraitObject);
  |             ^^^^^^^^^^^ the trait `Trait` is not implemented for `i32`
  |
help: this trait has no implementations, consider adding one
 --> /tmp/icemaker_global_tempdir.Ymn2UsCfVwpM/rustc_testrunner_tmpdir_reporting.x60PSTzhwL6s/mvce.rs:1:1
  |
1 | trait Trait {
  | ^^^^^^^^^^^

error: internal compiler error: /rustc-dev/621d76794c76fc21c0a6151fbc090120e0230a91/compiler/rustc_borrowck/src/type_check/canonical.rs:254:49: struct tail should have been computable, since we computed it in HIR


thread 'rustc' (1126879) panicked at /rustc-dev/621d76794c76fc21c0a6151fbc090120e0230a91/compiler/rustc_borrowck/src/type_check/canonical.rs:254:49:
Box<dyn Any>
stack backtrace:
   0:     0x7ff185433fd3 - <<std[287527946f71f0bc]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[7477a31a1a34cc49]::fmt::Display>::fmt
   1:     0x7ff185a0e2c8 - core[7477a31a1a34cc49]::fmt::write
   2:     0x7ff18544a9c6 - <std[287527946f71f0bc]::sys::stdio::unix::Stderr as std[287527946f71f0bc]::io::Write>::write_fmt
   3:     0x7ff18540a048 - std[287527946f71f0bc]::panicking::default_hook::{closure#0}
   4:     0x7ff185427703 - std[287527946f71f0bc]::panicking::default_hook
   5:     0x7ff1843fbb8a - std[287527946f71f0bc]::panicking::update_hook::<alloc[979041e9952e771b]::boxed::Box<rustc_driver_impl[517260a07841a630]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7ff1854279e2 - std[287527946f71f0bc]::panicking::panic_with_hook
   7:     0x7ff184438bc1 - std[287527946f71f0bc]::panicking::begin_panic::<rustc_errors[26c9ea40265c581b]::ExplicitBug>::{closure#0}
   8:     0x7ff184428fe6 - std[287527946f71f0bc]::sys::backtrace::__rust_end_short_backtrace::<std[287527946f71f0bc]::panicking::begin_panic<rustc_errors[26c9ea40265c581b]::ExplicitBug>::{closure#0}, !>
   9:     0x7ff1844264b9 - std[287527946f71f0bc]::panicking::begin_panic::<rustc_errors[26c9ea40265c581b]::ExplicitBug>
  10:     0x7ff184456901 - <rustc_errors[26c9ea40265c581b]::diagnostic::BugAbort as rustc_errors[26c9ea40265c581b]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7ff184a074f9 - rustc_middle[725063e074f29df]::util::bug::opt_span_bug_fmt::<rustc_span[851f35e07e3c2dd4]::span_encoding::Span>::{closure#0}
  12:     0x7ff184a07682 - rustc_middle[725063e074f29df]::ty::context::tls::with_opt::<rustc_middle[725063e074f29df]::util::bug::opt_span_bug_fmt<rustc_span[851f35e07e3c2dd4]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  13:     0x7ff1849f8cab - rustc_middle[725063e074f29df]::ty::context::tls::with_context_opt::<rustc_middle[725063e074f29df]::ty::context::tls::with_opt<rustc_middle[725063e074f29df]::util::bug::opt_span_bug_fmt<rustc_span[851f35e07e3c2dd4]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  14:     0x7ff181e91cc4 - rustc_middle[725063e074f29df]::util::bug::bug_fmt
  15:     0x7ff18409a5a0 - <rustc_borrowck[708d6014dfabc866]::type_check::TypeChecker>::struct_tail::<rustc_middle[725063e074f29df]::mir::Location>::{closure#0}::{closure#0}::{closure#0}
  16:     0x7ff186f33554 - <rustc_borrowck[708d6014dfabc866]::type_check::TypeChecker>::struct_tail::<rustc_middle[725063e074f29df]::mir::Location>
  17:     0x7ff186f0ace8 - <rustc_borrowck[708d6014dfabc866]::type_check::TypeChecker as rustc_middle[725063e074f29df]::mir::visit::Visitor>::visit_body
  18:     0x7ff18665f5b9 - rustc_borrowck[708d6014dfabc866]::type_check::type_check
  19:     0x7ff186b43fcb - <rustc_borrowck[708d6014dfabc866]::root_cx::BorrowCheckRootCtxt>::do_mir_borrowck
  20:     0x7ff186b3d410 - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 8usize]>>
  21:     0x7ff185b5522a - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_data_structures[e0d8483206daafa2]::vec_cache::VecCache<rustc_span[851f35e07e3c2dd4]::def_id::LocalDefId, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[b7e73caa2c2ad9a]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
  22:     0x7ff185b4bf99 - rustc_query_impl[f20b8284200e680a]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  23:     0x7ff185b4c1b7 - <rustc_middle[725063e074f29df]::ty::context::TyCtxt>::par_hir_body_owners::<rustc_interface[5c48368f5debe80d]::passes::run_required_analyses::{closure#1}::{closure#0}>::{closure#0}
  24:     0x7ff185b49c0a - rustc_interface[5c48368f5debe80d]::passes::analysis
  25:     0x7ff185b49035 - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 0usize]>>
  26:     0x7ff186ba4be3 - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_query_system[b7e73caa2c2ad9a]::query::caches::SingleCache<rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
  27:     0x7ff186ba49ce - rustc_query_impl[f20b8284200e680a]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7ff186d82c11 - <rustc_interface[5c48368f5debe80d]::passes::create_and_enter_global_ctxt<core[7477a31a1a34cc49]::option::Option<rustc_interface[5c48368f5debe80d]::queries::Linker>, rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[7477a31a1a34cc49]::ops::function::FnOnce<(&rustc_session[eb79e6d3104f29ae]::session::Session, rustc_middle[725063e074f29df]::ty::context::CurrentGcx, alloc[979041e9952e771b]::sync::Arc<rustc_data_structures[e0d8483206daafa2]::jobserver::Proxy>, &std[287527946f71f0bc]::sync::once_lock::OnceLock<rustc_middle[725063e074f29df]::ty::context::GlobalCtxt>, &rustc_data_structures[e0d8483206daafa2]::sync::worker_local::WorkerLocal<rustc_middle[725063e074f29df]::arena::Arena>, &rustc_data_structures[e0d8483206daafa2]::sync::worker_local::WorkerLocal<rustc_hir[7eac7792dedc1861]::Arena>, rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  29:     0x7ff186bf5d34 - rustc_interface[5c48368f5debe80d]::interface::run_compiler::<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}
  30:     0x7ff186b5aa3a - std[287527946f71f0bc]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5c48368f5debe80d]::util::run_in_thread_with_globals<rustc_interface[5c48368f5debe80d]::util::run_in_thread_pool_with_globals<rustc_interface[5c48368f5debe80d]::interface::run_compiler<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  31:     0x7ff186b5a7fe - <std[287527946f71f0bc]::thread::lifecycle::spawn_unchecked<rustc_interface[5c48368f5debe80d]::util::run_in_thread_with_globals<rustc_interface[5c48368f5debe80d]::util::run_in_thread_pool_with_globals<rustc_interface[5c48368f5debe80d]::interface::run_compiler<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[7477a31a1a34cc49]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7ff186b5c5c4 - <std[287527946f71f0bc]::sys::thread::unix::Thread>::new::thread_start
  33:     0x7ff18049698b - <unknown>
  34:     0x7ff18051a9cc - <unknown>
  35:                0x0 - <unknown>

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: rustc 1.95.0-nightly (621d76794 2026-01-18) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(lazy_type_alias) -Z next-solver=globally -Z dump-mir-dir=dir

query stack during panic:
#0 [mir_borrowck] borrow-checking `cast`
#1 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 4 previous errors; 1 warning emitted

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

@rustbot label +F-lazy_type_alias +WG-trait-system-refactor

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-lazy_type_alias`#![feature(lazy_type_alias)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions