Skip to content

ICE: item_ident: no name for DefPath #136233

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

trait Foo {
    fn bar(self) -> impl Deref;
}

impl Foo<u8> for Bar {}

original:

//@ check-pass

trait Foo {
    fn bar(self) -> impl Deref<Target = impl Display + ?Sized>;
}

struct TestB {}

impl Foo<u8> for Bar {
    fn iter<F2: Foo<u8>>(self) -> impl IntFactory<u8> {
        self
    }
}

fn main() {}

Version information

rustc 1.86.0-nightly (ccc9ba5c3 2025-01-29)
binary: rustc
commit-hash: ccc9ba5c30c675824e9ca62b960830ff4a1858ea
commit-date: 2025-01-29
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7

Possibly related line of code:

/// Look up the name and span of a definition.
///
/// See [`item_name`][Self::item_name] for more information.
pub fn item_ident(self, def_id: DefId) -> Ident {
self.opt_item_ident(def_id).unwrap_or_else(|| {
bug!("item_ident: no name for {:?}", self.def_path(def_id));
})
}
pub fn opt_associated_item(self, def_id: DefId) -> Option<AssocItem> {
if let DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy = self.def_kind(def_id) {
Some(self.associated_item(def_id))

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

Program output

error[E0405]: cannot find trait `Deref` in this scope
 --> /tmp/icemaker_global_tempdir.tpSYCWflzoz7/rustc_testrunner_tmpdir_reporting.ZtlqtBy7Sriu/mvce.rs:2:26
  |
2 |     fn bar(self) -> impl Deref;
  |                          ^^^^^ not found in this scope
  |
help: consider importing this trait
  |
1 + use std::ops::Deref;
  |

error[E0412]: cannot find type `Bar` in this scope
 --> /tmp/icemaker_global_tempdir.tpSYCWflzoz7/rustc_testrunner_tmpdir_reporting.ZtlqtBy7Sriu/mvce.rs:5:18
  |
5 | impl Foo<u8> for Bar {}
  |                  ^^^ not found in this scope

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.tpSYCWflzoz7/rustc_testrunner_tmpdir_reporting.ZtlqtBy7Sriu/mvce.rs:5:24
  |
5 | impl Foo<u8> for Bar {}
  |                        ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.tpSYCWflzoz7/rustc_testrunner_tmpdir_reporting.ZtlqtBy7Sriu/mvce.rs`

error: internal compiler error: compiler/rustc_middle/src/ty/mod.rs:1604:13: item_ident: no name for DefPath { data: [DisambiguatedDefPathData { data: TypeNs("Foo"), disambiguator: 0 }, DisambiguatedDefPathData { data: TypeNs(""), disambiguator: 0 }], krate: crate0 }


thread 'rustc' panicked at compiler/rustc_middle/src/ty/mod.rs:1604:13:
Box<dyn Any>
stack backtrace:
   0:     0x7d1c5b631f00 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h0dded18c14feaf13
   1:     0x7d1c5be13926 - core::fmt::write::h89bb533d60a91336
   2:     0x7d1c5cd42f11 - std::io::Write::write_fmt::hfcd7b2ed0f29a30b
   3:     0x7d1c5b631d62 - std::sys::backtrace::BacktraceLock::print::h6e7ed109349c584a
   4:     0x7d1c5b6341e2 - std::panicking::default_hook::{{closure}}::h1bd1fcf844b904ea
   5:     0x7d1c5b63406a - std::panicking::default_hook::hde6a4f59cd7f2fbe
   6:     0x7d1c5a78ccc9 - std[22925f88b74b870]::panicking::update_hook::<alloc[8949c91926b4ca6f]::boxed::Box<rustc_driver_impl[452065a515eaef46]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7d1c5b634d23 - std::panicking::rust_panic_with_hook::hfb83061973b16bb2
   8:     0x7d1c5a7c7a51 - std[22925f88b74b870]::panicking::begin_panic::<rustc_errors[c5e313b8644cf4a8]::ExplicitBug>::{closure#0}
   9:     0x7d1c5a7bc956 - std[22925f88b74b870]::sys::backtrace::__rust_end_short_backtrace::<std[22925f88b74b870]::panicking::begin_panic<rustc_errors[c5e313b8644cf4a8]::ExplicitBug>::{closure#0}, !>
  10:     0x7d1c5a7b961d - std[22925f88b74b870]::panicking::begin_panic::<rustc_errors[c5e313b8644cf4a8]::ExplicitBug>
  11:     0x7d1c5a7d19a1 - <rustc_errors[c5e313b8644cf4a8]::diagnostic::BugAbort as rustc_errors[c5e313b8644cf4a8]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7d1c5adb4393 - rustc_middle[9e3d5fefa4c87b56]::util::bug::opt_span_bug_fmt::<rustc_span[4d56365df4b9f4cd]::span_encoding::Span>::{closure#0}
  13:     0x7d1c5ad9d2fa - rustc_middle[9e3d5fefa4c87b56]::ty::context::tls::with_opt::<rustc_middle[9e3d5fefa4c87b56]::util::bug::opt_span_bug_fmt<rustc_span[4d56365df4b9f4cd]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7d1c5ad9d18b - rustc_middle[9e3d5fefa4c87b56]::ty::context::tls::with_context_opt::<rustc_middle[9e3d5fefa4c87b56]::ty::context::tls::with_opt<rustc_middle[9e3d5fefa4c87b56]::util::bug::opt_span_bug_fmt<rustc_span[4d56365df4b9f4cd]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7d1c58c2f370 - rustc_middle[9e3d5fefa4c87b56]::util::bug::bug_fmt
  16:     0x7d1c5adb3a68 - <rustc_middle[9e3d5fefa4c87b56]::ty::context::TyCtxt>::item_ident
  17:     0x7d1c5a8fddf2 - <core[8f10ac8b24df6146]::iter::adapters::map::Map<core[8f10ac8b24df6146]::iter::adapters::filter::Filter<core[8f10ac8b24df6146]::iter::adapters::filter::Filter<core[8f10ac8b24df6146]::iter::adapters::map::Map<core[8f10ac8b24df6146]::iter::adapters::map::Map<core[8f10ac8b24df6146]::slice::iter::Iter<(rustc_span[4d56365df4b9f4cd]::symbol::Symbol, rustc_middle[9e3d5fefa4c87b56]::ty::assoc::AssocItem)>, <rustc_data_structures[1167f24449982467]::sorted_map::index_map::SortedIndexMultiMap<u32, rustc_span[4d56365df4b9f4cd]::symbol::Symbol, rustc_middle[9e3d5fefa4c87b56]::ty::assoc::AssocItem>>::iter::{closure#0}>, <rustc_middle[9e3d5fefa4c87b56]::ty::assoc::AssocItems>::in_definition_order::{closure#0}>, <rustc_hir_analysis[84f7e81ed23fbe7a]::errors::wrong_number_of_generic_args::WrongNumberOfGenericArgs>::get_unbound_associated_types::{closure#0}>, <rustc_hir_analysis[84f7e81ed23fbe7a]::errors::wrong_number_of_generic_args::WrongNumberOfGenericArgs>::get_unbound_associated_types::{closure#1}>, <rustc_hir_analysis[84f7e81ed23fbe7a]::errors::wrong_number_of_generic_args::WrongNumberOfGenericArgs>::get_unbound_associated_types::{closure#2}> as core[8f10ac8b24df6146]::iter::traits::iterator::Iterator>::next
  18:     0x7d1c5a974c4d - <rustc_hir_analysis[84f7e81ed23fbe7a]::errors::wrong_number_of_generic_args::WrongNumberOfGenericArgs>::get_unbound_associated_types
  19:     0x7d1c5a977ea2 - <rustc_hir_analysis[84f7e81ed23fbe7a]::errors::wrong_number_of_generic_args::WrongNumberOfGenericArgs as rustc_errors[c5e313b8644cf4a8]::diagnostic::Diagnostic>::into_diag
  20:     0x7d1c5c7950e4 - <dyn rustc_hir_analysis[84f7e81ed23fbe7a]::hir_ty_lowering::HirTyLowerer>::lower_generic_args_of_path::{closure#0}
  21:     0x7d1c5c7919fc - <dyn rustc_hir_analysis[84f7e81ed23fbe7a]::hir_ty_lowering::HirTyLowerer>::lower_impl_trait_ref
  22:     0x7d1c5c790b9f - rustc_hir_analysis[84f7e81ed23fbe7a]::collect::impl_trait_header
  23:     0x7d1c5c09abf4 - rustc_query_impl[bce570863d78cd1a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bce570863d78cd1a]::query_impl::impl_trait_header::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9e3d5fefa4c87b56]::query::erase::Erased<[u8; 24usize]>>
  24:     0x7d1c5c099fd4 - rustc_query_system[e21ec7efdbdb2dc0]::query::plumbing::try_execute_query::<rustc_query_impl[bce570863d78cd1a]::DynamicConfig<rustc_query_system[e21ec7efdbdb2dc0]::query::caches::DefIdCache<rustc_middle[9e3d5fefa4c87b56]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[bce570863d78cd1a]::plumbing::QueryCtxt, false>
  25:     0x7d1c5c099ca8 - rustc_query_impl[bce570863d78cd1a]::query_impl::impl_trait_header::get_query_non_incr::__rust_end_short_backtrace
  26:     0x7d1c5c4e551b - <rustc_hir_analysis[84f7e81ed23fbe7a]::collect::CollectItemTypesVisitor as rustc_hir[40ce5670f34b2cab]::intravisit::Visitor>::visit_item
  27:     0x7d1c5c4eea2d - rustc_hir_analysis[84f7e81ed23fbe7a]::check::wfcheck::check_well_formed
  28:     0x7d1c5c4ee847 - rustc_query_impl[bce570863d78cd1a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bce570863d78cd1a]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9e3d5fefa4c87b56]::query::erase::Erased<[u8; 1usize]>>
  29:     0x7d1c5c4ee2e9 - rustc_query_system[e21ec7efdbdb2dc0]::query::plumbing::try_execute_query::<rustc_query_impl[bce570863d78cd1a]::DynamicConfig<rustc_data_structures[1167f24449982467]::vec_cache::VecCache<rustc_span[4d56365df4b9f4cd]::def_id::LocalDefId, rustc_middle[9e3d5fefa4c87b56]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[e21ec7efdbdb2dc0]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[bce570863d78cd1a]::plumbing::QueryCtxt, false>
  30:     0x7d1c5c4edd46 - rustc_query_impl[bce570863d78cd1a]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  31:     0x7d1c5c4eb96c - rustc_hir_analysis[84f7e81ed23fbe7a]::check::wfcheck::check_mod_type_wf
  32:     0x7d1c5c4eb78b - rustc_query_impl[bce570863d78cd1a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bce570863d78cd1a]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9e3d5fefa4c87b56]::query::erase::Erased<[u8; 1usize]>>
  33:     0x7d1c5cd81048 - rustc_query_system[e21ec7efdbdb2dc0]::query::plumbing::try_execute_query::<rustc_query_impl[bce570863d78cd1a]::DynamicConfig<rustc_query_system[e21ec7efdbdb2dc0]::query::caches::DefaultCache<rustc_span[4d56365df4b9f4cd]::def_id::LocalModDefId, rustc_middle[9e3d5fefa4c87b56]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[bce570863d78cd1a]::plumbing::QueryCtxt, false>
  34:     0x7d1c5cd80df0 - rustc_query_impl[bce570863d78cd1a]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  35:     0x7d1c5c18d8a6 - rustc_hir_analysis[84f7e81ed23fbe7a]::check_crate
  36:     0x7d1c5c18a734 - rustc_interface[53e51c53c3977dd7]::passes::run_required_analyses
  37:     0x7d1c5cd3e61e - rustc_interface[53e51c53c3977dd7]::passes::analysis
  38:     0x7d1c5cd3e5ef - rustc_query_impl[bce570863d78cd1a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[bce570863d78cd1a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9e3d5fefa4c87b56]::query::erase::Erased<[u8; 0usize]>>
  39:     0x7d1c5cdba855 - rustc_query_system[e21ec7efdbdb2dc0]::query::plumbing::try_execute_query::<rustc_query_impl[bce570863d78cd1a]::DynamicConfig<rustc_query_system[e21ec7efdbdb2dc0]::query::caches::SingleCache<rustc_middle[9e3d5fefa4c87b56]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[bce570863d78cd1a]::plumbing::QueryCtxt, false>
  40:     0x7d1c5cdba58e - rustc_query_impl[bce570863d78cd1a]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  41:     0x7d1c5cde1e29 - rustc_interface[53e51c53c3977dd7]::passes::create_and_enter_global_ctxt::<core[8f10ac8b24df6146]::option::Option<rustc_interface[53e51c53c3977dd7]::queries::Linker>, rustc_driver_impl[452065a515eaef46]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  42:     0x7d1c5cd55258 - rustc_interface[53e51c53c3977dd7]::interface::run_compiler::<(), rustc_driver_impl[452065a515eaef46]::run_compiler::{closure#0}>::{closure#1}
  43:     0x7d1c5cc79435 - std[22925f88b74b870]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[53e51c53c3977dd7]::util::run_in_thread_with_globals<rustc_interface[53e51c53c3977dd7]::util::run_in_thread_pool_with_globals<rustc_interface[53e51c53c3977dd7]::interface::run_compiler<(), rustc_driver_impl[452065a515eaef46]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  44:     0x7d1c5cc79119 - <<std[22925f88b74b870]::thread::Builder>::spawn_unchecked_<rustc_interface[53e51c53c3977dd7]::util::run_in_thread_with_globals<rustc_interface[53e51c53c3977dd7]::util::run_in_thread_pool_with_globals<rustc_interface[53e51c53c3977dd7]::interface::run_compiler<(), rustc_driver_impl[452065a515eaef46]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[8f10ac8b24df6146]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7d1c5cc788af - std::sys::pal::unix::thread::Thread::new::thread_start::h43c274f75b89ce71
  46:     0x7d1c56ea339d - <unknown>
  47:     0x7d1c56f2849c - <unknown>
  48:                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.86.0-nightly (ccc9ba5c3 2025-01-29) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [impl_trait_header] computing trait implemented by `<impl at /tmp/icemaker_global_tempdir.tpSYCWflzoz7/rustc_testrunner_tmpdir_reporting.ZtlqtBy7Sriu/mvce.rs:5:1: 5:21>`
#1 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.tpSYCWflzoz7/rustc_testrunner_tmpdir_reporting.ZtlqtBy7Sriu/mvce.rs:5:1: 5:21>` is well-formed
#2 [check_mod_type_wf] checking that types are well-formed in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 4 previous errors

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

Metadata

Metadata

Labels

C-bugCategory: This is a bug.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