Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE: missing associated_item_or_field_def_ids for DefId #135209

Closed
matthiaskrgr opened this issue Jan 7, 2025 · 4 comments · Fixed by #135222
Closed

ICE: missing associated_item_or_field_def_ids for DefId #135209

matthiaskrgr opened this issue Jan 7, 2025 · 4 comments · Fixed by #135222
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-low Low priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

auto-reduced (treereduce-rust):

fn main() {
    

    if let Some(<Map<I, F> as Iterator>::Item {_}) = foo {
    
    //
    
    //
    // where
    //
    // 'a: '0
    //
    
    
    
    (x, y)
}
    
}

original:

enum Foo {
    Bar { bar: u16 },
    Other,
}

fn main() {
    let foo = Some(Foo::Other);

    if let Some(<Map<I, F> as Iterator>::Item {_}) = foo {
    // Here we have a constraint that:
    //
    // (x, y) has type (&'0 u32, &'1 u32)
    //
    // where
    //
    // 'a: '0
    //
    // then we require that `('0 u32, &'1 u32): MultiRegionTrait<'a,
    // 'b>`, which winds up imposing a requirement that `'0 = 'a` and
    // `'1 = 'b`.
    (x, y)
}
    //~^ ERROR expected field pattern, found `_`
}

Version information

rustc 1.86.0-nightly (fb546ee09 2025-01-07)
binary: rustc
commit-hash: fb546ee09b226bc4dd4b712d35a372d923c4fa54
commit-date: 2025-01-07
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.6

Possibly related line of code:

self.crate_deps.decode(metadata)
}
}
impl<'a> CrateMetadataRef<'a> {
fn missing(self, descr: &str, id: DefIndex) -> ! {
bug!("missing `{descr}` for {:?}", self.local_def_id(id))
}
fn raw_proc_macro(self, id: DefIndex) -> &'a ProcMacro {
// DefIndex's in root.proc_macro_data have a one-to-one correspondence
// with items in 'raw_proc_macros'.
let pos = self

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

Program output

error: expected field pattern, found `_`
 --> /tmp/icemaker_global_tempdir.k0zQgENfEqOy/rustc_testrunner_tmpdir_reporting.jj69jde1HiKo/mvce.rs:6:48
  |
6 |     if let Some(<Map<I, F> as Iterator>::Item {_}) = foo {
  |                                                ^
  |
help: to omit remaining fields, use `..`
  |
6 |     if let Some(<Map<I, F> as Iterator>::Item {..}) = foo {
  |                                                ~~

error: internal compiler error: compiler/rustc_metadata/src/rmeta/decoder.rs:968:9: missing `associated_item_or_field_def_ids` for DefId(2:8878 ~ core[465b]::iter::traits::iterator::Iterator::Item)


thread 'rustc' panicked at compiler/rustc_metadata/src/rmeta/decoder.rs:968:9:
Box<dyn Any>
stack backtrace:
   0:     0x75323dae19ba - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h9bf89a0e5f11c1cf
   1:     0x75323e2135e6 - core::fmt::write::h761219e2be291c7a
   2:     0x75323f0d5991 - std::io::Write::write_fmt::h8032e22f9c3bd5b4
   3:     0x75323dae1812 - std::sys::backtrace::BacktraceLock::print::hebb5778cf40ee20f
   4:     0x75323dae3db7 - std::panicking::default_hook::{{closure}}::ha0fa1988f86f132d
   5:     0x75323dae3ba0 - std::panicking::default_hook::hc12d10b4cbb281ec
   6:     0x75323cc54a08 - std[a144ab5c1b85db5]::panicking::update_hook::<alloc[32a577d94c602890]::boxed::Box<rustc_driver_impl[c12604c6ccf9e768]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x75323dae4643 - std::panicking::rust_panic_with_hook::hf8ade0577c2f95bc
   8:     0x75323cc8cf31 - std[a144ab5c1b85db5]::panicking::begin_panic::<rustc_errors[f4fe76fe817796ae]::ExplicitBug>::{closure#0}
   9:     0x75323cc82116 - std[a144ab5c1b85db5]::sys::backtrace::__rust_end_short_backtrace::<std[a144ab5c1b85db5]::panicking::begin_panic<rustc_errors[f4fe76fe817796ae]::ExplicitBug>::{closure#0}, !>
  10:     0x75323cc82103 - std[a144ab5c1b85db5]::panicking::begin_panic::<rustc_errors[f4fe76fe817796ae]::ExplicitBug>
  11:     0x75323cc96e91 - <rustc_errors[f4fe76fe817796ae]::diagnostic::BugAbort as rustc_errors[f4fe76fe817796ae]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x75323d26b443 - rustc_middle[71fc52d0577df4e0]::util::bug::opt_span_bug_fmt::<rustc_span[80f3292a29acebce]::span_encoding::Span>::{closure#0}
  13:     0x75323d25044a - rustc_middle[71fc52d0577df4e0]::ty::context::tls::with_opt::<rustc_middle[71fc52d0577df4e0]::util::bug::opt_span_bug_fmt<rustc_span[80f3292a29acebce]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x75323d2502db - rustc_middle[71fc52d0577df4e0]::ty::context::tls::with_context_opt::<rustc_middle[71fc52d0577df4e0]::ty::context::tls::with_opt<rustc_middle[71fc52d0577df4e0]::util::bug::opt_span_bug_fmt<rustc_span[80f3292a29acebce]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x75323b37e280 - rustc_middle[71fc52d0577df4e0]::util::bug::bug_fmt
  16:     0x75323d1cf5cf - <rustc_metadata[8c5f88d146413f0b]::creader::CrateMetadataRef>::missing
  17:     0x75323e41913a - rustc_metadata[8c5f88d146413f0b]::rmeta::decoder::cstore_impl::provide_extern::associated_item_def_ids
  18:     0x75323e418ad5 - rustc_query_impl[c60017a6d5ec95c8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c60017a6d5ec95c8]::query_impl::associated_item_def_ids::dynamic_query::{closure#2}::{closure#0}, rustc_middle[71fc52d0577df4e0]::query::erase::Erased<[u8; 16usize]>>
  19:     0x75323e418a65 - <rustc_query_impl[c60017a6d5ec95c8]::query_impl::associated_item_def_ids::dynamic_query::{closure#2} as core[465b72dbeda08b19]::ops::function::FnOnce<(rustc_middle[71fc52d0577df4e0]::ty::context::TyCtxt, rustc_span[80f3292a29acebce]::def_id::DefId)>>::call_once
  20:     0x75323e416e4a - rustc_query_system[e4307e8df47736e2]::query::plumbing::try_execute_query::<rustc_query_impl[c60017a6d5ec95c8]::DynamicConfig<rustc_query_system[e4307e8df47736e2]::query::caches::DefIdCache<rustc_middle[71fc52d0577df4e0]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[c60017a6d5ec95c8]::plumbing::QueryCtxt, false>
  21:     0x75323e4168ba - rustc_query_impl[c60017a6d5ec95c8]::query_impl::associated_item_def_ids::get_query_non_incr::__rust_end_short_backtrace
  22:     0x75323e4151f7 - rustc_middle[71fc52d0577df4e0]::query::plumbing::query_get_at::<rustc_query_system[e4307e8df47736e2]::query::caches::DefIdCache<rustc_middle[71fc52d0577df4e0]::query::erase::Erased<[u8; 16usize]>>>
  23:     0x75323d70f0c4 - <rustc_resolve[31f3b70b31eadbf7]::Resolver>::field_idents
  24:     0x75323d6e9e49 - <rustc_resolve[31f3b70b31eadbf7]::late::LateResolutionVisitor>::smart_resolve_report_errors
  25:     0x75323b265a24 - <rustc_resolve[31f3b70b31eadbf7]::late::LateResolutionVisitor>::smart_resolve_path_fragment::{closure#0}
  26:     0x75323ee87946 - <rustc_resolve[31f3b70b31eadbf7]::late::LateResolutionVisitor>::smart_resolve_path_fragment
  27:     0x75323ee70fbc - <rustc_resolve[31f3b70b31eadbf7]::late::LateResolutionVisitor>::resolve_expr
  28:     0x75323ee710e1 - <rustc_resolve[31f3b70b31eadbf7]::late::LateResolutionVisitor>::resolve_expr
  29:     0x75323ee70647 - <rustc_resolve[31f3b70b31eadbf7]::late::LateResolutionVisitor>::resolve_block
  30:     0x75323ee71936 - <rustc_resolve[31f3b70b31eadbf7]::late::LateResolutionVisitor>::resolve_expr
  31:     0x75323ee70647 - <rustc_resolve[31f3b70b31eadbf7]::late::LateResolutionVisitor>::resolve_block
  32:     0x75323ee7a16a - <rustc_resolve[31f3b70b31eadbf7]::late::LateResolutionVisitor as rustc_ast[4ef52985ee0a86ba]::visit::Visitor>::visit_fn
  33:     0x75323ee91a77 - rustc_ast[4ef52985ee0a86ba]::visit::walk_item_ctxt::<rustc_resolve[31f3b70b31eadbf7]::late::LateResolutionVisitor, rustc_ast[4ef52985ee0a86ba]::ast::ItemKind>
  34:     0x75323ee9a993 - <rustc_resolve[31f3b70b31eadbf7]::late::LateResolutionVisitor as rustc_ast[4ef52985ee0a86ba]::visit::Visitor>::visit_item
  35:     0x75323f4162b5 - <rustc_resolve[31f3b70b31eadbf7]::Resolver>::resolve_crate::{closure#0}
  36:     0x75323f41227f - <rustc_resolve[31f3b70b31eadbf7]::Resolver>::resolve_crate
  37:     0x75323e734d57 - rustc_interface[26e69c7fcb6d2c01]::passes::resolver_for_lowering_raw
  38:     0x75323e733d9f - rustc_query_impl[c60017a6d5ec95c8]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[c60017a6d5ec95c8]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[71fc52d0577df4e0]::query::erase::Erased<[u8; 16usize]>>
  39:     0x75323e733d8d - <rustc_query_impl[c60017a6d5ec95c8]::query_impl::resolver_for_lowering_raw::dynamic_query::{closure#2} as core[465b72dbeda08b19]::ops::function::FnOnce<(rustc_middle[71fc52d0577df4e0]::ty::context::TyCtxt, ())>>::call_once
  40:     0x75323f1b6c36 - rustc_query_system[e4307e8df47736e2]::query::plumbing::try_execute_query::<rustc_query_impl[c60017a6d5ec95c8]::DynamicConfig<rustc_query_system[e4307e8df47736e2]::query::caches::SingleCache<rustc_middle[71fc52d0577df4e0]::query::erase::Erased<[u8; 16usize]>>, false, false, false>, rustc_query_impl[c60017a6d5ec95c8]::plumbing::QueryCtxt, false>
  41:     0x75323f1b68e0 - rustc_query_impl[c60017a6d5ec95c8]::query_impl::resolver_for_lowering_raw::get_query_non_incr::__rust_end_short_backtrace
  42:     0x75323f104265 - rustc_interface[26e69c7fcb6d2c01]::passes::create_and_enter_global_ctxt::<core[465b72dbeda08b19]::option::Option<rustc_interface[26e69c7fcb6d2c01]::queries::Linker>, rustc_driver_impl[c12604c6ccf9e768]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  43:     0x75323f177724 - rustc_interface[26e69c7fcb6d2c01]::interface::run_compiler::<(), rustc_driver_impl[c12604c6ccf9e768]::run_compiler::{closure#0}>::{closure#1}
  44:     0x75323eff8007 - std[a144ab5c1b85db5]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[26e69c7fcb6d2c01]::util::run_in_thread_with_globals<rustc_interface[26e69c7fcb6d2c01]::util::run_in_thread_pool_with_globals<rustc_interface[26e69c7fcb6d2c01]::interface::run_compiler<(), rustc_driver_impl[c12604c6ccf9e768]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  45:     0x75323eff84a4 - <<std[a144ab5c1b85db5]::thread::Builder>::spawn_unchecked_<rustc_interface[26e69c7fcb6d2c01]::util::run_in_thread_with_globals<rustc_interface[26e69c7fcb6d2c01]::util::run_in_thread_pool_with_globals<rustc_interface[26e69c7fcb6d2c01]::interface::run_compiler<(), rustc_driver_impl[c12604c6ccf9e768]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[465b72dbeda08b19]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  46:     0x75323eff9a6f - std::sys::pal::unix::thread::Thread::new::thread_start::hf3e31ce7c291fa9b
  47:     0x75323946439d - <unknown>
  48:     0x7532394e949c - <unknown>
  49:                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 (fb546ee09 2025-01-07) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [associated_item_def_ids] collecting associated items or fields of `core::iter::traits::iterator::Iterator::Item`
#1 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack
error: aborting due to 2 previous errors


@matthiaskrgr matthiaskrgr added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 7, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 7, 2025
@matthiaskrgr
Copy link
Member Author

fn main() {
	if let <Map<I, F> as Iterator>::Item {_} = _ {
		(x)
	}
}

@matthiaskrgr
Copy link
Member Author

bisection points to #134284 cc @estebank

@theemathas
Copy link
Contributor

fn main() {
    if let Iterator::Item { .. } = 1 {
        x
    }
}

@rustbot label +regression-from-stable-to-nightly

@rustbot rustbot added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jan 7, 2025
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 7, 2025
@jieyouxu jieyouxu added the S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue label Jan 7, 2025
@apiraino
Copy link
Contributor

apiraino commented Jan 7, 2025

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-low

@rustbot rustbot added P-low Low priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jan 7, 2025
@estebank estebank self-assigned this Jan 7, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 8, 2025
…errors

Ensure that we don't try to access fields on a non-struct pattern type

Fix rust-lang#135209.
@bors bors closed this as completed in 5f04f98 Jan 9, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 9, 2025
Rollup merge of rust-lang#135222 - estebank:issue-135209, r=compiler-errors

Ensure that we don't try to access fields on a non-struct pattern type

Fix rust-lang#135209.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-low Low priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants