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: panicked at 'index out of bounds: the len is 2 but the index is 2', compiler/rustc_mir/src/borrow_check/type_check/input_output.rs:76:32 #83499

Closed
chengniansun opened this issue Mar 25, 2021 · 5 comments · Fixed by #83535
Assignees
Labels
A-async-await Area: Async & Await A-borrow-checker Area: The borrow checker AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-low Low priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@chengniansun
Copy link

chengniansun commented Mar 25, 2021

Code

async fn multiple_named_lifetimes<'a, 'b>(_: u8, ...) {}

Meta

rustc --version --verbose:

rustc 1.53.0-nightly (07e0e2ec2 2021-03-24)
binary: rustc
commit-hash: 07e0e2ec268c140e607e1ac7f49f145612d0f597
commit-date: 2021-03-24
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

Error output

error[E0670]: `async fn` is not permitted in Rust 2015
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | async fn multiple_named_lifetimes<'a, 'b>(_: u8, ...) {}
  | ^^^^^ to use `async fn`, switch to Rust 2018 or later
  |
  = help: set `edition = "2018"` in `Cargo.toml`
  = note: for more on editions, read https://doc.rust-lang.org/edition-guide

error: only foreign or `unsafe extern "C" functions may be C-variadic
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:50
  |
1 | async fn multiple_named_lifetimes<'a, 'b>(_: u8, ...) {}
  |                                                  ^^^

error[E0658]: C-variadic functions are unstable
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | async fn multiple_named_lifetimes<'a, 'b>(_: u8, ...) {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #44930 <https://github.com/rust-lang/rust/issues/44930> for more information
  = help: add `#![feature(c_variadic)]` to the crate attributes to enable

error[E0601]: `main` function not found in crate `perses_node_priority_with_dfs_delta_reduced_mutant`
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | async fn multiple_named_lifetimes<'a, 'b>(_: u8, ...) {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ consider adding a `main` function to `perses_node_priority_with_dfs_delta_reduced_mutant.rs`

error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:55
  |
1 | async fn multiple_named_lifetimes<'a, 'b>(_: u8, ...) {}
  |                                                       ^
  |
note: hidden type `impl Future` captures lifetime smaller than the function body
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:55
  |
1 | async fn multiple_named_lifetimes<'a, 'b>(_: u8, ...) {}
  |                                                       ^

thread 'rustc' panicked at 'index out of bounds: the len is 2 but the index is 2', compiler/rustc_mir/src/borrow_check/type_check/input_output.rs:76:32
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: 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.53.0-nightly (07e0e2ec2 2021-03-24) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_borrowck] borrow-checking `multiple_named_lifetimes`
#1 [type_of] computing type of `multiple_named_lifetimes::{opaque#0}`
end of query stack
error: aborting due to 5 previous errors

Some errors have detailed explanations: E0601, E0658, E0670, E0700.
For more information about an error, try `rustc --explain E0601`.
Backtrace

error[E0670]: `async fn` is not permitted in Rust 2015
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | async fn multiple_named_lifetimes<'a, 'b>(_: u8, ...) {}
  | ^^^^^ to use `async fn`, switch to Rust 2018 or later
  |
  = help: set `edition = "2018"` in `Cargo.toml`
  = note: for more on editions, read https://doc.rust-lang.org/edition-guide

error: only foreign or `unsafe extern "C" functions may be C-variadic
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:50
  |
1 | async fn multiple_named_lifetimes<'a, 'b>(_: u8, ...) {}
  |                                                  ^^^

error[E0658]: C-variadic functions are unstable
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | async fn multiple_named_lifetimes<'a, 'b>(_: u8, ...) {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #44930 <https://github.com/rust-lang/rust/issues/44930> for more information
  = help: add `#![feature(c_variadic)]` to the crate attributes to enable

error[E0601]: `main` function not found in crate `perses_node_priority_with_dfs_delta_reduced_mutant`
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | async fn multiple_named_lifetimes<'a, 'b>(_: u8, ...) {}
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ consider adding a `main` function to `perses_node_priority_with_dfs_delta_reduced_mutant.rs`

error[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:55
  |
1 | async fn multiple_named_lifetimes<'a, 'b>(_: u8, ...) {}
  |                                                       ^
  |
note: hidden type `impl Future` captures lifetime smaller than the function body
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:55
  |
1 | async fn multiple_named_lifetimes<'a, 'b>(_: u8, ...) {}
  |                                                       ^

thread 'rustc' panicked at 'index out of bounds: the len is 2 but the index is 2', compiler/rustc_mir/src/borrow_check/type_check/input_output.rs:76:32
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/core/src/panicking.rs:92:14
   2: core::panicking::panic_bounds_check
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/core/src/panicking.rs:69:5
   3: rustc_mir::borrow_check::type_check::type_check
   4: rustc_mir::borrow_check::nll::compute_regions
   5: rustc_mir::borrow_check::do_mir_borrowck
   6: rustc_infer::infer::InferCtxtBuilder::enter
   7: rustc_mir::borrow_check::mir_borrowck
   8: core::ops::function::FnOnce::call_once
   9: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  10: rustc_query_system::query::plumbing::force_query_with_job
  11: rustc_query_system::query::plumbing::get_query_impl
  12: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
  13: rustc_typeck::collect::type_of::type_of
  14: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  15: rustc_data_structures::stack::ensure_sufficient_stack
  16: rustc_query_system::query::plumbing::force_query_with_job
  17: rustc_query_system::query::plumbing::get_query_impl
  18: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::type_of
  19: rustc_typeck::check::check::check_opaque
  20: rustc_typeck::check::check::check_item_type
  21: rustc_middle::hir::map::Map::visit_item_likes_in_module
  22: rustc_typeck::check::check::check_mod_item_types
  23: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  24: rustc_query_system::query::plumbing::force_query_with_job
  25: rustc_query_system::query::plumbing::get_query_impl
  26: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::check_mod_item_types
  27: rustc_session::utils::<impl rustc_session::session::Session>::time
  28: rustc_typeck::check_crate
  29: rustc_interface::passes::analysis
  30: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  31: rustc_data_structures::stack::ensure_sufficient_stack
  32: rustc_query_system::query::plumbing::force_query_with_job
  33: rustc_query_system::query::plumbing::get_query_impl
  34: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  35: rustc_interface::passes::QueryContext::enter
  36: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  37: rustc_span::with_source_map
  38: rustc_interface::interface::create_compiler_and_run
  39: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: 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.53.0-nightly (07e0e2ec2 2021-03-24) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [mir_borrowck] borrow-checking `multiple_named_lifetimes`
#1 [type_of] computing type of `multiple_named_lifetimes::{opaque#0}`
#2 [check_mod_item_types] checking item types in top-level module
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 5 previous errors

Some errors have detailed explanations: E0601, E0658, E0670, E0700.
For more information about an error, try `rustc --explain E0601`.

@chengniansun chengniansun 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 Mar 25, 2021
@jonas-schievink jonas-schievink added A-async-await Area: Async & Await A-borrow-checker Area: The borrow checker I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Mar 25, 2021
@apiraino
Copy link
Contributor

I've tried bisecting, could only pinpoint a range of merged PRs

********************************************************************************
Regression in nightly-2020-03-25
********************************************************************************
...
found 8 bors merge commits in the specified range
  commit[0] 2020-03-23UTC: Auto merge of #70330 - Centril:rollup-ts0clvx, r=Centril
  commit[1] 2020-03-23UTC: Auto merge of #70322 - matthiaskrgr:submodule_upd, r=Dylan-DPC
  commit[2] 2020-03-24UTC: Auto merge of #70343 - Centril:rollup-94egfvs, r=Centril
  commit[3] 2020-03-24UTC: Auto merge of #70351 - Centril:rollup-tveoq3w, r=Centril
  commit[4] 2020-03-24UTC: Auto merge of #69894 - vtbassmatt:master, r=nellshamrell
  commit[5] 2020-03-24UTC: Auto merge of #70163 - nikic:llvm-10-preparation, r=cuviper
  commit[6] 2020-03-24UTC: Auto merge of #70190 - pietroalbini:gha, r=Mark-Simulacrum
  commit[7] 2020-03-24UTC: Auto merge of #70371 - Centril:rollup-ywi1vo3, r=Centril
ERROR: no commits between 1edd389cc4c7b5be7a3dd4fe4b986f6017018e54 and 02046a5d402c789c006d0da7662f800fe3c45faf within last 167 days

fanninpm added a commit to fanninpm/glacier that referenced this issue Mar 26, 2021
@nikomatsakis
Copy link
Contributor

nikomatsakis commented Mar 26, 2021

Probably we just need to break out from this loop if argument_index >= body.local_decls.len():

// Equate expected input tys with those in the MIR.
for (argument_index, &normalized_input_ty) in normalized_input_tys.iter().enumerate() {
// In MIR, argument N is stored in local N+1.
let local = Local::new(argument_index + 1);
let mir_input_ty = body.local_decls[local].ty;
let mir_input_span = body.local_decls[local].source_info.span;
self.equate_normalized_input_or_output(
normalized_input_ty,
mir_input_ty,
mir_input_span,
);
}

In that case, we should include a delay_span_bug call before we break as well

@nikomatsakis nikomatsakis added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. labels Mar 26, 2021
@MidasLamb
Copy link
Contributor

@rustbot claim

@chengniansun
Copy link
Author

A duplicate.

fn foo(_: usize, ap0: VaListImpl, ...) -> impl {}

@apiraino
Copy link
Contributor

Assigning priority as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@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 Mar 31, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 1, 2021
…r=nikomatsakis

Break when there is a mismatch in the type count

When other errors are generated, there can be a mismatch between the
amount of input types in MIR, and the amount in the function itself.
Break from the comparative loop if this is the case to prevent
out-of-bounds.
Fixes rust-lang#83499
JohnTitor added a commit to JohnTitor/rust that referenced this issue Apr 2, 2021
…r=nikomatsakis

Break when there is a mismatch in the type count

When other errors are generated, there can be a mismatch between the
amount of input types in MIR, and the amount in the function itself.
Break from the comparative loop if this is the case to prevent
out-of-bounds.
Fixes rust-lang#83499
JohnTitor added a commit to JohnTitor/rust that referenced this issue Apr 2, 2021
…r=nikomatsakis

Break when there is a mismatch in the type count

When other errors are generated, there can be a mismatch between the
amount of input types in MIR, and the amount in the function itself.
Break from the comparative loop if this is the case to prevent
out-of-bounds.
Fixes rust-lang#83499
@bors bors closed this as completed in 03ba8ab Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-borrow-checker Area: The borrow checker AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-low Low priority 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