Skip to content

expr.rs index out of bounds: the len is 0 but the index is 0 #123442

Closed
@Naserume

Description

@Naserume

Code

(reduced)

extern crate issue_15562;

fn main() {
    {
        transmute();
    }
}
extern "rust-intrinsic" fn transmute() {}

(original)

//@ run-pass
//@ aux-build:issue-15562.rs

//@ pretty-expanded FIXME #23616

extern crate issue_15562 as i;

pub fn main() {
    unsafe {
        transmute();
        i::transmute();
    }
}

// We declare this so we don't run into unresolved symbol errors
// The above extern is NOT `extern "rust-intrinsic"` and thus
// means it'll try to find a corresponding symbol to link to.
#[no_mangle]
pub unsafe extern "rust-intrinsic" fn transmute() {}

Meta

rustc --version --verbose:

rustc 1.79.0-nightly (4fd4797c2 2024-04-03)
binary: rustc
commit-hash: 4fd4797c2654977f545c9a91e2aa4e6cdbb38919
commit-date: 2024-04-03
host: x86_64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.2

Error output

error[E0463]: can't find crate for `issue_15562`
 --> ./CF20DE9D60924DCBAD5950D10D572176B7F7ED570B099E173A86F64C0AAB2C6A.rs:1:1
  |
1 | extern crate issue_15562;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate

error[E0658]: intrinsics are subject to change
 --> ./CF20DE9D60924DCBAD5950D10D572176B7F7ED570B099E173A86F64C0AAB2C6A.rs:8:8
  |
8 | extern "rust-intrinsic" fn transmute() {}
  |        ^^^^^^^^^^^^^^^^
  |
  = help: add `#![feature(intrinsics)]` to the crate attributes to enable
  = note: this compiler was built on 2024-04-03; consider upgrading it if it is out of date

error[E0094]: intrinsic has wrong number of type parameters: found 0, expected 2
 --> ./CF20DE9D60924DCBAD5950D10D572176B7F7ED570B099E173A86F64C0AAB2C6A.rs:8:37
  |
8 | extern "rust-intrinsic" fn transmute() {}
  |                                     ^ expected 2 type parameters
Backtrace

thread 'rustc' panicked at compiler/rustc_hir_typeck/src/expr.rs:550:28:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0:        0x10e092797 - std::backtrace::Backtrace::create::hde801799bfcf1a18
   1:        0x10e0926e5 - std::backtrace::Backtrace::force_capture::h19ae693dac8964df
   2:        0x116c3dcfb - std[38e870d6de0dab70]::panicking::update_hook::<alloc[43ccfcebb6346d8b]::boxed::Box<rustc_driver_impl[b21b79e6d003739c]::install_ice_hook::{closure#0}>>::{closure#0}
   3:        0x10e0ac564 - std::panicking::rust_panic_with_hook::h980ef0202c45a742
   4:        0x10e0abea4 - std::panicking::begin_panic_handler::{{closure}}::h6974c7b825f3e848
   5:        0x10e0a9379 - std::sys_common::backtrace::__rust_end_short_backtrace::h8e1c545181895940
   6:        0x10e0abbd6 - _rust_begin_unwind
   7:        0x10e111355 - core::panicking::panic_fmt::h47e8c306b2b8d99c
   8:        0x10e111556 - core::panicking::panic_bounds_check::h7de25c62010f13eb
   9:        0x1170bb209 - <rustc_hir_typeck[b79567a4313f5def]::fn_ctxt::FnCtxt>::check_expr_path
  10:        0x1170b951f - <rustc_hir_typeck[b79567a4313f5def]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  11:        0x117098eb6 - <rustc_hir_typeck[b79567a4313f5def]::fn_ctxt::FnCtxt>::check_call
  12:        0x117196e29 - <rustc_hir_typeck[b79567a4313f5def]::fn_ctxt::FnCtxt>::check_expr_kind
  13:        0x1170b95db - <rustc_hir_typeck[b79567a4313f5def]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  14:        0x1170f05c6 - <rustc_hir_typeck[b79567a4313f5def]::fn_ctxt::FnCtxt>::check_stmt
  15:        0x1170f0dac - <rustc_hir_typeck[b79567a4313f5def]::fn_ctxt::FnCtxt>::check_block_with_expected
  16:        0x1170b95db - <rustc_hir_typeck[b79567a4313f5def]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  17:        0x1170f0dea - <rustc_hir_typeck[b79567a4313f5def]::fn_ctxt::FnCtxt>::check_block_with_expected
  18:        0x1170b95db - <rustc_hir_typeck[b79567a4313f5def]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  19:        0x1170bb595 - <rustc_hir_typeck[b79567a4313f5def]::fn_ctxt::FnCtxt>::check_return_expr
  20:        0x11718103e - rustc_hir_typeck[b79567a4313f5def]::check::check_fn
  21:        0x1171777e9 - rustc_hir_typeck[b79567a4313f5def]::typeck
  22:        0x11806c11a - rustc_query_impl[3605ca4bc1475aca]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3605ca4bc1475aca]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[292fdd7a6f274851]::query::erase::Erased<[u8; 8usize]>>
  23:        0x117eef00c - rustc_query_system[854611ef8e5fc0a7]::query::plumbing::try_execute_query::<rustc_query_impl[3605ca4bc1475aca]::DynamicConfig<rustc_query_system[854611ef8e5fc0a7]::query::caches::VecCache<rustc_hir[9efa7d06bb4f22]::hir_id::OwnerId, rustc_middle[292fdd7a6f274851]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[3605ca4bc1475aca]::plumbing::QueryCtxt, false>
  24:        0x11808ef1b - rustc_query_impl[3605ca4bc1475aca]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  25:        0x116e7a3e7 - <rustc_middle[292fdd7a6f274851]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[76877c2d5917afe]::check_crate::{closure#4}>::{closure#0}
  26:        0x116f8200c - rustc_hir_analysis[76877c2d5917afe]::check_crate
  27:        0x1173e8470 - rustc_interface[9070b66c4f6dc5ef]::passes::analysis
  28:        0x11806c16a - rustc_query_impl[3605ca4bc1475aca]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[3605ca4bc1475aca]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[292fdd7a6f274851]::query::erase::Erased<[u8; 1usize]>>
  29:        0x117e56b6e - rustc_query_system[854611ef8e5fc0a7]::query::plumbing::try_execute_query::<rustc_query_impl[3605ca4bc1475aca]::DynamicConfig<rustc_query_system[854611ef8e5fc0a7]::query::caches::SingleCache<rustc_middle[292fdd7a6f274851]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[3605ca4bc1475aca]::plumbing::QueryCtxt, false>
  30:        0x118076537 - rustc_query_impl[3605ca4bc1475aca]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  31:        0x116bee547 - <rustc_interface[9070b66c4f6dc5ef]::queries::QueryResult<&rustc_middle[292fdd7a6f274851]::ty::context::GlobalCtxt>>::enter::<core[14fbfc68cf988ae3]::result::Result<(), rustc_span[c77fbea70134c538]::ErrorGuaranteed>, rustc_driver_impl[b21b79e6d003739c]::run_compiler::{closure#0}::{closure#1}::{closure#3}>
  32:        0x116c44d1f - rustc_interface[9070b66c4f6dc5ef]::interface::run_compiler::<core[14fbfc68cf988ae3]::result::Result<(), rustc_span[c77fbea70134c538]::ErrorGuaranteed>, rustc_driver_impl[b21b79e6d003739c]::run_compiler::{closure#0}>::{closure#0}
  33:        0x116c37cad - std[38e870d6de0dab70]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[9070b66c4f6dc5ef]::util::run_in_thread_with_globals<rustc_interface[9070b66c4f6dc5ef]::util::run_in_thread_pool_with_globals<rustc_interface[9070b66c4f6dc5ef]::interface::run_compiler<core[14fbfc68cf988ae3]::result::Result<(), rustc_span[c77fbea70134c538]::ErrorGuaranteed>, rustc_driver_impl[b21b79e6d003739c]::run_compiler::{closure#0}>::{closure#0}, core[14fbfc68cf988ae3]::result::Result<(), rustc_span[c77fbea70134c538]::ErrorGuaranteed>>::{closure#0}, core[14fbfc68cf988ae3]::result::Result<(), rustc_span[c77fbea70134c538]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[14fbfc68cf988ae3]::result::Result<(), rustc_span[c77fbea70134c538]::ErrorGuaranteed>>
  34:        0x116c4ab7f - <<std[38e870d6de0dab70]::thread::Builder>::spawn_unchecked_<rustc_interface[9070b66c4f6dc5ef]::util::run_in_thread_with_globals<rustc_interface[9070b66c4f6dc5ef]::util::run_in_thread_pool_with_globals<rustc_interface[9070b66c4f6dc5ef]::interface::run_compiler<core[14fbfc68cf988ae3]::result::Result<(), rustc_span[c77fbea70134c538]::ErrorGuaranteed>, rustc_driver_impl[b21b79e6d003739c]::run_compiler::{closure#0}>::{closure#0}, core[14fbfc68cf988ae3]::result::Result<(), rustc_span[c77fbea70134c538]::ErrorGuaranteed>>::{closure#0}, core[14fbfc68cf988ae3]::result::Result<(), rustc_span[c77fbea70134c538]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[14fbfc68cf988ae3]::result::Result<(), rustc_span[c77fbea70134c538]::ErrorGuaranteed>>::{closure#1} as core[14fbfc68cf988ae3]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  35:        0x10e0b574b - std::sys::pal::unix::thread::Thread::new::thread_start::hb7c71ee179e441c0
  36:     0x7ff818270202 - __pthread_start


rustc version: 1.79.0-nightly (4fd4797c2 2024-04-03)
platform: x86_64-apple-darwin

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

Metadata

Metadata

Assignees

Labels

A-intrinsicsArea: IntrinsicsC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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