Closed
Description
I'm seeing an internal compiler error on the following input, found by fuzz-rustc:
Code
extern {
fn r() {
impl Copy for u8 {}
}
}
Error output
error: incorrect function inside `extern` block
--> src/lib.rs:2:8
|
1 | extern {
| ------ `extern` blocks define existing foreign functions and functions inside of them cannot have a body
2 | fn r() {
| ________^___-
| | |
| | cannot have a body
3 | | impl Copy for u8 {}
4 | | }
| |_____- help: remove the invalid body: `;`
|
= help: you might have meant to write a function accessible through FFI, which can be done by writing `extern fn` outside of the `extern` block
= note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html
thread 'rustc' panicked at 'index out of bounds: the len is 5 but the index is 5', /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/compiler/rustc_middle/src/hir/map/mod.rs:210:52
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Affected versions: I tried nightly 2021-11-28 and stable 1.56.1 and they both ICE. In stable 1.56.1 the error message is different though, I would say it's better:
error: internal compiler error: compiler/rustc_middle/src/hir/map/mod.rs:326:41: couldn't find hir id HirId { owner: DefId(0:5 ~ playground[443b]::::r::{impl#0}), local_id: 0 } in the HIR map
Backtrace
Compiling playground v0.0.1 (/playground)
error: incorrect function inside `extern` block
--> src/lib.rs:2:8
|
1 | extern {
| ------ `extern` blocks define existing foreign functions and functions inside of them cannot have a body
2 | fn r() {
| ________^___-
| | |
| | cannot have a body
3 | | impl Copy for u8 {}
4 | | }
| |_____- help: remove the invalid body: `;`
|
= help: you might have meant to write a function accessible through FFI, which can be done by writing `extern fn` outside of the `extern` block
= note: for more information, visit https://doc.rust-lang.org/std/keyword.extern.html
thread 'rustc' panicked at 'index out of bounds: the len is 5 but the index is 5', /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/compiler/rustc_middle/src/hir/map/mod.rs:210:52
stack backtrace:
0: rust_begin_unwind
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/panicking.rs:498:5
1: core::panicking::panic_fmt
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/core/src/panicking.rs:107:14
2: core::panicking::panic_bounds_check
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/core/src/panicking.rs:75:5
3: rustc_typeck::collect::impl_trait_ref
4: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::impl_trait_ref
5: rustc_typeck::coherence::orphan::orphan_check_crate
6: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), &[rustc_span::def_id::LocalDefId]>>
7: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::orphan_check_crate, rustc_query_impl::plumbing::QueryCtxt>
8: <rustc_session::session::Session>::track_errors::<rustc_typeck::check_crate::{closure#3}, ()>
9: rustc_typeck::check_crate
10: rustc_interface::passes::analysis
11: rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::plumbing::QueryCtxt, rustc_query_system::query::caches::DefaultCache<(), core::result::Result<(), rustc_errors::ErrorReported>>>
12: rustc_query_system::query::plumbing::get_query::<rustc_query_impl::queries::analysis, rustc_query_impl::plumbing::QueryCtxt>
13: <rustc_interface::passes::QueryContext>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}::{closure#3}, core::result::Result<(), rustc_errors::ErrorReported>>
14: <rustc_interface::interface::Compiler>::enter::<rustc_driver::run_compiler::{closure#1}::{closure#2}, core::result::Result<core::option::Option<rustc_interface::queries::Linker>, rustc_errors::ErrorReported>>
15: rustc_span::with_source_map::<core::result::Result<(), rustc_errors::ErrorReported>, rustc_interface::interface::create_compiler_and_run<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#1}>
16: <scoped_tls::ScopedKey<rustc_span::SessionGlobals>>::set::<rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<core::result::Result<(), rustc_errors::ErrorReported>, rustc_driver::run_compiler::{closure#1}>::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>::{closure#0}::{closure#0}, core::result::Result<(), rustc_errors::ErrorReported>>
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.59.0-nightly (db9d361a4 2021-11-28) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type lib
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
thread 'rustc' panicked at 'index out of bounds: the len is 5 but the index is 5', compiler/rustc_middle/src/hir/map/mod.rs:210:52
stack backtrace:
0: 0x7f54934e103c - std::backtrace_rs::backtrace::libunwind::trace::hc0d1f8b7d70190d2
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x7f54934e103c - std::backtrace_rs::backtrace::trace_unsynchronized::h94aea4818b005cdb
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x7f54934e103c - std::sys_common::backtrace::_print_fmt::hb60a10c1749ee317
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/sys_common/backtrace.rs:67:5
3: 0x7f54934e103c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h343208346f8e323c
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/sys_common/backtrace.rs:46:22
4: 0x7f549353dd9c - core::fmt::write::h72801a82c94e6ff1
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/core/src/fmt/mod.rs:1149:17
5: 0x7f54934d1695 - std::io::Write::write_fmt::h112481bad48af12b
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/io/mod.rs:1697:15
6: 0x7f54934e4200 - std::sys_common::backtrace::_print::hb97822725c04584f
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/sys_common/backtrace.rs:49:5
7: 0x7f54934e4200 - std::sys_common::backtrace::print::h9e4e4e41087102c8
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/sys_common/backtrace.rs:36:9
8: 0x7f54934e4200 - std::panicking::default_hook::{{closure}}::h98acb2f5574cdd66
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/panicking.rs:211:50
9: 0x7f54934e3dab - std::panicking::default_hook::hf70e89ed6d75872b
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/panicking.rs:228:9
10: 0x7f5493c830d1 - rustc_driver[a54076ffa5a213bc]::DEFAULT_HOOK::{closure#0}::{closure#0}
11: 0x7f54934e4a19 - std::panicking::rust_panic_with_hook::hf940f4eb73f69fac
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/panicking.rs:610:17
12: 0x7f54934e44d0 - std::panicking::begin_panic_handler::{{closure}}::h82243bf8eac030fd
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/panicking.rs:502:13
13: 0x7f54934e14e4 - std::sys_common::backtrace::__rust_end_short_backtrace::h069f9c03677e0254
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/sys_common/backtrace.rs:139:18
14: 0x7f54934e4439 - rust_begin_unwind
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/panicking.rs:498:5
15: 0x7f54934a9491 - core::panicking::panic_fmt::h7b8580d81fcbbacd
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/core/src/panicking.rs:107:14
16: 0x7f54934a9452 - core::panicking::panic_bounds_check::h63650a5dfc9aa86f
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/core/src/panicking.rs:75:5
17: 0x7f5495a41bb2 - <rustc_middle[285bc2392d469bf7]::hir::provide::{closure#7} as core[cc79c391059f8e46]::ops::function::FnOnce<(rustc_middle[285bc2392d469bf7]::ty::context::TyCtxt, rustc_span[2d5555579096f1fe]::def_id::DefId)>>::call_once
18: 0x7f54955db48b - <rustc_query_impl[40c3d6d60a0dbb85]::Queries as rustc_middle[285bc2392d469bf7]::ty::query::QueryEngine>::def_span
19: 0x7f54963ae43e - <rustc_middle[285bc2392d469bf7]::ty::print::pretty::FmtPrinter<&mut alloc[7de0d13971327f45]::string::String> as rustc_middle[285bc2392d469bf7]::ty::print::Printer>::print_def_path
20: 0x7f549639eb12 - <rustc_middle[285bc2392d469bf7]::ty::context::TyCtxt>::def_path_str_with_substs
21: 0x7f549639e9f4 - <rustc_middle[285bc2392d469bf7]::ty::context::TyCtxt>::def_path_str
22: 0x7f54945af151 - <std[79b10227d68e643c]::thread::local::LocalKey<core[cc79c391059f8e46]::cell::Cell<bool>>>::with::<rustc_middle[285bc2392d469bf7]::ty::print::pretty::with_no_trimmed_paths<<rustc_query_impl[40c3d6d60a0dbb85]::queries::impl_trait_ref as rustc_query_system[2bde6a78003d88e]::query::config::QueryDescription<rustc_query_impl[40c3d6d60a0dbb85]::plumbing::QueryCtxt>>::describe::{closure#0}, alloc[7de0d13971327f45]::string::String>::{closure#0}, alloc[7de0d13971327f45]::string::String>
23: 0x7f54945e1228 - <rustc_query_impl[40c3d6d60a0dbb85]::queries::impl_trait_ref as rustc_query_system[2bde6a78003d88e]::query::config::QueryDescription<rustc_query_impl[40c3d6d60a0dbb85]::plumbing::QueryCtxt>>::describe
24: 0x7f54945c8457 - <std[79b10227d68e643c]::thread::local::LocalKey<core[cc79c391059f8e46]::cell::Cell<bool>>>::with::<rustc_middle[285bc2392d469bf7]::ty::print::pretty::with_forced_impl_filename_line<rustc_query_impl[40c3d6d60a0dbb85]::make_query::impl_trait_ref::{closure#0}::{closure#0}, alloc[7de0d13971327f45]::string::String>::{closure#0}, alloc[7de0d13971327f45]::string::String>
25: 0x7f54945bd299 - <std[79b10227d68e643c]::thread::local::LocalKey<core[cc79c391059f8e46]::cell::Cell<bool>>>::with::<rustc_middle[285bc2392d469bf7]::ty::print::pretty::with_no_visible_paths<rustc_query_impl[40c3d6d60a0dbb85]::make_query::impl_trait_ref::{closure#0}, alloc[7de0d13971327f45]::string::String>::{closure#0}, alloc[7de0d13971327f45]::string::String>
26: 0x7f549475c3e5 - rustc_query_impl[40c3d6d60a0dbb85]::make_query::impl_trait_ref
27: 0x7f549450a97b - <rustc_query_system[2bde6a78003d88e]::query::plumbing::QueryState<rustc_middle[285bc2392d469bf7]::dep_graph::dep_node::DepKind, rustc_span[2d5555579096f1fe]::def_id::DefId>>::try_collect_active_jobs::<rustc_query_impl[40c3d6d60a0dbb85]::plumbing::QueryCtxt>
28: 0x7f54945febcf - <rustc_query_impl[40c3d6d60a0dbb85]::Queries>::try_collect_active_jobs
29: 0x7f5494721062 - rustc_query_system[2bde6a78003d88e]::query::job::print_query_stack::<rustc_query_impl[40c3d6d60a0dbb85]::plumbing::QueryCtxt>
30: 0x7f5493da058f - rustc_interface[3206e7bd345239de]::interface::try_print_query_stack
31: 0x7f5493c834f7 - rustc_driver[a54076ffa5a213bc]::report_ice
32: 0x7f54934e4a19 - std::panicking::rust_panic_with_hook::hf940f4eb73f69fac
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/panicking.rs:610:17
33: 0x7f54934e44d0 - std::panicking::begin_panic_handler::{{closure}}::h82243bf8eac030fd
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/panicking.rs:502:13
34: 0x7f54934e14e4 - std::sys_common::backtrace::__rust_end_short_backtrace::h069f9c03677e0254
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/sys_common/backtrace.rs:139:18
35: 0x7f54934e4439 - rust_begin_unwind
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/panicking.rs:498:5
36: 0x7f54934a9491 - core::panicking::panic_fmt::h7b8580d81fcbbacd
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/core/src/panicking.rs:107:14
37: 0x7f54934a9452 - core::panicking::panic_bounds_check::h63650a5dfc9aa86f
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/core/src/panicking.rs:75:5
38: 0x7f5495d9fead - rustc_typeck[9e38b16bd9631970]::collect::impl_trait_ref
39: 0x7f54955d8092 - <rustc_query_impl[40c3d6d60a0dbb85]::Queries as rustc_middle[285bc2392d469bf7]::ty::query::QueryEngine>::impl_trait_ref
40: 0x7f5495de3abd - rustc_typeck[9e38b16bd9631970]::coherence::orphan::orphan_check_crate
41: 0x7f5495fd7f89 - rustc_query_system[2bde6a78003d88e]::query::plumbing::try_execute_query::<rustc_query_impl[40c3d6d60a0dbb85]::plumbing::QueryCtxt, rustc_query_system[2bde6a78003d88e]::query::caches::DefaultCache<(), &[rustc_span[2d5555579096f1fe]::def_id::LocalDefId]>>
42: 0x7f5496018031 - rustc_query_system[2bde6a78003d88e]::query::plumbing::get_query::<rustc_query_impl[40c3d6d60a0dbb85]::queries::orphan_check_crate, rustc_query_impl[40c3d6d60a0dbb85]::plumbing::QueryCtxt>
43: 0x7f5495dad5b4 - <rustc_session[b2ee9260b1d6486]::session::Session>::track_errors::<rustc_typeck[9e38b16bd9631970]::check_crate::{closure#3}, ()>
44: 0x7f5495da96fa - rustc_typeck[9e38b16bd9631970]::check_crate
45: 0x7f5495b3d567 - rustc_interface[3206e7bd345239de]::passes::analysis
46: 0x7f5495fd2c95 - rustc_query_system[2bde6a78003d88e]::query::plumbing::try_execute_query::<rustc_query_impl[40c3d6d60a0dbb85]::plumbing::QueryCtxt, rustc_query_system[2bde6a78003d88e]::query::caches::DefaultCache<(), core[cc79c391059f8e46]::result::Result<(), rustc_errors[d745ba542b3af442]::ErrorReported>>>
47: 0x7f5496026fa5 - rustc_query_system[2bde6a78003d88e]::query::plumbing::get_query::<rustc_query_impl[40c3d6d60a0dbb85]::queries::analysis, rustc_query_impl[40c3d6d60a0dbb85]::plumbing::QueryCtxt>
48: 0x7f5495b32d79 - <rustc_interface[3206e7bd345239de]::passes::QueryContext>::enter::<rustc_driver[a54076ffa5a213bc]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[cc79c391059f8e46]::result::Result<(), rustc_errors[d745ba542b3af442]::ErrorReported>>
49: 0x7f5495b147c4 - <rustc_interface[3206e7bd345239de]::interface::Compiler>::enter::<rustc_driver[a54076ffa5a213bc]::run_compiler::{closure#1}::{closure#2}, core[cc79c391059f8e46]::result::Result<core[cc79c391059f8e46]::option::Option<rustc_interface[3206e7bd345239de]::queries::Linker>, rustc_errors[d745ba542b3af442]::ErrorReported>>
50: 0x7f5495b10fcd - rustc_span[2d5555579096f1fe]::with_source_map::<core[cc79c391059f8e46]::result::Result<(), rustc_errors[d745ba542b3af442]::ErrorReported>, rustc_interface[3206e7bd345239de]::interface::create_compiler_and_run<core[cc79c391059f8e46]::result::Result<(), rustc_errors[d745ba542b3af442]::ErrorReported>, rustc_driver[a54076ffa5a213bc]::run_compiler::{closure#1}>::{closure#1}>
51: 0x7f5495b1574f - <scoped_tls[3fea4c3dcac147b1]::ScopedKey<rustc_span[2d5555579096f1fe]::SessionGlobals>>::set::<rustc_interface[3206e7bd345239de]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[3206e7bd345239de]::interface::run_compiler<core[cc79c391059f8e46]::result::Result<(), rustc_errors[d745ba542b3af442]::ErrorReported>, rustc_driver[a54076ffa5a213bc]::run_compiler::{closure#1}>::{closure#0}, core[cc79c391059f8e46]::result::Result<(), rustc_errors[d745ba542b3af442]::ErrorReported>>::{closure#0}::{closure#0}, core[cc79c391059f8e46]::result::Result<(), rustc_errors[d745ba542b3af442]::ErrorReported>>
52: 0x7f5495b13845 - std[79b10227d68e643c]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[3206e7bd345239de]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[3206e7bd345239de]::interface::run_compiler<core[cc79c391059f8e46]::result::Result<(), rustc_errors[d745ba542b3af442]::ErrorReported>, rustc_driver[a54076ffa5a213bc]::run_compiler::{closure#1}>::{closure#0}, core[cc79c391059f8e46]::result::Result<(), rustc_errors[d745ba542b3af442]::ErrorReported>>::{closure#0}, core[cc79c391059f8e46]::result::Result<(), rustc_errors[d745ba542b3af442]::ErrorReported>>
53: 0x7f5495b337da - <<std[79b10227d68e643c]::thread::Builder>::spawn_unchecked<rustc_interface[3206e7bd345239de]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[3206e7bd345239de]::interface::run_compiler<core[cc79c391059f8e46]::result::Result<(), rustc_errors[d745ba542b3af442]::ErrorReported>, rustc_driver[a54076ffa5a213bc]::run_compiler::{closure#1}>::{closure#0}, core[cc79c391059f8e46]::result::Result<(), rustc_errors[d745ba542b3af442]::ErrorReported>>::{closure#0}, core[cc79c391059f8e46]::result::Result<(), rustc_errors[d745ba542b3af442]::ErrorReported>>::{closure#1} as core[cc79c391059f8e46]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
54: 0x7f54934efb23 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h732269b0f7c15df2
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/alloc/src/boxed.rs:1694:9
55: 0x7f54934efb23 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h81bbb21674b25c87
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/alloc/src/boxed.rs:1694:9
56: 0x7f54934efb23 - std::sys::unix::thread::Thread::new::thread_start::he34f2ab1cc243b66
at /rustc/db9d361a4731ca0bb48533fab6297a8fea75696f/library/std/src/sys/unix/thread.rs:108:17
57: 0x7f5493428609 - start_thread
58: 0x7f549333c293 - clone
59: 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.59.0-nightly (db9d361a4 2021-11-28) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type lib
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
thread panicked while panicking. aborting.
error: could not compile `playground` due to previous error