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: begin <= end (12 <= 11) when slicing 'Self::Assoc<'_>' #121807

Closed
matthiaskrgr opened this issue Feb 29, 2024 · 1 comment · Fixed by #122841
Closed

ICE: begin <= end (12 <= 11) when slicing 'Self::Assoc<'_>' #121807

matthiaskrgr opened this issue Feb 29, 2024 · 1 comment · Fixed by #122841
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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

@matthiaskrgr
Copy link
Member

snippet:

trait MemoryUnit {
    extern "C" fn read_word(&mut self) -> u8;
    extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
}

struct ROM {}

impl MemoryUnit for ROM {
    extern "C" fn read_dword(&'s self) -> u16 {
        let a16 = self.read_word() as u16;
        let b16 = self.read_word() as u16;

        (b16 << 8) | a16
    }
}

Version information

rustc 1.78.0-nightly (384d26fc7 2024-02-29)
binary: rustc
commit-hash: 384d26fc7e3bdd7687cc17b2662b091f6017ec2a
commit-date: 2024-02-29
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

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

Program output

error[E0261]: use of undeclared lifetime name `'s`
 --> /tmp/icemaker_global_tempdir.TDgy1iqr90fd/rustc_testrunner_tmpdir_reporting.nnRae760BqGM/mvce.rs:9:31
  |
9 |     extern "C" fn read_dword(&'s self) -> u16 {
  |                               ^^ undeclared lifetime
  |
help: consider introducing lifetime `'s` here
  |
9 |     extern "C" fn read_dword<'s>(&'s self) -> u16 {
  |                             ++++
help: consider introducing lifetime `'s` here
  |
8 | impl<'s> MemoryUnit for ROM {
  |     ++++

warning: anonymous parameters are deprecated and will be removed in the next edition
 --> /tmp/icemaker_global_tempdir.TDgy1iqr90fd/rustc_testrunner_tmpdir_reporting.nnRae760BqGM/mvce.rs:3:30
  |
3 |     extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
  |                              ^^^^^^^^^^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: Self::Assoc<'_>`
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
  = note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
  = note: `#[warn(anonymous_parameters)]` on by default

error[E0601]: `main` function not found in crate `mvce`
  --> /tmp/icemaker_global_tempdir.TDgy1iqr90fd/rustc_testrunner_tmpdir_reporting.nnRae760BqGM/mvce.rs:15:2
   |
15 | }
   |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.TDgy1iqr90fd/rustc_testrunner_tmpdir_reporting.nnRae760BqGM/mvce.rs`

error[E0220]: associated type `Assoc` not found for `Self`
 --> /tmp/icemaker_global_tempdir.TDgy1iqr90fd/rustc_testrunner_tmpdir_reporting.nnRae760BqGM/mvce.rs:3:36
  |
3 |     extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
  |                                    ^^^^^ associated type `Assoc` not found

error[E0185]: method `read_dword` has a `&self` declaration in the impl, but not in the trait
 --> /tmp/icemaker_global_tempdir.TDgy1iqr90fd/rustc_testrunner_tmpdir_reporting.nnRae760BqGM/mvce.rs:9:5
  |
3 |     extern "C" fn read_dword(Self::Assoc<'_>) -> u16;
  |     ------------------------------------------------- trait method declared without `&self`
...
9 |     extern "C" fn read_dword(&'s self) -> u16 {
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&self` used in impl

error[E0046]: not all trait items implemented, missing: `read_word`
 --> /tmp/icemaker_global_tempdir.TDgy1iqr90fd/rustc_testrunner_tmpdir_reporting.nnRae760BqGM/mvce.rs:8:1
  |
2 |     extern "C" fn read_word(&mut self) -> u8;
  |     ----------------------------------------- `read_word` from trait
...
8 | impl MemoryUnit for ROM {
  | ^^^^^^^^^^^^^^^^^^^^^^^ missing `read_word` in implementation

thread 'rustc' panicked at compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs:1368:48:
begin <= end (12 <= 11) when slicing `Self::Assoc<'_>`
stack backtrace:
   0:     0x7f752178cd36 - std::backtrace_rs::backtrace::libunwind::trace::h3a19003a2649a042
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f752178cd36 - std::backtrace_rs::backtrace::trace_unsynchronized::hafb8387fdb677ced
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f752178cd36 - std::sys_common::backtrace::_print_fmt::h773b2eb83e893aac
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f752178cd36 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf9c4b0aaffae0e26
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f75217ddc8c - core::fmt::rt::Argument::fmt::hd27bd8720fbe360b
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/core/src/fmt/rt.rs:142:9
   5:     0x7f75217ddc8c - core::fmt::write::h302aead198f704a5
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f752178159f - std::io::Write::write_fmt::h47ac46bdbb511a9b
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/io/mod.rs:1846:15
   7:     0x7f752178cae4 - std::sys_common::backtrace::_print::hbe00a1350460cf41
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f752178cae4 - std::sys_common::backtrace::print::hfc2bd9d3d47d4566
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f752178f81b - std::panicking::default_hook::{{closure}}::hb9ff0341655a5c73
  10:     0x7f752178f577 - std::panicking::default_hook::hf368561d0cd93e13
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/panicking.rs:292:9
  11:     0x7f75246a4a7c - std[fbb42328cecafc22]::panicking::update_hook::<alloc[c93a5f242b466a42]::boxed::Box<rustc_driver_impl[9cf1776aae3c094]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f752178ff80 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h2e1de234f5eaee61
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/alloc/src/boxed.rs:2030:9
  13:     0x7f752178ff80 - std::panicking::rust_panic_with_hook::he0aaa3480ffc94b9
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/panicking.rs:783:13
  14:     0x7f752178fcc2 - std::panicking::begin_panic_handler::{{closure}}::h8a6e565b7e092d89
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/panicking.rs:657:13
  15:     0x7f752178d216 - std::sys_common::backtrace::__rust_end_short_backtrace::h396ef3d27803de1f
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f752178f9f4 - rust_begin_unwind
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/panicking.rs:645:5
  17:     0x7f75217da1a5 - core::panicking::panic_fmt::h08e652d54c9df8f0
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/core/src/panicking.rs:72:14
  18:     0x7f75217e23b8 - core::str::slice_error_fail_rt::h2b2d3394853a6979
  19:     0x7f75217e2207 - core::str::slice_error_fail::hef6f34374c73c39c
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/core/src/str/mod.rs:91:9
  20:     0x7f75244b0753 - rustc_borrowck[f1c2b069dd61b1a9]::diagnostics::mutability_errors::suggest_ampmut_self
  21:     0x7f75244af392 - <rustc_borrowck[f1c2b069dd61b1a9]::MirBorrowckCtxt>::suggest_make_local_mut
  22:     0x7f75230ef759 - <rustc_borrowck[f1c2b069dd61b1a9]::MirBorrowckCtxt>::report_mutability_error
  23:     0x7f7526865418 - rustc_borrowck[f1c2b069dd61b1a9]::do_mir_borrowck
  24:     0x7f752681485e - rustc_borrowck[f1c2b069dd61b1a9]::mir_borrowck
  25:     0x7f7526814317 - rustc_query_impl[1640d3938b91755e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1640d3938b91755e]::query_impl::mir_borrowck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[29894b38651fd55d]::query::erase::Erased<[u8; 8usize]>>
  26:     0x7f7525baa770 - rustc_query_system[9c626cf6262cf6c2]::query::plumbing::try_execute_query::<rustc_query_impl[1640d3938b91755e]::DynamicConfig<rustc_query_system[9c626cf6262cf6c2]::query::caches::VecCache<rustc_span[e214f2a58174522b]::def_id::LocalDefId, rustc_middle[29894b38651fd55d]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[1640d3938b91755e]::plumbing::QueryCtxt, false>
  27:     0x7f7525baa34c - rustc_query_impl[1640d3938b91755e]::query_impl::mir_borrowck::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7f75266ae98c - rustc_interface[c8c0a49aa2897191]::passes::analysis
  29:     0x7f75266ae499 - rustc_query_impl[1640d3938b91755e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1640d3938b91755e]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[29894b38651fd55d]::query::erase::Erased<[u8; 1usize]>>
  30:     0x7f75267326a5 - rustc_query_system[9c626cf6262cf6c2]::query::plumbing::try_execute_query::<rustc_query_impl[1640d3938b91755e]::DynamicConfig<rustc_query_system[9c626cf6262cf6c2]::query::caches::SingleCache<rustc_middle[29894b38651fd55d]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[1640d3938b91755e]::plumbing::QueryCtxt, false>
  31:     0x7f7526732409 - rustc_query_impl[1640d3938b91755e]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  32:     0x7f7526739f3c - rustc_interface[c8c0a49aa2897191]::interface::run_compiler::<core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>, rustc_driver_impl[9cf1776aae3c094]::run_compiler::{closure#0}>::{closure#0}
  33:     0x7f75269de105 - std[fbb42328cecafc22]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[c8c0a49aa2897191]::util::run_in_thread_with_globals<rustc_interface[c8c0a49aa2897191]::util::run_in_thread_pool_with_globals<rustc_interface[c8c0a49aa2897191]::interface::run_compiler<core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>, rustc_driver_impl[9cf1776aae3c094]::run_compiler::{closure#0}>::{closure#0}, core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>>::{closure#0}, core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>>
  34:     0x7f75269ddf32 - <<std[fbb42328cecafc22]::thread::Builder>::spawn_unchecked_<rustc_interface[c8c0a49aa2897191]::util::run_in_thread_with_globals<rustc_interface[c8c0a49aa2897191]::util::run_in_thread_pool_with_globals<rustc_interface[c8c0a49aa2897191]::interface::run_compiler<core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>, rustc_driver_impl[9cf1776aae3c094]::run_compiler::{closure#0}>::{closure#0}, core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>>::{closure#0}, core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[3e98a99d3b4a7fa7]::result::Result<(), rustc_span[e214f2a58174522b]::ErrorGuaranteed>>::{closure#1} as core[3e98a99d3b4a7fa7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:     0x7f7521799955 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h1310005556baa0fc
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/alloc/src/boxed.rs:2016:9
  36:     0x7f7521799955 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h55d902c3660dd7c9
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/alloc/src/boxed.rs:2016:9
  37:     0x7f7521799955 - std::sys::pal::unix::thread::Thread::new::thread_start::h5bd490f6a8b2e778
                               at /rustc/384d26fc7e3bdd7687cc17b2662b091f6017ec2a/library/std/src/sys/pal/unix/thread.rs:108:17
  38:     0x7f752158155a - <unknown>
  39:     0x7f75215fea3c - <unknown>
  40:                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.78.0-nightly (384d26fc7 2024-02-29) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_borrowck] borrow-checking `<impl at /tmp/icemaker_global_tempdir.TDgy1iqr90fd/rustc_testrunner_tmpdir_reporting.nnRae760BqGM/mvce.rs:8:1: 8:24>::read_dword`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 5 previous errors; 1 warning emitted

Some errors have detailed explanations: E0046, E0185, E0220, E0261, E0601.
For more information about an error, try `rustc --explain E0046`.

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Feb 29, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 29, 2024
@matthiaskrgr matthiaskrgr changed the title ICE: ´begin <= end (12 <= 11) when slicing Self::Assoc<'_> ICE: ´begin <= end (12 <= 11) when slicing 'Self::Assoc<'_>'` Feb 29, 2024
@matthiaskrgr matthiaskrgr changed the title ICE: ´begin <= end (12 <= 11) when slicing 'Self::Assoc<'_>'` ICE: begin <= end (12 <= 11) when slicing 'Self::Assoc<'_>' Feb 29, 2024
@matthiaskrgr
Copy link
Member Author

#120550 cc @oli-obk

@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 29, 2024
@matthiaskrgr matthiaskrgr added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Mar 21, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 21, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 22, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 22, 2024
Rollup merge of rust-lang#122841 - matthiaskrgr:moretests, r=wesleywiser

add 2 more tests for issues fixed by rust-lang#122749

 Fixes rust-lang#121807
 Fixes rust-lang#122098
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. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. 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

Successfully merging a pull request may close this issue.

3 participants