Skip to content

ICE: capacity overflow in Vec with -Zunpretty=hir let-else-bool-binop-init.rs #99319

Closed

Description

@matthiaskrgr

Code

./src/test/ui/let-else/let-else-bool-binop-init.rs

// run-rustfix

#![feature(let_else)]

fn main() {
    let true = true && false else { return }; //~ ERROR a `&&` expression cannot be directly assigned in `let...else`
    let true = true || false else { return }; //~ ERROR a `||` expression cannot be directly assigned in `let...else`
}

Meta

rustc --version --verbose:

rustc 1.64.0-nightly (87588a2af 2022-07-13)
binary: rustc
commit-hash: 87588a2afd9ca903366f0deaf84d805f34469384
commit-date: 2022-07-13
host: x86_64-unknown-linux-gnu
release: 1.64.0-nightly
LLVM version: 14.0.6

Error output

rustc ./src/test/ui/let-else/let-else-bool-binop-init.rs -Zunpretty=hir

error: a `&&` expression cannot be directly assigned in `let...else`
 --> ./src/test/ui/let-else/let-else-bool-binop-init.rs:6:16
  |
6 |     let true = true && false else { return }; //~ ERROR a `&&` expression cannot be directly assigned in `let...else`
  |                ^^^^^^^^^^^^^
  |
help: wrap the expression in parentheses
  |
6 |     let true = (true && false) else { return }; //~ ERROR a `&&` expression cannot be directly assigned in `let...else`
  |                +             +

error: a `||` expression cannot be directly assigned in `let...else`
 --> ./src/test/ui/let-else/let-else-bool-binop-init.rs:7:16
  |
7 |     let true = true || false else { return }; //~ ERROR a `||` expression cannot be directly assigned in `let...else`
  |                ^^^^^^^^^^^^^
  |
help: wrap the expression in parentheses
  |
7 |     let true = (true || false) else { return }; //~ ERROR a `||` expression cannot be directly assigned in `let...else`
  |                +             +
Backtrace

thread 'rustc' panicked at 'capacity overflow', library/alloc/src/raw_vec.rs:518:5
stack backtrace:
   0:     0x7fad1d2a2850 - std::backtrace_rs::backtrace::libunwind::trace::h546e34b136647819
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7fad1d2a2850 - std::backtrace_rs::backtrace::trace_unsynchronized::h76e576fe0a1ec65e
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fad1d2a2850 - std::sys_common::backtrace::_print_fmt::h3489fbb9d5d01094
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fad1d2a2850 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h401cfc97a3c2f247
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fad1d2fbe2c - core::fmt::write::h327c921ac5532dc9
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/core/src/fmt/mod.rs:1198:17
   5:     0x7fad1d293e15 - std::io::Write::write_fmt::h334c1fe5d85b41a9
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/io/mod.rs:1672:15
   6:     0x7fad1d2a54e1 - std::sys_common::backtrace::_print::hddc5656bc817cc55
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fad1d2a54e1 - std::sys_common::backtrace::print::h46adcb0dcb6fbe81
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fad1d2a54e1 - std::panicking::default_hook::{{closure}}::h7e55301ce91fa17d
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/panicking.rs:295:22
   9:     0x7fad1d2a51b3 - std::panicking::default_hook::he24b412fa8dea167
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/panicking.rs:314:9
  10:     0x7fad1db47e04 - rustc_driver[24990f24c5f9557a]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fad1d2a5cb6 - std::panicking::rust_panic_with_hook::hd6be56b55800f278
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/panicking.rs:702:17
  12:     0x7fad1d2a5ac9 - std::panicking::begin_panic_handler::{{closure}}::h299e1cde9b2d55bf
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/panicking.rs:586:13
  13:     0x7fad1d2a2d34 - std::sys_common::backtrace::__rust_end_short_backtrace::h217affeadc688779
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7fad1d2a5832 - rust_begin_unwind
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/panicking.rs:584:5
  15:     0x7fad1d269b73 - core::panicking::panic_fmt::hce80afc1c6c77893
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/core/src/panicking.rs:142:14
  16:     0x7fad1d2ed309 - alloc::raw_vec::capacity_overflow::h7fbf2e844df63d1e
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/alloc/src/raw_vec.rs:518:5
  17:     0x7fad1fc8b766 - <rustc_ast_pretty[c2f1cb48f89c6c8]::pp::Printer>::scan_string
  18:     0x7fad1e84f5ab - <rustc_hir_pretty[ace3b7ae5e9072c9]::State as rustc_ast_pretty[c2f1cb48f89c6c8]::pprust::state::PrintState>::print_comment
  19:     0x7fad203d0ff6 - <rustc_hir_pretty[ace3b7ae5e9072c9]::State>::print_stmt
  20:     0x7fad203d1316 - <rustc_hir_pretty[ace3b7ae5e9072c9]::State>::print_block_maybe_unclosed
  21:     0x7fad1f847d92 - <rustc_hir_pretty[ace3b7ae5e9072c9]::State>::print_expr
  22:     0x7fad1db37894 - <rustc_driver[24990f24c5f9557a]::pretty::IdentifiedAnnotation as rustc_hir_pretty[ace3b7ae5e9072c9]::PpAnn>::nested
  23:     0x7fad203cef7c - <rustc_hir_pretty[ace3b7ae5e9072c9]::State>::print_item
  24:     0x7fad1db37894 - <rustc_driver[24990f24c5f9557a]::pretty::IdentifiedAnnotation as rustc_hir_pretty[ace3b7ae5e9072c9]::PpAnn>::nested
  25:     0x7fad1e8508cd - <rustc_hir_pretty[ace3b7ae5e9072c9]::State>::print_mod
  26:     0x7fad1e85000e - rustc_hir_pretty[ace3b7ae5e9072c9]::print_crate
  27:     0x7fad1db39ba3 - rustc_driver[24990f24c5f9557a]::pretty::print_after_hir_lowering::{closure#1}
  28:     0x7fad1db397bc - rustc_driver[24990f24c5f9557a]::pretty::print_after_hir_lowering
  29:     0x7fad1db223ba - <rustc_interface[d9e16a24b5464548]::passes::QueryContext>::enter::<rustc_driver[24990f24c5f9557a]::run_compiler::{closure#1}::{closure#2}::{closure#1}, core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>>
  30:     0x7fad1fcea90f - <rustc_interface[d9e16a24b5464548]::interface::Compiler>::enter::<rustc_driver[24990f24c5f9557a]::run_compiler::{closure#1}::{closure#2}, core[734affb1a3eaf053]::result::Result<core[734affb1a3eaf053]::option::Option<rustc_interface[d9e16a24b5464548]::queries::Linker>, rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>>
  31:     0x7fad1fce676f - rustc_span[b8cb56592c4d9b67]::with_source_map::<core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>, rustc_interface[d9e16a24b5464548]::interface::create_compiler_and_run<core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>, rustc_driver[24990f24c5f9557a]::run_compiler::{closure#1}>::{closure#1}>
  32:     0x7fad1fd02880 - rustc_interface[d9e16a24b5464548]::interface::create_compiler_and_run::<core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>, rustc_driver[24990f24c5f9557a]::run_compiler::{closure#1}>
  33:     0x7fad1fd16a02 - <scoped_tls[93927b52d599628f]::ScopedKey<rustc_span[b8cb56592c4d9b67]::SessionGlobals>>::set::<rustc_interface[d9e16a24b5464548]::interface::run_compiler<core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>, rustc_driver[24990f24c5f9557a]::run_compiler::{closure#1}>::{closure#0}, core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>>
  34:     0x7fad1fce8cff - std[66dc708de7974585]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[d9e16a24b5464548]::util::run_in_thread_pool_with_globals<rustc_interface[d9e16a24b5464548]::interface::run_compiler<core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>, rustc_driver[24990f24c5f9557a]::run_compiler::{closure#1}>::{closure#0}, core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>>::{closure#0}, core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>>
  35:     0x7fad1fd02cd9 - <<std[66dc708de7974585]::thread::Builder>::spawn_unchecked_<rustc_interface[d9e16a24b5464548]::util::run_in_thread_pool_with_globals<rustc_interface[d9e16a24b5464548]::interface::run_compiler<core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>, rustc_driver[24990f24c5f9557a]::run_compiler::{closure#1}>::{closure#0}, core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>>::{closure#0}, core[734affb1a3eaf053]::result::Result<(), rustc_errors[7a9b9cc96f052d83]::ErrorGuaranteed>>::{closure#1} as core[734affb1a3eaf053]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:     0x7fad1d2af703 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h332a3f23c5b3d8bc
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/alloc/src/boxed.rs:1934:9
  37:     0x7fad1d2af703 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h33b3da7f4496df00
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/alloc/src/boxed.rs:1934:9
  38:     0x7fad1d2af703 - std::sys::unix::thread::Thread::new::thread_start::hf48274d01b2ded65
                               at /rustc/87588a2afd9ca903366f0deaf84d805f34469384/library/std/src/sys/unix/thread.rs:108:17
  39:     0x7fad1d08054d - <unknown>
  40:     0x7fad1d105874 - clone
  41:                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.64.0-nightly (87588a2af 2022-07-13) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z unpretty=hir

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

Activity

  1. added
    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.
    C-bugCategory: This is a bug.
    F-let_elseIssues related to let-else statements (RFC 3137)
    on Jul 16, 2022
  2. added a commit that references this issue on Jul 17, 2022
  3. added a commit that references this issue on Aug 13, 2022
    60fa217
  4. added a commit that references this issue on Aug 13, 2022
    2126cc6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-let_elseIssues related to let-else statements (RFC 3137)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.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions