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 'called Option::unwrap() on a None value', compiler/rustc_middle/src/ty/sty.rs #78644

Closed
chengniansun opened this issue Nov 1, 2020 · 1 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.

Comments

@chengniansun
Copy link

Code

#![no_core]
#[lang = "sized"]
trait Sized {}
#[lang = "deref"]
trait Deref {}
fn test() {
    epriv()
}

Meta

rustc --version --verbose:

rustc 1.49.0-nightly (4f7612ac1 2020-10-31)
binary: rustc
commit-hash: 4f7612ac1499258025077f1fd05d2f429f9accfb
commit-date: 2020-10-31
host: x86_64-unknown-linux-gnu
release: 1.49.0-nightly

Error output

error[E0425]: cannot find function `epriv` in this scope
 --> reduced_mutant.rs:7:5
  |
7 |     epriv()
  |     ^^^^^ not found in this scope

error[E0658]: language items are subject to change
 --> reduced_mutant.rs:2:1
  |
2 | #[lang = "sized"]
  | ^^^^^^^^^^^^^^^^^
  |
  = help: add `#![feature(lang_items)]` to the crate attributes to enable

error[E0658]: language items are subject to change
 --> reduced_mutant.rs:4:1
  |
4 | #[lang = "deref"]
  | ^^^^^^^^^^^^^^^^^
  |
  = help: add `#![feature(lang_items)]` to the crate attributes to enable

error[E0658]: the `#[no_core]` attribute is an experimental feature
 --> reduced_mutant.rs:1:1
  |
1 | #![no_core]
  | ^^^^^^^^^^^
  |
  = note: see issue #29639 <https://github.com/rust-lang/rust/issues/29639> for more information
  = help: add `#![feature(no_core)]` to the crate attributes to enable

error[E0601]: `main` function not found in crate `reduced_mutant`
 --> reduced_mutant.rs:1:1
  |
1 | / #![no_core]
2 | | #[lang = "sized"]
3 | | trait Sized {}
4 | | #[lang = "deref"]
... |
7 | |     epriv()
8 | | }
  | |_^ consider adding a `main` function to `reduced_mutant.rs`

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_middle/src/ty/sty.rs:1142:14
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.49.0-nightly (4f7612ac1 2020-10-31) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [typeck] type-checking `test`
#1 [typeck_item_bodies] type-checking all item bodies
end of query stack
error: aborting due to 5 previous errors

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

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_middle/src/ty/sty.rs:1142:14
stack backtrace:
   0: rust_begin_unwind
             at /rustc/4f7612ac1499258025077f1fd05d2f429f9accfb/library/std/src/panicking.rs:495:5
   1: core::panicking::panic_fmt
             at /rustc/4f7612ac1499258025077f1fd05d2f429f9accfb/library/core/src/panicking.rs:92:14
   2: core::panicking::panic
             at /rustc/4f7612ac1499258025077f1fd05d2f429f9accfb/library/core/src/panicking.rs:50:5
   3: rustc_middle::ty::sty::ProjectionTy::from_ref_and_name
   4: <rustc_trait_selection::autoderef::Autoderef as core::iter::traits::iterator::Iterator>::next
   5: rustc_typeck::check::callee::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_call
   6: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
   7: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
   8: rustc_typeck::check::fn_ctxt::checks::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_block_with_expected
   9: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_kind
  10: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  11: rustc_typeck::check::expr::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::check_return_expr
  12: rustc_typeck::check::check::check_fn
  13: rustc_infer::infer::InferCtxtBuilder::enter
  14: rustc_typeck::check::typeck
  15: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck>::compute
  16: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  17: rustc_data_structures::stack::ensure_sufficient_stack
  18: rustc_query_system::query::plumbing::get_query_impl
  19: rustc_query_system::query::plumbing::ensure_query_impl
  20: rustc_typeck::check::typeck_item_bodies
  21: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_item_bodies>::compute
  22: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  23: rustc_data_structures::stack::ensure_sufficient_stack
  24: rustc_query_system::query::plumbing::get_query_impl
  25: rustc_typeck::check_crate
  26: rustc_interface::passes::analysis
  27: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  28: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  29: rustc_data_structures::stack::ensure_sufficient_stack
  30: rustc_query_system::query::plumbing::get_query_impl
  31: rustc_interface::passes::QueryContext::enter
  32: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  33: rustc_span::with_source_map
  34: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

NOTE: The bug is found by our work-in-progress compiler testing tool Kira, and the test program is reduced/minimized by Perses

@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 Nov 1, 2020
@jonas-schievink
Copy link
Contributor

This is because trait Deref {} is missing the associated Target type, so closing in favor of #9307

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

2 participants