Skip to content

Panic after complaining about let expression position #85653

@santoshs

Description

@santoshs

Code

fn main() {
    println!("{:?}", backspace_compare("ab#c", "ad#c"));
}

fn backspace_compare(u: &str, v: &str) -> bool {
    let mut i = u.chars().into_iter().peekable();
    let mut j = v.chars().into_iter().peekable();
    let mut a_in_bs = false;
    let mut b_in_bs = false;

    loop {
        let a = if !a_in_bs && let Some(a) = i.next() { a } else { break };
        let b = if !b_in_bs && let Some(a) = j.next() { a } else { break };

        // other logic
    }

    return true;
}

Meta

rustc --version --verbose:

rustc 1.52.0-nightly (9b471a3f5 2021-02-19)
binary: rustc
commit-hash: 9b471a3f5fe57e5c6e08acf665f2094422415a3d
commit-date: 2021-02-19
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 11.0.1

Error output

error[E0658]: `let` expressions in this position are experimental
  --> backspace_compare.rs:12:32
   |
12 |         let a = if !a_in_bs && let Some(a) = i.next() { a } else { break };
   |                                ^^^^^^^^^^^^^^^^^^^^^^
   |
   = 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
  --> backspace_compare.rs:13:32
   |
13 |         let b = if !b_in_bs && let Some(a) = j.next() { a } else { break };
   |                                ^^^^^^^^^^^^^^^^^^^^^^
   |
   = 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(61),
)', 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-unknown-linux-gnu

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`.
Backtrace

stack backtrace:
   0:     0x7fb7ac2f8ab0 - std::backtrace_rs::backtrace::libunwind::trace::hb4de9797f80b7b8c
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7fb7ac2f8ab0 - std::backtrace_rs::backtrace::trace_unsynchronized::h59566d0bd20efff7
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb7ac2f8ab0 - std::sys_common::backtrace::_print_fmt::hcfa5ce6be50275d4
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7fb7ac2f8ab0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd8c307a38b9bab04
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7fb7ac369e6c - core::fmt::write::h3868db8542c90941
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/core/src/fmt/mod.rs:1092:17
   5:     0x7fb7ac2eb992 - std::io::Write::write_fmt::hab90295d5a0f197d
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/io/mod.rs:1568:15
   6:     0x7fb7ac2fc9a5 - std::sys_common::backtrace::_print::h19224910b8700cf1
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7fb7ac2fc9a5 - std::sys_common::backtrace::print::h25dedfa68c5fb84a
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7fb7ac2fc9a5 - std::panicking::default_hook::{{closure}}::h12c5765653a72a42
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/panicking.rs:208:50
   9:     0x7fb7ac2fc453 - std::panicking::default_hook::he65cee71c4209f0c
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/panicking.rs:225:9
  10:     0x7fb7acb5b08b - rustc_driver::report_ice::h56d5f6e6a9fb9d03
  11:     0x7fb7ac2fd2a6 - std::panicking::rust_panic_with_hook::h01a674d863fe0d8a
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/panicking.rs:595:17
  12:     0x7fb7ac2fcdc7 - std::panicking::begin_panic_handler::{{closure}}::h9b9fecf185178864
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/panicking.rs:497:13
  13:     0x7fb7ac2f8f4c - std::sys_common::backtrace::__rust_end_short_backtrace::h57be46a42dc7f24b
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/sys_common/backtrace.rs:141:18
  14:     0x7fb7ac2fcd29 - rust_begin_unwind
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/panicking.rs:493:5
  15:     0x7fb7ac2fccdb - std::panicking::begin_panic_fmt::h12277576db89392f
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/panicking.rs:435:5
  16:     0x7fb7ae75e4ce - rustc_ast_lowering::LoweringContext::lower_node_id_generic::h96ef6a2b3badc67a
  17:     0x7fb7ae759023 - rustc_ast_lowering::path::<impl rustc_ast_lowering::LoweringContext>::lower_qpath::h728abfd914684cf6
  18:     0x7fb7ae76e109 - rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_expr_mut::{{closure}}::hee5f49f6edf5c89d
  19:     0x7fb7ae74d204 - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::hcf8cf9d142d490c8
  20:     0x7fb7ae771d19 - <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next::h7d1ad417737c6ec1
  21:     0x7fb7ae773a9a - <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend::h818bb2f96edbc005
  22:     0x7fb7ae76a4c6 - rustc_arena::cold_path::h052ae9e9e0200f1f
  23:     0x7fb7af370f3b - rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_expr_if::h183f1e13f3abfeb8
  24:     0x7fb7ae76ec61 - rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_expr_mut::{{closure}}::hee5f49f6edf5c89d
  25:     0x7fb7ae7663a6 - rustc_ast_lowering::LoweringContext::lower_stmt::h0f088964b0684b7c
  26:     0x7fb7ae74d273 - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::hcf8cf9d142d490c8
  27:     0x7fb7ae771d19 - <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next::h7d1ad417737c6ec1
  28:     0x7fb7ae773a9a - <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend::h818bb2f96edbc005
  29:     0x7fb7ae76a4c6 - rustc_arena::cold_path::h052ae9e9e0200f1f
  30:     0x7fb7af374a85 - rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::with_loop_scope::hc3c72fb91ff9b1fd
  31:     0x7fb7ae76f731 - rustc_ast_lowering::expr::<impl rustc_ast_lowering::LoweringContext>::lower_expr_mut::{{closure}}::hee5f49f6edf5c89d
  32:     0x7fb7ae766752 - rustc_ast_lowering::LoweringContext::lower_stmt::h0f088964b0684b7c
  33:     0x7fb7ae74d273 - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::hcf8cf9d142d490c8
  34:     0x7fb7ae771d19 - <core::iter::adapters::flatten::Flatten<I> as core::iter::traits::iterator::Iterator>::next::h7d1ad417737c6ec1
  35:     0x7fb7ae773a9a - <smallvec::SmallVec<A> as core::iter::traits::collect::Extend<<A as smallvec::Array>::Item>>::extend::h818bb2f96edbc005
  36:     0x7fb7ae76a4c6 - rustc_arena::cold_path::h052ae9e9e0200f1f
  37:     0x7fb7ae755002 - rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::lower_fn_body_block::h4c87b770b4dfad13
  38:     0x7fb7ae7553ab - rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::lower_maybe_async_body::h0184ada37111015f
  39:     0x7fb7ae7504b4 - rustc_ast_lowering::item::<impl rustc_ast_lowering::LoweringContext>::lower_item::heff00976658f0442
  40:     0x7fb7ae75e635 - rustc_ast_lowering::LoweringContext::with_hir_id_owner::h8a959c729ad00cb2
  41:     0x7fb7ae75bc56 - rustc_ast_lowering::lower_crate::he6105ef5c2a0a8f8
  42:     0x7fb7aef39fbf - rustc_interface::passes::BoxedResolver::access::{{closure}}::h0000940762143484
  43:     0x7fb7aef23873 - rustc_interface::passes::configure_and_expand::{{closure}}::hc445850932a65240
  44:     0x7fb7aef32561 - rustc_interface::queries::Queries::lower_to_hir::hcadbdfb94a3f902a
  45:     0x7fb7aef3570b - rustc_interface::queries::Queries::global_ctxt::hd425583f92f1d6c5
  46:     0x7fb7aeecd24f - rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter::hae97633c8f5175d4
  47:     0x7fb7aeec5e11 - rustc_span::with_source_map::hd16d211d24c668a9
  48:     0x7fb7aeeccc62 - scoped_tls::ScopedKey<T>::set::h08e96579ac07fec5
  49:     0x7fb7aeece448 - std::sys_common::backtrace::__rust_begin_short_backtrace::h84dc4b3263d56f8c
  50:     0x7fb7aeeacaba - core::ops::function::FnOnce::call_once{{vtable.shim}}::h209d27a00dc0b7e3
  51:     0x7fb7ac30dffa - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h321523073ee11258
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/alloc/src/boxed.rs:1546:9
  52:     0x7fb7ac30dffa - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf0e85e12c83b99b3
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/alloc/src/boxed.rs:1546:9
  53:     0x7fb7ac30dffa - std::sys::unix::thread::Thread::new::thread_start::hba22c7961aa0e2f8
                               at /rustc/9b471a3f5fe57e5c6e08acf665f2094422415a3d/library/std/src/sys/unix/thread.rs:71:17
  54:     0x7fb7ac229299 - <unknown>
  55:     0x7fb7ac13d353 - clone
  56:                0x0 - <unknown>

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-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`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions