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

rustc crashes when impl Iterator for X {} has a function with a return type containing Item #130198

Closed
xrdelectro opened this issue Sep 10, 2024 · 3 comments
Labels
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.

Comments

@xrdelectro
Copy link

xrdelectro commented Sep 10, 2024

Code

impl<T> Iterator for S<T> {
    fn next(&mut self) -> Option<Item> {}
}

even more minimal:

impl Iterator for S {
  fn n() -> Item {}
}

Meta

rustc --version --verbose:

rustc 1.83.0-nightly (c2f74c3f9 2024-09-09)
binary: rustc
commit-hash: c2f74c3f928aeb503f15b4e9ef5778e77f3058b8
commit-date: 2024-09-09
host: aarch64-apple-darwin
release: 1.83.0-nightly
LLVM version: 19.1.0

Error output

RUST_BACKTRACE=1 rustc --edition 2021 rustc_crash_code.rs:

thread 'rustc' panicked at compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs:244:1:
DefId(2:8887 ~ core[5321]::iter::traits::iterator::Iterator::Item) does not have a "fn_arg_names"
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: rustc_metadata::rmeta::decoder::cstore_impl::provide_extern::fn_arg_names::{closure#2}
   3: rustc_metadata::rmeta::decoder::cstore_impl::provide_extern::fn_arg_names
      [... omitted 2 frames ...]
   4: rustc_middle::query::plumbing::query_get_at::<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 16]>>>
   5: <rustc_resolve::late::LateResolutionVisitor>::try_lookup_name_relaxed
   6: <rustc_resolve::late::LateResolutionVisitor>::smart_resolve_report_errors
   7: <rustc_resolve::late::LateResolutionVisitor>::smart_resolve_path_fragment::{closure#0}
   8: <rustc_resolve::late::LateResolutionVisitor>::smart_resolve_path_fragment
   9: <rustc_resolve::late::LateResolutionVisitor>::smart_resolve_path
  10: <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_ty
  11: <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_generic_arg
  12: rustc_ast::visit::walk_generic_args::<rustc_resolve::late::LateResolutionVisitor>
  13: rustc_ast::visit::walk_path::<rustc_resolve::late::LateResolutionVisitor>
  14: <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_ty
  15: <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_fn
  16: <rustc_ast::ast::AssocItemKind as rustc_ast::visit::WalkItemKind>::walk::<rustc_resolve::late::LateResolutionVisitor>
  17: <rustc_resolve::late::LateResolutionVisitor>::resolve_impl_item
  18: <rustc_resolve::late::LateResolutionVisitor>::resolve_item
  19: <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_item
  20: <rustc_resolve::Resolver>::late_resolve_crate
  21: <rustc_session::session::Session>::time::<(), <rustc_resolve::Resolver>::resolve_crate::{closure#0}>
  22: rustc_interface::passes::resolver_for_lowering_raw
      [... omitted 2 frames ...]
  23: <rustc_middle::ty::context::GlobalCtxt>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}::{closure#3}, &rustc_data_structures::steal::Steal<(rustc_middle::ty::ResolverAstLowering, alloc::sync::Arc<rustc_ast::ast::Crate>)>>
  24: <rustc_interface::interface::Compiler>::enter::<rustc_driver_impl::run_compiler::{closure#0}::{closure#1}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_span::ErrorGuaranteed>>
  25: rustc_span::create_session_globals_then::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}, core::result::Result<(), rustc_span::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}>
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: the compiler unexpectedly panicked. this is a bug.

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 `/Users/zigmars/Documents/sandbox/comprehensive-rust/rustc-ice-2024-09-10T13_56_41-37663.txt` to your bug report

query stack during panic:
#0 [fn_arg_names] looking up function parameter names for `core::iter::traits::iterator::Iterator::Item`
#1 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack
Backtrace

<backtrace>

rustc-ice-2024-09-10T13_56_41-37663.txt

[rustc-ice-2024-09-10T13_56_41-37663.txt](https://github.com/user-attachments/files/16945965/rustc-ice-2024-09-10T13_56_41-37663.txt)
@xrdelectro xrdelectro 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 Sep 10, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 10, 2024
@xrdelectro xrdelectro changed the title rustc crashes on some (probably invalid) code rustc crashes when impl has a function/method with Item in return type Sep 10, 2024
@xrdelectro xrdelectro changed the title rustc crashes when impl has a function/method with Item in return type rustc crashes when impl Iterator for ... has a function/method with Item in return type Sep 10, 2024
@xrdelectro xrdelectro changed the title rustc crashes when impl Iterator for ... has a function/method with Item in return type rustc crashes when impl Iterator for X {} has a function with Item in return type Sep 10, 2024
@xrdelectro xrdelectro changed the title rustc crashes when impl Iterator for X {} has a function with Item in return type rustc crashes when impl Iterator for X {} has a function with a return type containing Item Sep 10, 2024
@xrdelectro
Copy link
Author

When e.g., Item -> Self::Item, it does not crash anymore.

@compiler-errors
Copy link
Member

Fixed by #130033

@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Sep 14, 2024
@fmease
Copy link
Member

fmease commented Sep 14, 2024

Duplicate of #130015

@fmease fmease marked this as a duplicate of #130015 Sep 14, 2024
@fmease fmease closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2024
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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants