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: unreachable in compiler/rustc_ast/src/util/literal.rs with -Zunpretty=hir #100948

Closed
matthiaskrgr opened this issue Aug 24, 2022 · 3 comments · Fixed by #100978
Closed

ICE: unreachable in compiler/rustc_ast/src/util/literal.rs with -Zunpretty=hir #100948

matthiaskrgr opened this issue Aug 24, 2022 · 3 comments · Fixed by #100978
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

use std::iter::Iterator;

fn map<T, U, I: Iterator<T>>(fun: |T| -> U, mut iter: I) -> Vec<U> {
    let mut acc = vec![];
    for elt in iter {
        acc.push(fun(elt));
    }
    acc
}

fn main() {
    let x = map(|&x| x + 2, vec![1u,2,3].iter());
    println!("{}", x);
}

Meta

rustc --version --verbose:

rustc 1.65.0-nightly (060e47f74 2022-08-23)
binary: rustc
commit-hash: 060e47f74a91b28c3db28d80a6a9d6841ca51026
commit-date: 2022-08-23
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0

Error output

rustc ./20108.rs -Zunpretty=hir

error: expected type, found `|`
 --> ./20108.rs:3:35
  |
3 | fn map<T, U, I: Iterator<T>>(fun: |T| -> U, mut iter: I) -> Vec<U> {
  |                                   ^ expected type

error: invalid suffix `u` for number literal
  --> ./20108.rs:12:34
   |
12 |     let x = map(|&x| x + 2, vec![1u,2,3].iter());
   |                                  ^^ invalid suffix `u`
   |
   = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.)

error[E0425]: cannot find function `fun` in this scope
 --> ./20108.rs:6:18
  |
6 |         acc.push(fun(elt));
  |                  ^^^ not found in this scope
Backtrace

thread 'rustc' panicked at 'internal error: entered unreachable code', compiler/rustc_ast/src/util/literal.rs:202:29
stack backtrace:
   0:     0x7f729b6cc750 - std::backtrace_rs::backtrace::libunwind::trace::h18bb8883b170e61e
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f729b6cc750 - std::backtrace_rs::backtrace::trace_unsynchronized::hfbfd04778228f53a
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f729b6cc750 - std::sys_common::backtrace::_print_fmt::hf014d9c7ceb4c50b
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f729b6cc750 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0cff30d852e41e28
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f729b727a5e - core::fmt::write::hf3278c297bc3e8c3
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/core/src/fmt/mod.rs:1202:17
   5:     0x7f729b6bd4d5 - std::io::Write::write_fmt::hb3fb7e9de918605f
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/std/src/io/mod.rs:1672:15
   6:     0x7f729b6cf413 - std::sys_common::backtrace::_print::hb735a2b0aa8c9126
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f729b6cf413 - std::sys_common::backtrace::print::h1d481f5d3b90ee64
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f729b6cf413 - std::panicking::default_hook::{{closure}}::h3cda275262afb117
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/std/src/panicking.rs:295:22
   9:     0x7f729b6cf0ff - std::panicking::default_hook::h2eba6d64b7e32862
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/std/src/panicking.rs:314:9
  10:     0x7f729df1d4e4 - <rustc_driver[b627559a5a77e284]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[e3f13d716672aa]::ops::function::FnOnce<(&core[e3f13d716672aa]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f729b6cfc4d - std::panicking::rust_panic_with_hook::hfaad0ec4972467c1
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/std/src/panicking.rs:702:17
  12:     0x7f729b6cfa61 - std::panicking::begin_panic_handler::{{closure}}::h401c5684148433ac
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/std/src/panicking.rs:586:13
  13:     0x7f729b6ccc5c - std::sys_common::backtrace::__rust_end_short_backtrace::h356ecf2a7ec67271
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f729b6cf7c2 - rust_begin_unwind
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/std/src/panicking.rs:584:5
  15:     0x7f729b724573 - core::panicking::panic_fmt::h9555dfef52eae25e
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/core/src/panicking.rs:142:14
  16:     0x7f729b7243bd - core::panicking::panic::hbe0e36c7510ee8e3
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/core/src/panicking.rs:48:5
  17:     0x7f729cf37d8f - <rustc_ast[7723d7f951651904]::ast::LitKind>::to_token_lit
  18:     0x7f729cf34601 - <rustc_hir_pretty[541b7d9012655fc5]::State>::print_expr
  19:     0x7f729cf381fc - <rustc_hir_pretty[541b7d9012655fc5]::State>::commasep_cmnt::<rustc_hir[bd2c63ffa7ad50d5]::hir::Expr, <rustc_hir_pretty[541b7d9012655fc5]::State>::commasep_exprs::{closure#0}, <rustc_hir_pretty[541b7d9012655fc5]::State>::commasep_exprs::{closure#1}>
  20:     0x7f729cf349a9 - <rustc_hir_pretty[541b7d9012655fc5]::State>::print_expr
  21:     0x7f729cf35a8d - <rustc_hir_pretty[541b7d9012655fc5]::State>::print_expr
  22:     0x7f729cf381fc - <rustc_hir_pretty[541b7d9012655fc5]::State>::commasep_cmnt::<rustc_hir[bd2c63ffa7ad50d5]::hir::Expr, <rustc_hir_pretty[541b7d9012655fc5]::State>::commasep_exprs::{closure#0}, <rustc_hir_pretty[541b7d9012655fc5]::State>::commasep_exprs::{closure#1}>
  23:     0x7f729cf348c0 - <rustc_hir_pretty[541b7d9012655fc5]::State>::print_expr
  24:     0x7f729cf3543b - <rustc_hir_pretty[541b7d9012655fc5]::State>::print_expr
  25:     0x7f729cf381fc - <rustc_hir_pretty[541b7d9012655fc5]::State>::commasep_cmnt::<rustc_hir[bd2c63ffa7ad50d5]::hir::Expr, <rustc_hir_pretty[541b7d9012655fc5]::State>::commasep_exprs::{closure#0}, <rustc_hir_pretty[541b7d9012655fc5]::State>::commasep_exprs::{closure#1}>
  26:     0x7f729cf348c0 - <rustc_hir_pretty[541b7d9012655fc5]::State>::print_expr
  27:     0x7f729cf3b16f - <rustc_hir_pretty[541b7d9012655fc5]::State>::print_stmt
  28:     0x7f729cf3a755 - <rustc_hir_pretty[541b7d9012655fc5]::State>::print_block_maybe_unclosed
  29:     0x7f729cf34cd4 - <rustc_hir_pretty[541b7d9012655fc5]::State>::print_expr
  30:     0x7f729df13b44 - <rustc_driver[b627559a5a77e284]::pretty::IdentifiedAnnotation as rustc_hir_pretty[541b7d9012655fc5]::PpAnn>::nested
  31:     0x7f729d9ac6b6 - <rustc_hir_pretty[541b7d9012655fc5]::State>::print_item
  32:     0x7f729df13b44 - <rustc_driver[b627559a5a77e284]::pretty::IdentifiedAnnotation as rustc_hir_pretty[541b7d9012655fc5]::PpAnn>::nested
  33:     0x7f729eb4fe3d - <rustc_hir_pretty[541b7d9012655fc5]::State>::print_mod
  34:     0x7f729eb4f52e - rustc_hir_pretty[541b7d9012655fc5]::print_crate
  35:     0x7f729df16e70 - rustc_driver[b627559a5a77e284]::pretty::print_after_hir_lowering::{closure#1}
  36:     0x7f729df16741 - rustc_driver[b627559a5a77e284]::pretty::print_after_hir_lowering
  37:     0x7f729defa1ca - <rustc_interface[bf5d5e33b83f0123]::passes::QueryContext>::enter::<rustc_driver[b627559a5a77e284]::run_compiler::{closure#1}::{closure#2}::{closure#1}, core[e3f13d716672aa]::result::Result<(), rustc_errors[96dfb46f0b8980b]::ErrorGuaranteed>>
  38:     0x7f729d7d554f - <rustc_interface[bf5d5e33b83f0123]::interface::Compiler>::enter::<rustc_driver[b627559a5a77e284]::run_compiler::{closure#1}::{closure#2}, core[e3f13d716672aa]::result::Result<core[e3f13d716672aa]::option::Option<rustc_interface[bf5d5e33b83f0123]::queries::Linker>, rustc_errors[96dfb46f0b8980b]::ErrorGuaranteed>>
  39:     0x7f729d7d0d5c - rustc_span[bead5e57778f0b1b]::with_source_map::<core[e3f13d716672aa]::result::Result<(), rustc_errors[96dfb46f0b8980b]::ErrorGuaranteed>, rustc_interface[bf5d5e33b83f0123]::interface::create_compiler_and_run<core[e3f13d716672aa]::result::Result<(), rustc_errors[96dfb46f0b8980b]::ErrorGuaranteed>, rustc_driver[b627559a5a77e284]::run_compiler::{closure#1}>::{closure#1}>
  40:     0x7f729d7d07d2 - rustc_interface[bf5d5e33b83f0123]::interface::create_compiler_and_run::<core[e3f13d716672aa]::result::Result<(), rustc_errors[96dfb46f0b8980b]::ErrorGuaranteed>, rustc_driver[b627559a5a77e284]::run_compiler::{closure#1}>
  41:     0x7f729d7cf2c1 - <scoped_tls[c2b62212662a5735]::ScopedKey<rustc_span[bead5e57778f0b1b]::SessionGlobals>>::set::<rustc_interface[bf5d5e33b83f0123]::interface::run_compiler<core[e3f13d716672aa]::result::Result<(), rustc_errors[96dfb46f0b8980b]::ErrorGuaranteed>, rustc_driver[b627559a5a77e284]::run_compiler::{closure#1}>::{closure#0}, core[e3f13d716672aa]::result::Result<(), rustc_errors[96dfb46f0b8980b]::ErrorGuaranteed>>
  42:     0x7f729d7cefaf - std[bb5449232b08fe6e]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[bf5d5e33b83f0123]::util::run_in_thread_pool_with_globals<rustc_interface[bf5d5e33b83f0123]::interface::run_compiler<core[e3f13d716672aa]::result::Result<(), rustc_errors[96dfb46f0b8980b]::ErrorGuaranteed>, rustc_driver[b627559a5a77e284]::run_compiler::{closure#1}>::{closure#0}, core[e3f13d716672aa]::result::Result<(), rustc_errors[96dfb46f0b8980b]::ErrorGuaranteed>>::{closure#0}, core[e3f13d716672aa]::result::Result<(), rustc_errors[96dfb46f0b8980b]::ErrorGuaranteed>>
  43:     0x7f729dd3c059 - <<std[bb5449232b08fe6e]::thread::Builder>::spawn_unchecked_<rustc_interface[bf5d5e33b83f0123]::util::run_in_thread_pool_with_globals<rustc_interface[bf5d5e33b83f0123]::interface::run_compiler<core[e3f13d716672aa]::result::Result<(), rustc_errors[96dfb46f0b8980b]::ErrorGuaranteed>, rustc_driver[b627559a5a77e284]::run_compiler::{closure#1}>::{closure#0}, core[e3f13d716672aa]::result::Result<(), rustc_errors[96dfb46f0b8980b]::ErrorGuaranteed>>::{closure#0}, core[e3f13d716672aa]::result::Result<(), rustc_errors[96dfb46f0b8980b]::ErrorGuaranteed>>::{closure#1} as core[e3f13d716672aa]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  44:     0x7f729b6d97a3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hd8b4f77c73b6de54
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/alloc/src/boxed.rs:1940:9
  45:     0x7f729b6d97a3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h396dcf115ad932d5
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/alloc/src/boxed.rs:1940:9
  46:     0x7f729b6d97a3 - std::sys::unix::thread::Thread::new::thread_start::h004395cd09d806b0
                               at /rustc/060e47f74a91b28c3db28d80a6a9d6841ca51026/library/std/src/sys/unix/thread.rs:108:17
  47:     0x7f729b43778d - <unknown>
  48:     0x7f729b4b88e4 - clone
  49:                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.65.0-nightly (060e47f74 2022-08-23) 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 3 previous errors

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

@matthiaskrgr matthiaskrgr added 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. C-bug Category: This is a bug. labels Aug 24, 2022
@matthiaskrgr
Copy link
Member Author

Reduced:

fn main() {
    1u;
}

@matthiaskrgr matthiaskrgr added the S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue label Aug 24, 2022
@TaKO8Ki TaKO8Ki self-assigned this Aug 24, 2022
@TaKO8Ki
Copy link
Member

TaKO8Ki commented Aug 24, 2022

Regression in a1bea15

@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Aug 24, 2022

The assert was added in #100907

I MENT #100909 (sorry, I should no do this on the phone... 🙄 ) cc @nnethercote

TaKO8Ki added a commit to TaKO8Ki/rust that referenced this issue Aug 24, 2022
JohnTitor added a commit to JohnTitor/rust that referenced this issue Aug 25, 2022
…nkov

Handle `Err` in `ast::LitKind::to_token_lit`.

Fixes rust-lang#100948.

r? `@petrochenkov`
JohnTitor added a commit to JohnTitor/rust that referenced this issue Aug 26, 2022
…nkov

Handle `Err` in `ast::LitKind::to_token_lit`.

Fixes rust-lang#100948.

r? ``@petrochenkov``
@bors bors closed this as completed in b997af9 Aug 26, 2022
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) ❄️ S-has-mcve Status: A Minimal Complete and Verifiable Example has been found for this issue T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants