Skip to content

let_chains causes a compiler panic #82290

Closed
@irevoire

Description

@irevoire

Code

#![feature(str_split_once)]
#![feature(let_chains)]

fn main() {
    let mut bug = "lalacoollolo".to_string();
    if !bug.contains("🔢") && (let Some((start, end)) = bug.split_once("1234")) {
        bug = format!("{}🔢{}", start, end);
    }

    println!("{}", bug);
}

Meta

rustc --version --verbose:

rustc 1.52.0-nightly (8e54a2113 2021-02-13)
binary: rustc
commit-hash: 8e54a21139ae96a2aca3129100b057662e2799b9
commit-date: 2021-02-13
host: x86_64-unknown-linux-gnu
release: 1.52.0-nightly
LLVM version: 11.0.1

Error output

thread 'rustc' panicked at 'expected `NodeId` to be lowered already for res Local(
    NodeId(28),
)', compiler/rustc_ast_lowering/src/lib.rs:714: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 (8e54a2113 2021-02-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -C opt-level=3 -C embed-bitcode=no --crate-type bin

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

query stack during panic:
end of query stack
Backtrace

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

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: could not compile `bug`

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

I made a small git repo to reproduce the bug here

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-let_chains`#![feature(let_chains)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions