Skip to content

'rustc' panicked at compiler/rustc_hir_typeck/src/method/suggest.rs:3299:28: #124868

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

Closed
Danvil opened this issue May 7, 2024 · 3 comments
Closed
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

@Danvil
Copy link
Contributor

Danvil commented May 7, 2024

Code

Sorry this is non-open source production code and I was not able to create a minimal reproducible example yet. However I can confirm that the compiler would like to display the following error message when it crashes:

error[E0599]: no method named `len` found for struct `crash::MyFoo` in the current scope
  --> XXX/src/crash.rs:55:34
   |
31 | pub struct MyFoo<'a>(ArrayView1<'a, f64>);
   | -------------------- method `len` not found for this struct
...
55 |         assert_eq!(out.dim(), (x.len(), y.len()));
   |                                  ^^^ this is an associated function, not a method
   |
   = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
note: the candidate is defined in the trait `MyTrait`
  --> furrow_planner/src/crash.rs:15:5
   |
15 |     fn len() -> usize {
   |     ^^^^^^^^^^^^^^^^^
   = help: items from traits can only be used if the trait is implemented and in scope
   = note: the following traits define an item `len`, perhaps you need to implement one of them:
           candidate #1: `XXX`
           candidate #2: `XXX`
           candidate #3: `ExactSizeIterator`
           candidate #4: `FixedInitializer`
           candidate #5: `ndarray_linalg::krylov::Orthogonalizer`
           candidate #6: `re_arrow2::array::Array`
           candidate #7: `re_arrow2::array::MutableArray`
           candidate #8: `re_arrow2::array::iterator::ArrayAccessor`
           candidate #9: `re_arrow2::array::growable::Growable`
           candidate #10: `unicode_bidi::TextSource`
           candidate #11: `nix::NixPath`
           candidate #12: `nix::sys::socket::SockaddrLike`
           candidate #13: `typenum::Len`
           candidate #14: `gimli::Reader`
           candidate #15: `object::ReadRef`
           candidate #16: `similar::DiffableStr`
           candidate #17: `ring::hkdf::KeyType`
           candidate #18: `rayon::iter::IndexedParallelIterator`
           candidate #19: `rayon::range::private::IndexedRangeInteger`
           candidate #20: `rayon::range_inclusive::private::IndexedRangeInteger`
help: use associated function syntax instead
   |
55 |         assert_eq!(out.dim(), (crash::MyFoo<'_>::len(), y.len()));
   |                                ~~~~~~~~~~~~~~~~~~~~~~~
help: one of the expressions' fields has a method of the same name
   |
55 |         assert_eq!(out.dim(), (x.0.len(), y.len()));
   |                                  ++

   0:     0x7eff7790dfab - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he8d8a3d249a948a2
   1:     0x7eff77981a40 - core::fmt::write::h4d5f6025aa566322
   2:     0x7eff778fa4fd - <unknown>
   3:     0x7eff7790dd94 - <unknown>
   4:     0x7eff7794b0aa - <unknown>
   5:     0x7eff7794ad4d - std::panicking::default_hook::h731f67f92b204ede
   6:     0x7eff78548697 - <unknown>
   7:     0x7eff7794b77a - std::panicking::rust_panic_with_hook::hbcae08ba0ccf4c11
   8:     0x7eff7790e44e - <unknown>
   9:     0x7eff7790e1c6 - <unknown>
  10:     0x7eff7794b332 - rust_begin_unwind
  11:     0x7eff778efca5 - core::panicking::panic_fmt::hef0307862026e6f9
  12:     0x7eff778efec2 - core::panicking::panic_bounds_check::h6879eeb39abdf99d
  13:     0x7eff7c036e96 - <unknown>
  14:     0x7eff7bf34f09 - <unknown>
  15:     0x7eff7bf2965e - <rustc_hir_typeck[3fa998acef9546fd]::fn_ctxt::FnCtxt>::report_no_match_method_error
  16:     0x7eff7bf6446a - <rustc_hir_typeck[3fa998acef9546fd]::fn_ctxt::FnCtxt>::report_method_error

Meta

rustc --version --verbose:

rustc 1.75.0 (82e1608df 2023-12-21) (built from a source tarball)
binary: rustc
commit-hash: 82e1608dfa6e0b5569232559e3d385fea5a93112
commit-date: 2023-12-21
host: x86_64-unknown-linux-gnu
release: 1.75.0
LLVM version: 17.0.6

Error output

thread 'rustc' panicked at compiler/rustc_hir_typeck/src/method/suggest.rs:3299:28:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x7ff33a912fab - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he8d8a3d249a948a2
   1:     0x7ff33a986a40 - core::fmt::write::h4d5f6025aa566322
   2:     0x7ff33a8ff4fd - <unknown>
   3:     0x7ff33a912d94 - <unknown>
   4:     0x7ff33a9500aa - <unknown>
   5:     0x7ff33a94fd4d - std::panicking::default_hook::h731f67f92b204ede
   6:     0x7ff33b54d697 - <unknown>
   7:     0x7ff33a95077a - std::panicking::rust_panic_with_hook::hbcae08ba0ccf4c11
   8:     0x7ff33a91344e - <unknown>
   9:     0x7ff33a9131c6 - <unknown>
  10:     0x7ff33a950332 - rust_begin_unwind
  11:     0x7ff33a8f4ca5 - core::panicking::panic_fmt::hef0307862026e6f9
  12:     0x7ff33a8f4ec2 - core::panicking::panic_bounds_check::h6879eeb39abdf99d
  13:     0x7ff33f03be96 - <unknown>
  14:     0x7ff33ef39f09 - <unknown>
  15:     0x7ff33ef2e65e - <rustc_hir_typeck[3fa998acef9546fd]::fn_ctxt::FnCtxt>::report_no_match_method_error
  16:     0x7ff33ef6946a - <rustc_hir_typeck[3fa998acef9546fd]::fn_ctxt::FnCtxt>::report_method_error
  17:     0x7ff33ef5d4e1 - <unknown>
  18:     0x7ff33eef4048 - <unknown>
  19:     0x7ff33f0964b5 - <unknown>
  20:     0x7ff33ef5e116 - <unknown>
  21:     0x7ff33eef4048 - <unknown>
  22:     0x7ff33ef0c2d0 - <unknown>
  23:     0x7ff33eee5707 - <unknown>
  24:     0x7ff33eee41aa - <rustc_hir_typeck[3fa998acef9546fd]::fn_ctxt::FnCtxt>::check_call
  25:     0x7ff33ef5c2dd - <unknown>
  26:     0x7ff33eef4048 - <unknown>
  27:     0x7ff33ef13cd2 - <rustc_hir_typeck[3fa998acef9546fd]::fn_ctxt::FnCtxt>::check_decl_initializer
  28:     0x7ff33ef13f7e - <unknown>
  29:     0x7ff33ef143c9 - <rustc_hir_typeck[3fa998acef9546fd]::fn_ctxt::FnCtxt>::check_stmt
  30:     0x7ff33ef14b69 - <unknown>
  31:     0x7ff33eef4048 - <unknown>
  32:     0x7ff33eef51e9 - <unknown>
  33:     0x7ff33f0bc217 - <unknown>
  34:     0x7ff33f0dc53c - rustc_hir_typeck[3fa998acef9546fd]::typeck
  35:     0x7ff33ffd0a6c - <unknown>
  36:     0x7ff34016e4ac - <unknown>
  37:     0x7ff34025ce4d - <unknown>
  38:     0x7ff340074166 - <unknown>
  39:     0x7ff33f22894d - <unknown>
  40:     0x7ff33f267cb9 - <unknown>
  41:     0x7ff33f1eca3e - rustc_hir_analysis[250f63beef1a4a08]::check_crate
  42:     0x7ff33b67c480 - rustc_interface[ce13348c42292bb3]::passes::analysis
  43:     0x7ff33ffd0ada - <unknown>
  44:     0x7ff34005cef8 - <unknown>
  45:     0x7ff3401f8383 - <unknown>
  46:     0x7ff340061b53 - <unknown>
  47:     0x7ff33b4de44c - <unknown>
  48:     0x7ff33b52b9a4 - <unknown>
  49:     0x7ff33b50e3de - <unknown>
  50:     0x7ff33b52ca61 - <unknown>
  51:     0x7ff33b54a590 - <unknown>
  52:     0x7ff33b516d27 - <unknown>
  53:     0x7ff33a9061f5 - <unknown>
thread 'rustc' panicked at compiler/rustc_hir_typeck/src/method/suggest.rs:3299:28:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:     0x7f503b22bfab - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he8d8a3d249a948a2
   1:     0x7f503b29fa40 - core::fmt::write::h4d5f6025aa566322
   2:     0x7f503b2184fd - <unknown>
   3:     0x7f503b22bd94 - <unknown>
   4:     0x7f503b2690aa - <unknown>
   5:     0x7f503b268d4d - std::panicking::default_hook::h731f67f92b204ede
   6:     0x7f503be66697 - <unknown>
   7:     0x7f503b26977a - std::panicking::rust_panic_with_hook::hbcae08ba0ccf4c11
   8:     0x7f503b22c44e - <unknown>
   9:     0x7f503b22c1c6 - <unknown>
  10:     0x7f503b269332 - rust_begin_unwind
  11:     0x7f503b20dca5 - core::panicking::panic_fmt::hef0307862026e6f9
  12:     0x7f503b20dec2 - core::panicking::panic_bounds_check::h6879eeb39abdf99d
  13:     0x7f503f954e96 - <unknown>
  14:     0x7f503f852f09 - <unknown>
  15:     0x7f503f84765e - <rustc_hir_typeck[3fa998acef9546fd]::fn_ctxt::FnCtxt>::report_no_match_method_error
  16:     0x7f503f88246a - <rustc_hir_typeck[3fa998acef9546fd]::fn_ctxt::FnCtxt>::report_method_error
  17:     0x7f503f8764e1 - <unknown>
  18:     0x7f503f80d048 - <unknown>
  19:     0x7f503f9af4b5 - <unknown>
  20:     0x7f503f877116 - <unknown>
  21:     0x7f503f80d048 - <unknown>
  22:     0x7f503f8252d0 - <unknown>
  23:     0x7f503f7fe707 - <unknown>
  24:     0x7f503f7fd1aa - <rustc_hir_typeck[3fa998acef9546fd]::fn_ctxt::FnCtxt>::check_call
  25:     0x7f503f8752dd - <unknown>
  26:     0x7f503f80d048 - <unknown>
  27:     0x7f503f82ccd2 - <rustc_hir_typeck[3fa998acef9546fd]::fn_ctxt::FnCtxt>::check_decl_initializer
  28:     0x7f503f82cf7e - <unknown>
  29:     0x7f503f82d3c9 - <rustc_hir_typeck[3fa998acef9546fd]::fn_ctxt::FnCtxt>::check_stmt
  30:     0x7f503f82db69 - <unknown>
  31:     0x7f503f80d048 - <unknown>
  32:     0x7f503f80e1e9 - <unknown>
  33:     0x7f503f9d5217 - <unknown>
  34:     0x7f503f9f553c - rustc_hir_typeck[3fa998acef9546fd]::typeck
  35:     0x7f50408e9a6c - <unknown>
  36:     0x7f5040a874ac - <unknown>
  37:     0x7f5040b75e4d - <unknown>
  38:     0x7f504098d166 - <unknown>
  39:     0x7f503fb4194d - <unknown>
  40:     0x7f503fb80cb9 - <unknown>
  41:     0x7f503fb05a3e - rustc_hir_analysis[250f63beef1a4a08]::check_crate
  42:     0x7f503bf95480 - rustc_interface[ce13348c42292bb3]::passes::analysis
  43:     0x7f50408e9ada - <unknown>
  44:     0x7f5040975ef8 - <unknown>
  45:     0x7f5040b11383 - <unknown>
  46:     0x7f504097ab53 - <unknown>
  47:     0x7f503bdf744c - <unknown>
  48:     0x7f503be449a4 - <unknown>
  49:     0x7f503be273de - <unknown>
  50:     0x7f503be45a61 - <unknown>
  51:     0x7f503be63590 - <unknown>
  52:     0x7f503be2fd27 - <unknown>
  53:     0x7f503b21f1f5 - <unknown>
  54:     0x7ff33a722ac3 - start_thread
                               at ./nptl/pthread_create.c:442:8
  55:     0x7ff33a7b4850 - __GI___clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  56:                0x0 - <unknown>

  54:     0x7f503b03bac3 - start_thread
                               at ./nptl/pthread_create.c:442:8
  55:     0x7f503b0cd850 - __GI___clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
  56:                0x0 - <unknown>

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: rustc 1.75.0 (82e1608df 2023-12-21) (built from a source tarball) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C opt-level=3 -C embed-bitcode=no

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [typeck] type-checking `REDACTED`
#1 [analysis] running analysis passes on this crate
end of query stack

Backtrace


@Danvil Danvil 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 May 7, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 7, 2024
@compiler-errors
Copy link
Member

Please check if this still reproduces on nightly (and run rustup update nightly). If it does, please share another stack trace since the one you shared doesn't seem to point to a relevant line for the panic.

@compiler-errors
Copy link
Member

Ah, also check stable Rust too, since you're using an old version of Rust (1.75).

@compiler-errors
Copy link
Member

Actually, I almost certainly fixed this ICE in #117848, which is only on 1.76

Given that we don't backport fixes to previous version of Rust, I encourage you to upgrade your Rust compiler or cherry-pick that PR into your local sources if that's not possible.

@compiler-errors compiler-errors closed this as not planned Won't fix, can't repro, duplicate, stale May 7, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 9, 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