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

Compiler panic when yielding array element from non-generator #64620

Closed
arxanas opened this issue Sep 19, 2019 · 1 comment · Fixed by #69842
Closed

Compiler panic when yielding array element from non-generator #64620

arxanas opened this issue Sep 19, 2019 · 1 comment · Fixed by #69842
Labels
A-coroutines Area: Coroutines 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. F-coroutines `#![feature(coroutines)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@arxanas
Copy link

arxanas commented Sep 19, 2019

Steps to reproduce:

  1. Run cargo new --lib crash.
  2. Replace src/lib.rs with this content:
#![feature(generators)]

pub fn crash(arr: [usize; 1]) {
    yield arr[0];
}
  1. Run RUST_BACKTRACE=full cargo +nightly build --verbose to get this output:
   Compiling crash v0.1.0 (/Users/waleedk/Workspace/rust/crash)
     Running `rustc --edition=2018 --crate-name crash src/lib.rs --color never --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 -C metadata=23cf916e5f69a1d5 -C extra-filename=-23cf916e5f69a1d5 --out-dir /Users/waleedk/Workspace/rust/crash/target/debug/deps -C incremental=/Users/waleedk/Workspace/rust/crash/target/debug/incremental -L dependency=/Users/waleedk/Workspace/rust/crash/target/debug/deps`
error[E0627]: yield statement outside of generator literal
 --> src/lib.rs:4:5
  |
4 |     yield arr[0];
  |     ^^^^^^^^^^^^

error: internal compiler error: src/librustc/ty/context.rs:513: node_type: no type for node `expr arr (hir_id=HirId { owner: DefIndex(12), local_id: 4 })`

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:643:9
stack backtrace:
   0:        0x106073185 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h407a883469cc9aea
   1:        0x1060a9e40 - core::fmt::write::h0fac5bdf1ffbd343
   2:        0x1060667db - std::io::Write::write_fmt::h29f6e9a4453f8e64
   3:        0x1060774ca - std::panicking::default_hook::{{closure}}::h514976ca44017853
   4:        0x1060771d5 - std::panicking::default_hook::h0cf5e5649c498611
   5:        0x106e23a72 - rustc_driver::report_ice::h6ba72ba240c53ce3
   6:        0x106077d02 - std::panicking::rust_panic_with_hook::hb89fa56b0e453398
   7:        0x10894e321 - std::panicking::begin_panic::hce94a994785bd80a
   8:        0x108962a11 - rustc_errors::Handler::bug::h265e236e59364186
   9:        0x10827b7eb - rustc::util::bug::opt_span_bug_fmt::{{closure}}::h1866a473633f70cb
  10:        0x108275f86 - rustc::ty::context::tls::with_opt::{{closure}}::h8e08a01f090121d8
  11:        0x108275c84 - rustc::ty::context::tls::with_context_opt::hdad39dbafc5ec58d
  12:        0x108275cb2 - rustc::ty::context::tls::with_opt::h32448c650a990704
  13:        0x10827b708 - rustc::util::bug::opt_span_bug_fmt::h7d1e0412534498f1
  14:        0x10827b65b - rustc::util::bug::bug_fmt::h15b5afa17bb8a885
  15:        0x10846a6af - rustc::ty::context::TypeckTables::node_type::{{closure}}::h5cee46e2a7fddad1
  16:        0x10846af7f - rustc::ty::context::TypeckTables::expr_ty_adjusted::h9a1a0498668f933a
  17:        0x107349b61 - <rustc_typeck::check::writeback::WritebackCx as rustc::hir::intravisit::Visitor>::visit_expr::hfabfed1d580fd434
  18:        0x107349d37 - <rustc_typeck::check::writeback::WritebackCx as rustc::hir::intravisit::Visitor>::visit_expr::hfabfed1d580fd434
  19:        0x10749985f - rustc::hir::intravisit::walk_expr::hce3981a7cb93dce2
  20:        0x107349d37 - <rustc_typeck::check::writeback::WritebackCx as rustc::hir::intravisit::Visitor>::visit_expr::hfabfed1d580fd434
  21:        0x1072ef7d7 - rustc_typeck::check::writeback::<impl rustc_typeck::check::FnCtxt>::resolve_type_vars_in_body::hc3f47a3d49d6def3
  22:        0x1074787a2 - rustc::ty::context::GlobalCtxt::enter_local::h699d9d6b520150c4
  23:        0x10731d5ac - rustc_typeck::check::typeck_tables_of::h0349fdf1b9f7c1ea
  24:        0x10736878a - rustc::ty::query::__query_compute::typeck_tables_of::he96adad9f8508347
  25:        0x1073f245b - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute::hc066a0e8be7ccc2d
  26:        0x10739e9e9 - rustc::dep_graph::graph::DepGraph::with_task_impl::hbd4ef70d845d9338
  27:        0x107415aa0 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h2ce71490153de00b
  28:        0x1073ef260 - rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners::hc4ce32a0430f92a7
  29:        0x10731d0a5 - rustc_typeck::check::typeck_item_bodies::h2b11ae34f5facd7b
  30:        0x107368b92 - rustc::ty::query::__query_compute::typeck_item_bodies::h18343492cac5f4ec
  31:        0x10739689b - rustc::dep_graph::graph::DepGraph::with_task_impl::h550c64cb66ef5c2a
  32:        0x107470ca8 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::hffc3b386c637fd84
  33:        0x10736bd65 - rustc::util::common::time::h7c6cc64b93fbb8e0
  34:        0x1075166dc - rustc_typeck::check_crate::h1976021c3c35cace
  35:        0x106ebc862 - rustc_interface::passes::analysis::h58e38d87b942506f
  36:        0x106dd024e - rustc::ty::query::__query_compute::analysis::hddfd24a5907dd9e0
  37:        0x106dd12d9 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h190aae50181d7543
  38:        0x106df116c - rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}::h5a27bf8f9540381c
  39:        0x106f2ec9b - rustc_interface::passes::create_global_ctxt::{{closure}}::h9c5444345f4c2293
  40:        0x106df3622 - rustc_interface::interface::run_compiler_in_existing_thread_pool::hfc3311be21f2f27a
  41:        0x106e255e4 - std::thread::local::LocalKey<T>::with::h188788fcd090e799
  42:        0x106e2a0e2 - scoped_tls::ScopedKey<T>::set::h999b3fc3ad485797
  43:        0x106e43235 - syntax::with_globals::h3db29ff7d66827a3
  44:        0x106dcb1fd - std::sys_common::backtrace::__rust_begin_short_backtrace::h1f76ce0ab4ce564e
  45:        0x106086faf - __rust_maybe_catch_panic
  46:        0x106de7407 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h45a83671da86e5b7
  47:        0x10605902e - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h9c2e02a877751d79
  48:        0x106085dbe - std::sys::unix::thread::Thread::new::thread_start::h48a214a3a7467592
  49:     0x7fff5d2ee2eb - _pthread_body
  50:     0x7fff5d2f1249 - _pthread_start

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.39.0-nightly (eceec57f7 2019-09-18) running on x86_64-apple-darwin

note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib

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

query stack during panic:
#0 [typeck_tables_of] processing `crash`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

error: Could not compile `crash`.

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name crash src/lib.rs --color never --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 -C metadata=23cf916e5f69a1d5 -C extra-filename=-23cf916e5f69a1d5 --out-dir /Users/waleedk/Workspace/rust/crash/target/debug/deps -C incremental=/Users/waleedk/Workspace/rust/crash/target/debug/incremental -L dependency=/Users/waleedk/Workspace/rust/crash/target/debug/deps` (exit code: 101)
@jonas-schievink jonas-schievink added A-coroutines Area: Coroutines C-bug Category: This is a bug. F-coroutines `#![feature(coroutines)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-community requires-nightly This issue requires a nightly compiler in some way. labels Sep 19, 2019
@arxanas arxanas changed the title Compiler panic when yielding array element from generator Compiler panic when yielding array element from non-generator Sep 19, 2019
@jonas-schievink jonas-schievink added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed T-community labels Sep 19, 2019
@jonas-schievink
Copy link
Contributor

No longer ICEs

@jonas-schievink jonas-schievink 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 8, 2020
Centril added a commit to Centril/rust that referenced this issue Mar 9, 2020
@bors bors closed this as completed in 7e903f8 Mar 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-coroutines Area: Coroutines 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. F-coroutines `#![feature(coroutines)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. 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.

2 participants