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 rustc' panicked at expected NodeId when using if let` in combination with a boolean test #84795

Closed
ghost opened this issue May 1, 2021 · 3 comments
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

@ghost
Copy link

ghost commented May 1, 2021

Code

playground

fn main() {
    let a = Some("world");
    let b = true;
    if let Some(text) = a && b {
        println!("hello {}", text);
    }
}

Meta

rustc --version --verbose:

rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-unknown-linux-gnu
release: 1.51.0
LLVM version: 11.0.1
rustc 1.53.0-nightly (42816d6 2021-04-24) gives a reasonable error message and does not panic:
$ rustc +nightly oops.rs
error[E0658]: `let` expressions in this position are experimental
 --> oops.rs:4:8
  |
4 |     if let Some(text) = a && b {
  |        ^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
  = help: add `#![feature(let_chains)]` to the crate attributes to enable
  = help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`

error: `let` expressions are not supported here
 --> oops.rs:4:8
  |
4 |     if let Some(text) = a && b {
  |        ^^^^^^^^^^^^^^^^^^
  |
  = note: only supported directly without parentheses in conditions of `if`- and `while`-expressions, as well as in `let` chains within parentheses

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.

Error output

thread 'rustc' panicked at 'expected `NodeId` to be lowered already for res Local(
    NodeId(24),
)', compiler/rustc_ast_lowering/src/lib.rs:714:17
Backtrace

$ rustc oops.rs
error[E0658]: `let` expressions in this position are experimental
 --> oops.rs:4:8
  |
4 |     if let Some(text) = a && b {
  |        ^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information

thread 'rustc' panicked at 'expected `NodeId` to be lowered already for res Local(
    NodeId(24),
)', compiler/rustc_ast_lowering/src/lib.rs:714:17
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:435:5
   2: rustc_ast_lowering::LoweringContext::lower_node_id_generic
   3: rustc_ast_lowering::path::<impl rustc_ast_lowering::LoweringContext>::lower_qpath
   4: rustc_data_structures::stack::ensure_sufficient_stack
   5: rustc_data_structures::stack::ensure_sufficient_stack
   6: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
   7: rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_exprs
   8: rustc_data_structures::stack::ensure_sufficient_stack
   9: rustc_data_structures::stack::ensure_sufficient_stack
  10: rustc_data_structures::stack::ensure_sufficient_stack
  11: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  12: rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_exprs
  13: rustc_data_structures::stack::ensure_sufficient_stack
  14: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  15: rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_exprs
  16: rustc_data_structures::stack::ensure_sufficient_stack
  17: rustc_ast_lowering::LoweringContext::lower_stmt
  18: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  19: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  20: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  21: rustc_arena::cold_path
  22: rustc_ast_lowering::LoweringContext::lower_block
  23: rustc_data_structures::stack::ensure_sufficient_stack
  24: rustc_ast_lowering::LoweringContext::lower_stmt
  25: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  26: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  27: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  28: rustc_arena::cold_path
  29: rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_expr_if
  30: rustc_data_structures::stack::ensure_sufficient_stack
  31: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  32: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  33: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  34: rustc_arena::cold_path
  35: rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::lower_fn_body_block
  36: rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::lower_maybe_async_body
  37: rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::lower_item
  38: rustc_ast_lowering::LoweringContext::with_hir_id_owner
  39: <rustc_ast_lowering::item::ItemLowerer as rustc_ast::visit::Visitor>::visit_mod
  40: rustc_ast_lowering::lower_crate
  41: rustc_interface::passes::BoxedResolver::access::{{closure}}
  42: rustc_interface::passes::configure_and_expand::{{closure}}
  43: rustc_interface::passes::BoxedResolver::access
  44: rustc_interface::queries::Queries::lower_to_hir
  45: rustc_interface::queries::Queries::global_ctxt
  46: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  47: rustc_span::with_source_map
  48: rustc_interface::interface::create_compiler_and_run
  49: rustc_span::with_session_globals
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.51.0 (2fd73fabe 2021-03-23) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack
error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.

@ghost ghost 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 May 1, 2021
@hellow554
Copy link
Contributor

Duplicate of #82290 (comment) which has been fixed by f0637e4 so it should not occur on nightly and next stable. Can you check that please @digitalatigid

@ghost
Copy link
Author

ghost commented May 3, 2021

Beta and Nightly do not panic when compiling and instead show an appropriate error message. (rustc 1.52.0-beta.7 (9a1dfd2dc 2021-04-30) and rustc 1.53.0-nightly (42816d61e 2021-04-24))

@hellow554
Copy link
Contributor

Then you can close this issue (:

Thanks for the report!

This issue was closed.
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

1 participant