Skip to content

thread 'rustc' panicked at 'called Result::unwrap() on an Err value: SourceNotAvailable #96225

Closed
@Badel2

Description

@Badel2

I'm seeing an internal compiler error on the following input (found by fuzz-rustc):

Code

fn L(,,) {
    L(vec![])
}

Playground

Error output

error: expected parameter name, found `,`
 --> src/lib.rs:1:6
  |
1 | fn L(,,) {
  |      ^ expected parameter name

error: expected parameter name, found `,`
 --> src/lib.rs:1:7
  |
1 | fn L(,,) {
  |       ^ expected parameter name

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "/rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/alloc/src/macros.rs" }) }', compiler/rustc_typeck/src/check/fn_ctxt/checks.rs:984:77

Caused by this line introduced in #92364

let arg_text = source_map.span_to_snippet(arg_span).unwrap();

I found a similar issue in the past, this pull request fixes it: #70725

Unfortunately, this one looks like a spurious failure. It can be reproduced in the playground using nightly 2022-04-18, but when I try it locally using the same nightly version there is no ICE. This is the error message:

error: expected parameter name, found `,`
 --> src/lib.rs:1:6
  |
1 | fn L(,,) {
  |      ^ expected parameter name

error: expected parameter name, found `,`
 --> src/lib.rs:1:7
  |
1 | fn L(,,) {
  |       ^ expected parameter name

error[E0061]: this function takes 2 arguments but 1 argument was supplied
 --> src/lib.rs:2:5
  |
2 |     L(vec![])
  |     ^-------- an argument is missing
  |
note: function defined here
 --> src/lib.rs:1:4
  |
1 | fn L(,,) {
  |    ^--
help: provide the argument
  |
2 |     L($crate::vec::Vec::new(), {[type error]})
  |
Backtrace

   Compiling playground v0.0.1 (/playground)
error: expected parameter name, found `,`
 --> src/lib.rs:1:6
  |
1 | fn L(,,) {
  |      ^ expected parameter name

error: expected parameter name, found `,`
 --> src/lib.rs:1:7
  |
1 | fn L(,,) {
  |       ^ expected parameter name

thread 'rustc' panicked at 'called `Result::unwrap()` on an `Err` value: SourceNotAvailable { filename: Real(Remapped { local_path: None, virtual_name: "/rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/alloc/src/macros.rs" }) }', compiler/rustc_typeck/src/check/fn_ctxt/checks.rs:984:77
stack backtrace:
   0:     0x7fb944eff82d - std::backtrace_rs::backtrace::libunwind::trace::h9d7060c592fe8069
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7fb944eff82d - std::backtrace_rs::backtrace::trace_unsynchronized::hde51808b1556e5d1
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7fb944eff82d - std::sys_common::backtrace::_print_fmt::hd954a2d1cd9fdbd5
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7fb944eff82d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h6271b22d4e4423c8
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7fb944f5aecc - core::fmt::write::heb1c2a4e59b134a9
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/core/src/fmt/mod.rs:1194:17
   5:     0x7fb944ef1011 - std::io::Write::write_fmt::h6652729f1feeae87
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/std/src/io/mod.rs:1655:15
   6:     0x7fb944f02545 - std::sys_common::backtrace::_print::ha9ae153024491f3f
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7fb944f02545 - std::sys_common::backtrace::print::h110c021885084d6a
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7fb944f02545 - std::panicking::default_hook::{{closure}}::h68d23f0b88a08886
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/std/src/panicking.rs:295:22
   9:     0x7fb944f021b9 - std::panicking::default_hook::h2e20223d1536191d
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/std/src/panicking.rs:314:9
  10:     0x7fb9456a4731 - rustc_driver[46ea51695bd673e5]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7fb944f02d16 - std::panicking::rust_panic_with_hook::hfe1e95a000a88a64
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/std/src/panicking.rs:702:17
  12:     0x7fb944f02b17 - std::panicking::begin_panic_handler::{{closure}}::h04cf82910c0a653e
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/std/src/panicking.rs:588:13
  13:     0x7fb944effce4 - std::sys_common::backtrace::__rust_end_short_backtrace::h187f35deeb28abc2
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7fb944f02849 - rust_begin_unwind
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/std/src/panicking.rs:584:5
  15:     0x7fb944ec7ba3 - core::panicking::panic_fmt::h70547f234f37fa30
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/core/src/panicking.rs:142:14
  16:     0x7fb944ec7c93 - core::result::unwrap_failed::h95b8761ba0c00f97
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/core/src/result.rs:1785:5
  17:     0x7fb946b5123c - <rustc_typeck[1bd8200d7af772bc]::check::fn_ctxt::FnCtxt>::check_argument_types
  18:     0x7fb946b15f6e - <rustc_typeck[1bd8200d7af772bc]::check::fn_ctxt::FnCtxt>::confirm_builtin_call
  19:     0x7fb946b12438 - <rustc_typeck[1bd8200d7af772bc]::check::fn_ctxt::FnCtxt>::check_call
  20:     0x7fb946b6818d - <rustc_typeck[1bd8200d7af772bc]::check::fn_ctxt::FnCtxt>::check_expr_kind
  21:     0x7fb946b66fc0 - <rustc_typeck[1bd8200d7af772bc]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  22:     0x7fb946b56590 - <rustc_typeck[1bd8200d7af772bc]::check::fn_ctxt::FnCtxt>::check_block_with_expected
  23:     0x7fb946b682b3 - <rustc_typeck[1bd8200d7af772bc]::check::fn_ctxt::FnCtxt>::check_expr_kind
  24:     0x7fb946b66fc0 - <rustc_typeck[1bd8200d7af772bc]::check::fn_ctxt::FnCtxt>::check_expr_with_expectation
  25:     0x7fb946c802d6 - rustc_typeck[1bd8200d7af772bc]::check::check::check_fn
  26:     0x7fb946be0140 - <rustc_infer[a51b2704175fce84]::infer::InferCtxtBuilder>::enter::<&rustc_middle[4038938c89644caa]::ty::context::TypeckResults, <rustc_typeck[1bd8200d7af772bc]::check::inherited::InheritedBuilder>::enter<rustc_typeck[1bd8200d7af772bc]::check::typeck_with_fallback<rustc_typeck[1bd8200d7af772bc]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[4038938c89644caa]::ty::context::TypeckResults>::{closure#0}>
  27:     0x7fb946bb2f00 - rustc_typeck[1bd8200d7af772bc]::check::typeck
  28:     0x7fb9470c7390 - rustc_query_system[103384a90f76de31]::query::plumbing::try_execute_query::<rustc_query_impl[8b18bc69f52059fc]::plumbing::QueryCtxt, rustc_query_system[103384a90f76de31]::query::caches::DefaultCache<rustc_span[8638436c65ab17fb]::def_id::LocalDefId, &rustc_middle[4038938c89644caa]::ty::context::TypeckResults>>
  29:     0x7fb9471cbb08 - <rustc_query_impl[8b18bc69f52059fc]::Queries as rustc_middle[4038938c89644caa]::ty::query::QueryEngine>::typeck
  30:     0x7fb946c64c18 - <rustc_middle[4038938c89644caa]::hir::map::Map>::par_body_owners::<rustc_typeck[1bd8200d7af772bc]::check::typeck_item_bodies::{closure#0}>
  31:     0x7fb94797f23c - rustc_typeck[1bd8200d7af772bc]::check::typeck_item_bodies
  32:     0x7fb947bd3c92 - rustc_query_system[103384a90f76de31]::query::plumbing::try_execute_query::<rustc_query_impl[8b18bc69f52059fc]::plumbing::QueryCtxt, rustc_query_system[103384a90f76de31]::query::caches::DefaultCache<(), ()>>
  33:     0x7fb947bfb4a1 - rustc_query_system[103384a90f76de31]::query::plumbing::get_query::<rustc_query_impl[8b18bc69f52059fc]::queries::typeck_item_bodies, rustc_query_impl[8b18bc69f52059fc]::plumbing::QueryCtxt>
  34:     0x7fb94798e2f3 - <rustc_session[5849b3ac9fc37c68]::session::Session>::time::<(), rustc_typeck[1bd8200d7af772bc]::check_crate::{closure#7}>
  35:     0x7fb94798be93 - rustc_typeck[1bd8200d7af772bc]::check_crate
  36:     0x7fb94770c477 - rustc_interface[668261b8f47f72c0]::passes::analysis
  37:     0x7fb947bc9dc4 - rustc_query_system[103384a90f76de31]::query::plumbing::try_execute_query::<rustc_query_impl[8b18bc69f52059fc]::plumbing::QueryCtxt, rustc_query_system[103384a90f76de31]::query::caches::DefaultCache<(), core[2fe9dabce7a4eee7]::result::Result<(), rustc_errors[87e4665ca07ec85e]::ErrorGuaranteed>>>
  38:     0x7fb947c0b24e - rustc_query_system[103384a90f76de31]::query::plumbing::get_query::<rustc_query_impl[8b18bc69f52059fc]::queries::analysis, rustc_query_impl[8b18bc69f52059fc]::plumbing::QueryCtxt>
  39:     0x7fb9476e9af7 - <rustc_interface[668261b8f47f72c0]::passes::QueryContext>::enter::<rustc_driver[46ea51695bd673e5]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[2fe9dabce7a4eee7]::result::Result<(), rustc_errors[87e4665ca07ec85e]::ErrorGuaranteed>>
  40:     0x7fb9476d5078 - <rustc_interface[668261b8f47f72c0]::interface::Compiler>::enter::<rustc_driver[46ea51695bd673e5]::run_compiler::{closure#1}::{closure#2}, core[2fe9dabce7a4eee7]::result::Result<core[2fe9dabce7a4eee7]::option::Option<rustc_interface[668261b8f47f72c0]::queries::Linker>, rustc_errors[87e4665ca07ec85e]::ErrorGuaranteed>>
  41:     0x7fb9476fde3f - rustc_span[8638436c65ab17fb]::with_source_map::<core[2fe9dabce7a4eee7]::result::Result<(), rustc_errors[87e4665ca07ec85e]::ErrorGuaranteed>, rustc_interface[668261b8f47f72c0]::interface::create_compiler_and_run<core[2fe9dabce7a4eee7]::result::Result<(), rustc_errors[87e4665ca07ec85e]::ErrorGuaranteed>, rustc_driver[46ea51695bd673e5]::run_compiler::{closure#1}>::{closure#1}>
  42:     0x7fb9476d5c97 - <scoped_tls[b360d135f6f091a9]::ScopedKey<rustc_span[8638436c65ab17fb]::SessionGlobals>>::set::<rustc_interface[668261b8f47f72c0]::interface::run_compiler<core[2fe9dabce7a4eee7]::result::Result<(), rustc_errors[87e4665ca07ec85e]::ErrorGuaranteed>, rustc_driver[46ea51695bd673e5]::run_compiler::{closure#1}>::{closure#0}, core[2fe9dabce7a4eee7]::result::Result<(), rustc_errors[87e4665ca07ec85e]::ErrorGuaranteed>>
  43:     0x7fb9476eb1df - std[4fdfe6e28689bcfc]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[668261b8f47f72c0]::util::run_in_thread_pool_with_globals<rustc_interface[668261b8f47f72c0]::interface::run_compiler<core[2fe9dabce7a4eee7]::result::Result<(), rustc_errors[87e4665ca07ec85e]::ErrorGuaranteed>, rustc_driver[46ea51695bd673e5]::run_compiler::{closure#1}>::{closure#0}, core[2fe9dabce7a4eee7]::result::Result<(), rustc_errors[87e4665ca07ec85e]::ErrorGuaranteed>>::{closure#0}, core[2fe9dabce7a4eee7]::result::Result<(), rustc_errors[87e4665ca07ec85e]::ErrorGuaranteed>>
  44:     0x7fb9476eb329 - <<std[4fdfe6e28689bcfc]::thread::Builder>::spawn_unchecked_<rustc_interface[668261b8f47f72c0]::util::run_in_thread_pool_with_globals<rustc_interface[668261b8f47f72c0]::interface::run_compiler<core[2fe9dabce7a4eee7]::result::Result<(), rustc_errors[87e4665ca07ec85e]::ErrorGuaranteed>, rustc_driver[46ea51695bd673e5]::run_compiler::{closure#1}>::{closure#0}, core[2fe9dabce7a4eee7]::result::Result<(), rustc_errors[87e4665ca07ec85e]::ErrorGuaranteed>>::{closure#0}, core[2fe9dabce7a4eee7]::result::Result<(), rustc_errors[87e4665ca07ec85e]::ErrorGuaranteed>>::{closure#1} as core[2fe9dabce7a4eee7]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  45:     0x7fb944f0cbc3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6caff75e9500dfec
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/alloc/src/boxed.rs:1866:9
  46:     0x7fb944f0cbc3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hfcb7dd749eba4870
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/alloc/src/boxed.rs:1866:9
  47:     0x7fb944f0cbc3 - std::sys::unix::thread::Thread::new::thread_start::h865210c19e650802
                               at /rustc/311e2683e1bad87715b1558f7900e294d24ce491/library/std/src/sys/unix/thread.rs:108:17
  48:     0x7fb944e3d609 - start_thread
  49:     0x7fb944d56163 - clone
  50:                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.62.0-nightly (311e2683e 2022-04-18) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
#0 [typeck] type-checking `L`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: could not compile `playground` due to 2 previous errors

Metadata

Metadata

Assignees

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