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

if-let chain on nightly: rustc panicked at expected NodeId to be lowered #82828

Closed
lloydparlee opened this issue Mar 6, 2021 · 1 comment
Closed
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

@lloydparlee
Copy link

I am new to rust, and I found this bug while trying to guess whether I could chain if-let expressions with &&. I created a smaller example that causes the panic. This appears to only panic on nightly.

For the record, I was slightly drunk when I found this bug. :)

Code

fn main() {
    let a = Some(1);
    let b = Some(2);

    if 
        let Some(x) = a &&
        let Some(y) = b
    {   
        let z = x;
    }
}

Meta

rustc --version --verbose:

--------@-----MacBook-Pro crash % rustc +nightly --version --verbose
rustc 1.52.0-nightly (9b471a3f5 2021-02-19)
binary: rustc
commit-hash: 9b471a3f5fe57e5c6e08acf665f2094422415a3d
commit-date: 2021-02-19
host: x86_64-apple-darwin
release: 1.52.0-nightly
LLVM version: 11.0.1

Error output

--------@-----MacBook-Pro src % cargo +nightly build
   Compiling crash v0.1.0 (/Users/-----/src/local/crash)
error[E0658]: `let` expressions in this position are experimental
 --> src/main.rs:6:9
  |
6 |         let Some(x) = a &&
  |         ^^^^^^^^^^^^^^^
  |
  = 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

error[E0658]: `let` expressions in this position are experimental
 --> src/main.rs:7:9
  |
7 |         let Some(y) = 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

thread 'rustc' panicked at 'expected `NodeId` to be lowered already for res Local(
    NodeId(26),
)', compiler/rustc_ast_lowering/src/lib.rs:713:17
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.52.0-nightly (9b471a3f5 2021-02-19) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

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

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

For more information about this error, try `rustc --explain E0658`.
error: could not compile `crash`

To learn more, run the command again with --verbose.

Backtrace

--------@-----MacBook-Pro crash % RUST_BACKTRACE=1 cargo +nightly build 
   Compiling crash v0.1.0 (/Users/------/src/local/crash)
error[E0658]: `let` expressions in this position are experimental
 --> src/main.rs:6:9
  |
6 |         let Some(x) = a &&
  |         ^^^^^^^^^^^^^^^
  |
  = 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

error[E0658]: `let` expressions in this position are experimental
 --> src/main.rs:7:9
  |
7 |         let Some(y) = 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

thread 'rustc' panicked at 'expected `NodeId` to be lowered already for res Local(
    NodeId(26),
)', compiler/rustc_ast_lowering/src/lib.rs:713:17
stack backtrace:
   0: _rust_begin_unwind
   1: std::panicking::begin_panic_fmt
   2: rustc_ast_lowering::LoweringContext::lower_res::{{closure}}::{{closure}}
   3: rustc_ast_lowering::LoweringContext::lower_node_id_generic
   4: rustc_ast_lowering::path::<impl rustc_ast_lowering::LoweringContext>::lower_qpath
   5: rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_expr_mut::{{closure}}
   6: rustc_data_structures::stack::ensure_sufficient_stack
   7: rustc_ast_lowering::LoweringContext::lower_stmt
   8: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
   9: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  10: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  11: rustc_arena::cold_path
  12: rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_expr_if
  13: rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_expr_mut::{{closure}}
  14: rustc_data_structures::stack::ensure_sufficient_stack
  15: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
  16: <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next
  17: <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend
  18: rustc_arena::cold_path
  19: rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::lower_block_expr_opt
  20: rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::lower_fn_body_block
  21: rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::lower_item
  22: rustc_ast_lowering::LoweringContext::with_hir_id_owner
  23: rustc_ast_lowering::lower_crate
  24: rustc_interface::passes::BoxedResolver::access::{{closure}}
  25: rustc_interface::passes::configure_and_expand::{{closure}}
  26: rustc_interface::queries::Queries::lower_to_hir
  27: rustc_interface::queries::Queries::global_ctxt
  28: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  29: rustc_span::with_source_map
  30: 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.52.0-nightly (9b471a3f5 2021-02-19) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

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

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

For more information about this error, try `rustc --explain E0658`.
error: could not compile `crash`

To learn more, run the command again with --verbose.

@lloydparlee lloydparlee 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 6, 2021
@JohnTitor
Copy link
Member

Duplicate of #82290, it should be fixed on the recent nightly. Thanks for reporting anyway!

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