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: compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs:130:13: no type for local variable local 0 #78653

Closed
chengniansun opened this issue Nov 2, 2020 · 2 comments · Fixed by #82245
Labels
A-coroutines Area: Coroutines C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@chengniansun
Copy link

Code

fn main() {
    yield || for _ in 0 {}
}

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[E0658]: yield syntax is experimental
 --> reduced_mutant.rs:2:5
  |
2 |     yield || for _ in 0 {}
  |     ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
  = help: add `#![feature(generators)]` to the crate attributes to enable

error[E0627]: yield expression outside of generator literal
 --> reduced_mutant.rs:2:5
  |
2 |     yield || for _ in 0 {}
  |     ^^^^^^^^^^^^^^^^^^^^^^

error: internal compiler error: compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs:130:13: no type for local variable local 0 (hir_id=HirId { owner: DefId(0:3 ~ reduced_mutant[317d]::main), local_id: 23 })
 --> reduced_mutant.rs:2:23
  |
2 |     yield || for _ in 0 {}
  |                       ^

thread 'rustc' panicked at 'Box<Any>', /rustc/4f7612ac1499258025077f1fd05d2f429f9accfb/compiler/rustc_errors/src/lib.rs:888:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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 `main`
#1 [typeck_item_bodies] type-checking all item bodies
end of query stack
error: aborting due to 3 previous errors

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

thread 'rustc' panicked at 'Box<Any>', /rustc/4f7612ac1499258025077f1fd05d2f429f9accfb/compiler/rustc_errors/src/lib.rs:888:9
stack backtrace:
   0: std::panicking::begin_panic
   1: rustc_errors::HandlerInner::span_bug
   2: rustc_errors::Handler::span_bug
   3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
   4: rustc_middle::ty::context::tls::with_opt::{{closure}}
   5: rustc_middle::ty::context::tls::with_opt
   6: rustc_middle::util::bug::opt_span_bug_fmt
   7: rustc_middle::util::bug::span_bug_fmt
   8: rustc_typeck::check::fn_ctxt::_impl::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::local_ty::{{closure}}
   9: rustc_typeck::check::fn_ctxt::_impl::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::local_ty
  10: <rustc_typeck::check::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_local
  11: rustc_hir::intravisit::walk_expr
  12: <rustc_typeck::check::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
  13: rustc_hir::intravisit::walk_expr
  14: <rustc_typeck::check::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
  15: <rustc_typeck::check::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
  16: <rustc_typeck::check::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
  17: <rustc_typeck::check::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
  18: <rustc_typeck::check::writeback::WritebackCx as rustc_hir::intravisit::Visitor>::visit_expr
  19: rustc_typeck::check::writeback::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::resolve_type_vars_in_body
  20: rustc_infer::infer::InferCtxtBuilder::enter
  21: rustc_typeck::check::typeck
  22: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck>::compute
  23: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  24: rustc_data_structures::stack::ensure_sufficient_stack
  25: rustc_query_system::query::plumbing::get_query_impl
  26: rustc_query_system::query::plumbing::ensure_query_impl
  27: rustc_typeck::check::typeck_item_bodies
  28: 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
  29: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  30: rustc_data_structures::stack::ensure_sufficient_stack
  31: rustc_query_system::query::plumbing::get_query_impl
  32: rustc_typeck::check_crate
  33: rustc_interface::passes::analysis
  34: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  35: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  36: rustc_data_structures::stack::ensure_sufficient_stack
  37: rustc_query_system::query::plumbing::get_query_impl
  38: rustc_interface::passes::QueryContext::enter
  39: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  40: rustc_span::with_source_map
  41: 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 2, 2020
@jonas-schievink jonas-schievink added A-coroutines Area: Coroutines I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Nov 2, 2020
@JohnTitor JohnTitor added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Nov 2, 2020
@JohnTitor
Copy link
Member

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

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Nov 8, 2020
@matthiaskrgr
Copy link
Member

This ICEs since 1.33
@rustbot modify labels: +regression-from-stable-to-stable

@rustbot rustbot added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Dec 20, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Feb 19, 2021
Do not ICE when evaluating locals' types of invalid `yield`

When a `yield` is outside of a generator, check its value regardless to
avoid an ICE while trying to get all locals' types in writeback.

Fix rust-lang#78653.
@bors bors closed this as completed in 3eb454a Feb 19, 2021
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. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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.

6 participants