Skip to content

[ICE]: cannot call check_type_bounds on item: TraitItem(TraitItem #152797

@matthiaskrgr

Description

@matthiaskrgr

original:

#![feature(final_associated_functions)]
trait PubEnum {
    final type FooExtern;
}

fn main() {}

Version information

rustc 1.95.0-nightly (838709580 2026-02-17)
binary: rustc
commit-hash: 8387095803f21a256a9a772ac1f9b41ed4d5aa0a
commit-date: 2026-02-17
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 22.1.0

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

error: `final` is only allowed on associated functions in traits
 --> code.rs:3:5
  |
3 |     final type FooExtern;
  |     -----^^^^^^^^^^^^^^^^
  |     |
  |     `final` because of this

error: internal compiler error: /rustc-dev/8387095803f21a256a9a772ac1f9b41ed4d5aa0a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs:2386:21: cannot call `check_type_bounds` on item: TraitItem(TraitItem { ident: FooExtern#0, owner_id: DefId(0:4 ~ code[cb8f]::PubEnum::FooExtern), generics: Generics { params: [], predicates: [], has_where_clause_predicates: false, where_clause_span: code.rs:3:25: 3:25 (#0), span: code.rs:3:25: 3:25 (#0) }, kind: Type([], None), span: code.rs:3:5: 3:26 (#0), defaultness: Final, has_delayed_lints: false })
 --> code.rs:3:5
  |
3 |     final type FooExtern;
  |     ^^^^^^^^^^^^^^^^^^^^


thread 'rustc' (3106408) panicked at /rustc-dev/8387095803f21a256a9a772ac1f9b41ed4d5aa0a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs:2386:21:
Box<dyn Any>
stack backtrace:
   0:     0x7f0d145c15cb - <<std[9ed7a72950199a90]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[81c8857e8c954940]::fmt::Display>::fmt
   1:     0x7f0d14c21208 - core[81c8857e8c954940]::fmt::write
   2:     0x7f0d145d8846 - <std[9ed7a72950199a90]::sys::stdio::unix::Stderr as std[9ed7a72950199a90]::io::Write>::write_fmt
   3:     0x7f0d14597688 - std[9ed7a72950199a90]::panicking::default_hook::{closure#0}
   4:     0x7f0d145b4a33 - std[9ed7a72950199a90]::panicking::default_hook
   5:     0x7f0d1357e9ef - std[9ed7a72950199a90]::panicking::update_hook::<alloc[baed8ab89d997876]::boxed::Box<rustc_driver_impl[5db22dd92f525ab]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f0d145b4d12 - std[9ed7a72950199a90]::panicking::panic_with_hook
   7:     0x7f0d135b29e1 - std[9ed7a72950199a90]::panicking::begin_panic::<rustc_errors[5e9c1cabf743c53a]::ExplicitBug>::{closure#0}
   8:     0x7f0d135ab786 - std[9ed7a72950199a90]::sys::backtrace::__rust_end_short_backtrace::<std[9ed7a72950199a90]::panicking::begin_panic<rustc_errors[5e9c1cabf743c53a]::ExplicitBug>::{closure#0}, !>
   9:     0x7f0d135ab5fb - std[9ed7a72950199a90]::panicking::begin_panic::<rustc_errors[5e9c1cabf743c53a]::ExplicitBug>
  10:     0x7f0d135bdf71 - <rustc_errors[5e9c1cabf743c53a]::diagnostic::BugAbort as rustc_errors[5e9c1cabf743c53a]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  11:     0x7f0d13b5eb6c - <rustc_errors[5e9c1cabf743c53a]::DiagCtxtHandle>::span_bug::<rustc_span[9d095f6e85d4ed40]::span_encoding::Span, alloc[baed8ab89d997876]::string::String>
  12:     0x7f0d13b880e6 - rustc_middle[2fc1cbf9843c119b]::util::bug::opt_span_bug_fmt::<rustc_span[9d095f6e85d4ed40]::span_encoding::Span>::{closure#0}
  13:     0x7f0d13b88292 - rustc_middle[2fc1cbf9843c119b]::ty::context::tls::with_opt::<rustc_middle[2fc1cbf9843c119b]::util::bug::opt_span_bug_fmt<rustc_span[9d095f6e85d4ed40]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7f0d13b78e0b - rustc_middle[2fc1cbf9843c119b]::ty::context::tls::with_context_opt::<rustc_middle[2fc1cbf9843c119b]::ty::context::tls::with_opt<rustc_middle[2fc1cbf9843c119b]::util::bug::opt_span_bug_fmt<rustc_span[9d095f6e85d4ed40]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7f0d11f8e188 - rustc_middle[2fc1cbf9843c119b]::util::bug::span_bug_fmt::<rustc_span[9d095f6e85d4ed40]::span_encoding::Span>
  16:     0x7f0d156203cc - rustc_hir_analysis[6b3797d8ddfcab38]::check::compare_impl_item::check_type_bounds
  17:     0x7f0d155a0537 - rustc_hir_analysis[6b3797d8ddfcab38]::check::check::check_item_type
  18:     0x7f0d1559835c - rustc_hir_analysis[6b3797d8ddfcab38]::check::wfcheck::check_well_formed
  19:     0x7f0d15598335 - rustc_query_impl[86d0b9a9bed47822]::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  20:     0x7f0d15597b2c - rustc_query_impl[86d0b9a9bed47822]::execution::try_execute_query::<rustc_data_structures[6c24676c85babd96]::vec_cache::VecCache<rustc_span[9d095f6e85d4ed40]::def_id::LocalDefId, rustc_middle[2fc1cbf9843c119b]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[2fc1cbf9843c119b]::dep_graph::graph::DepNodeIndex>, {rustc_query_impl[86d0b9a9bed47822]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}, false>
  21:     0x7f0d15597896 - rustc_query_impl[86d0b9a9bed47822]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  22:     0x7f0d1559452c - rustc_hir_analysis[6b3797d8ddfcab38]::check::wfcheck::check_type_wf
  23:     0x7f0d15594429 - rustc_query_impl[86d0b9a9bed47822]::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  24:     0x7f0d15e1a813 - rustc_query_impl[86d0b9a9bed47822]::execution::try_execute_query::<rustc_middle[2fc1cbf9843c119b]::query::caches::SingleCache<rustc_middle[2fc1cbf9843c119b]::query::erase::ErasedData<[u8; 1usize]>>, {rustc_query_impl[86d0b9a9bed47822]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}, false>
  25:     0x7f0d15e1a5ce - rustc_query_impl[86d0b9a9bed47822]::query_impl::check_type_wf::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7f0d1570a3b6 - rustc_hir_analysis[6b3797d8ddfcab38]::check_crate
  27:     0x7f0d1570e456 - rustc_interface[9f0e450cc6ea9315]::passes::analysis
  28:     0x7f0d15e1b6f1 - rustc_query_impl[86d0b9a9bed47822]::execution::try_execute_query::<rustc_middle[2fc1cbf9843c119b]::query::caches::SingleCache<rustc_middle[2fc1cbf9843c119b]::query::erase::ErasedData<[u8; 0usize]>>, {rustc_query_impl[86d0b9a9bed47822]::QueryFlags { is_anon: false, is_depth_limit: false, is_feedable: false }}, false>
  29:     0x7f0d15e1b448 - rustc_query_impl[86d0b9a9bed47822]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  30:     0x7f0d15ecbca7 - <rustc_interface[9f0e450cc6ea9315]::passes::create_and_enter_global_ctxt<core[81c8857e8c954940]::option::Option<rustc_interface[9f0e450cc6ea9315]::queries::Linker>, rustc_driver_impl[5db22dd92f525ab]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[81c8857e8c954940]::ops::function::FnOnce<(&rustc_session[6f36801eff1b8bba]::session::Session, rustc_middle[2fc1cbf9843c119b]::ty::context::CurrentGcx, alloc[baed8ab89d997876]::sync::Arc<rustc_data_structures[6c24676c85babd96]::jobserver::Proxy>, &std[9ed7a72950199a90]::sync::once_lock::OnceLock<rustc_middle[2fc1cbf9843c119b]::ty::context::GlobalCtxt>, &rustc_data_structures[6c24676c85babd96]::sync::worker_local::WorkerLocal<rustc_middle[2fc1cbf9843c119b]::arena::Arena>, &rustc_data_structures[6c24676c85babd96]::sync::worker_local::WorkerLocal<rustc_hir[fe7d6d55c041f1f]::Arena>, rustc_driver_impl[5db22dd92f525ab]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  31:     0x7f0d15dd820c - rustc_interface[9f0e450cc6ea9315]::interface::run_compiler::<(), rustc_driver_impl[5db22dd92f525ab]::run_compiler::{closure#0}>::{closure#1}
  32:     0x7f0d15e0123e - std[9ed7a72950199a90]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[9f0e450cc6ea9315]::util::run_in_thread_with_globals<rustc_interface[9f0e450cc6ea9315]::util::run_in_thread_pool_with_globals<rustc_interface[9f0e450cc6ea9315]::interface::run_compiler<(), rustc_driver_impl[5db22dd92f525ab]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  33:     0x7f0d15e01920 - <std[9ed7a72950199a90]::thread::lifecycle::spawn_unchecked<rustc_interface[9f0e450cc6ea9315]::util::run_in_thread_with_globals<rustc_interface[9f0e450cc6ea9315]::util::run_in_thread_pool_with_globals<rustc_interface[9f0e450cc6ea9315]::interface::run_compiler<(), rustc_driver_impl[5db22dd92f525ab]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[81c8857e8c954940]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  34:     0x7f0d15e027ac - <std[9ed7a72950199a90]::sys::thread::unix::Thread>::new::thread_start
  35:     0x7f0d0f8a598b - <unknown>
  36:     0x7f0d0f929a0c - <unknown>
  37:                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: please attach the file at `/home/matthias/vcs/github/CRED/rustc-ice-2026-02-18T13_25_03-3106406.txt` to your bug report

note: rustc 1.95.0-nightly (838709580 2026-02-17) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [check_well_formed] checking that `PubEnum` is well-formed
#1 [check_type_wf] checking that types are well-formed
#2 [analysis] running analysis passes on crate `code`
end of query stack
error: aborting due to 2 previous errors

@rustbot label +F-final_associated_functions

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-final_associated_functions`#![feature(final_associated_functions)]`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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions