rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.6k stars 12.48k forks source link

ICE: failed to get layout for `[type error]`: the type `[type error]` has an unknown layout #102366

Open FedericoStra opened 1 year ago

FedericoStra commented 1 year ago

Hello! This is a strange bug that I'm reporting. I don't have the slightest idea of what it does, nor is it very relevant how I encountered this bug. I report it because it might unveil something important. Anyway, here it is.

Code

Make a new lib with cargo new --lib rustc-bug and put this in src/lib.rs:

/*!
```rust
use rustfmt::lexer::{lex_tokens, Token};
assert!(lex_tokens("Hello!") == Ok(("", vec![Token::Command])));

*/


That's it: an empty module with a single documentation comment with a doc-test.

Now, if you are ready for the bang, run `cargo test --doc` and you'll be welcomed with

error: internal compiler error: compiler/rustc_codegen_llvm/src/context.rs:974:13: failed to get layout for [type error]: the type [type error] has an unknown layout --> src/lib.rs:1:38 | 2 | fn main() { #[allow(non_snake_case)] fn _doctest_main_src_lib_rs_1_0() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


The full backtrace is at the end.

### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:

rustc 1.64.0 (a55dd71d5 2022-09-19) binary: rustc commit-hash: a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52 commit-date: 2022-09-19 host: x86_64-unknown-linux-gnu release: 1.64.0 LLVM version: 14.0.6


The same bug persists if I run it with this nightly version:

rustc 1.66.0-nightly (8b705839c 2022-09-26) binary: rustc commit-hash: 8b705839cd656d202e920efa8769cbe43a5ee269 commit-date: 2022-09-26 host: x86_64-unknown-linux-gnu release: 1.66.0-nightly LLVM version: 15.0.0


### Error output

<!--
Include a backtrace in the code block by setting `RUST_BACKTRACE=1` in your
environment. E.g. `RUST_BACKTRACE=1 cargo build`.
-->
<details><summary><strong>Backtrace</strong></summary>
<p>

running 1 test test src/lib.rs - (line 1) ... FAILED

failures:

---- src/lib.rs - (line 1) stdout ---- error: internal compiler error: compiler/rustc_codegen_llvm/src/context.rs:974:13: failed to get layout for [type error]: the type [type error] has an unknown layout --> src/lib.rs:1:38 | 2 | fn main() { #[allow(non_snake_case)] fn _doctest_main_src_lib_rs_1_0() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'Box', /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/compiler/rustc_errors/src/lib.rs:1332:9 stack backtrace: 0: 0x7f8ec2bb919d - std::backtrace_rs::backtrace::libunwind::trace::h9135f25bc195152c at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x7f8ec2bb919d - std::backtrace_rs::backtrace::trace_unsynchronized::h015ee85be510df51 at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7f8ec2bb919d - std::sys_common::backtrace::_print_fmt::h5fad03caa9652a2c at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/sys_common/backtrace.rs:66:5 3: 0x7f8ec2bb919d - ::fmt::h2b42ca28d244e5c7 at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/sys_common/backtrace.rs:45:22 4: 0x7f8ec2c146ac - core::fmt::write::h401e827d053130ed at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/fmt/mod.rs:1198:17 5: 0x7f8ec2baa4e1 - std::io::Write::write_fmt::hffec93268f5cde32 at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/io/mod.rs:1672:15 6: 0x7f8ec2bbbeb5 - std::sys_common::backtrace::_print::h180c4c706ee1d3fb at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/sys_common/backtrace.rs:48:5 7: 0x7f8ec2bbbeb5 - std::sys_common::backtrace::print::hd0c35d18765761c9 at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/sys_common/backtrace.rs:35:9 8: 0x7f8ec2bbbeb5 - std::panicking::default_hook::{{closure}}::h1f023310983bc730 at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:295:22 9: 0x7f8ec2bbbbd1 - std::panicking::default_hook::h188fec3334afd5be at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:314:9 10: 0x7f8ec1645484 - rustc_driver[4568cc0a685fd94d]::DEFAULT_HOOK::{closure#0}::{closure#0} 11: 0x7f8ec2bbc5ea - std::panicking::rust_panic_with_hook::hf26e9d4f97b40096 at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:702:17 12: 0x7f8ec16fc491 - std[306a94a967d8f5ee]::panicking::begin_panic::<rustc_errors[5fcb1a1f56a762e6]::ExplicitBug>::{closure#0} 13: 0x7f8ec16fc196 - std[306a94a967d8f5ee]::sys_common::backtrace::rust_end_short_backtrace::<std[306a94a967d8f5ee]::panicking::begin_panic<rustc_errors[5fcb1a1f56a762e6]::ExplicitBug>::{closure#0}, !> 14: 0x7f8ec1726bd6 - std[306a94a967d8f5ee]::panicking::begin_panic::<rustc_errors[5fcb1a1f56a762e6]::ExplicitBug> 15: 0x7f8ec1742d96 - std[306a94a967d8f5ee]::panic::panic_any::<rustc_errors[5fcb1a1f56a762e6]::ExplicitBug> 16: 0x7f8ec1742531 - <rustc_errors[5fcb1a1f56a762e6]::HandlerInner>::span_bug::<rustc_span[721a57c036170ce]::span_encoding::Span, &alloc[6d6f83537459af52]::string::String> 17: 0x7f8ec1741d90 - <rustc_errors[5fcb1a1f56a762e6]::Handler>::span_bug::<rustc_span[721a57c036170ce]::span_encoding::Span, &alloc[6d6f83537459af52]::string::String> 18: 0x7f8ec172e888 - rustc_middle[b6cf56a787d1e2a1]::ty::context::tls::with_opt::<rustc_middle[b6cf56a787d1e2a1]::util::bug::opt_span_bug_fmt<rustc_span[721a57c036170ce]::span_encoding::Span>::{closure#0}, ()> 19: 0x7f8ec172e726 - rustc_middle[b6cf56a787d1e2a1]::util::bug::opt_span_bug_fmt::<rustc_span[721a57c036170ce]::span_encoding::Span> 20: 0x7f8ec0167d04 - rustc_middle[b6cf56a787d1e2a1]::util::bug::span_bug_fmt::<rustc_span[721a57c036170ce]::span_encoding::Span> 21: 0x7f8ec17377a1 - <rustc_codegen_llvm[3e0bcdafb62c313]::context::CodegenCx as rustc_middle[b6cf56a787d1e2a1]::ty::layout::LayoutOfHelpers>::handle_layout_err 22: 0x7f8ec1731721 - <rustc_codegen_llvm[3e0bcdafb62c313]::context::CodegenCx as rustc_middle[b6cf56a787d1e2a1]::ty::layout::LayoutOf>::spanned_layout_of::{closure#0} 23: 0x7f8ec01813be - rustc_codegen_ssa[5936c3af92679481]::mir::analyze::non_ssa_locals::<rustc_codegen_llvm[3e0bcdafb62c313]::builder::Builder> 24: 0x7f8ec014d8bd - rustc_codegen_ssa[5936c3af92679481]::mir::codegen_mir::<rustc_codegen_llvm[3e0bcdafb62c313]::builder::Builder> 25: 0x7f8ec105bf23 - rustc_codegen_llvm[3e0bcdafb62c313]::base::compile_codegen_unit::module_codegen 26: 0x7f8ec0b23b19 - <rustc_query_system[8caf4755e287670e]::dep_graph::graph::DepGraph<rustc_middle[b6cf56a787d1e2a1]::dep_graph::dep_node::DepKind>>::with_task::<rustc_middle[b6cf56a787d1e2a1]::ty::context::TyCtxt, rustc_span[721a57c036170ce]::symbol::Symbol, rustc_codegen_ssa[5936c3af92679481]::ModuleCodegen<rustc_codegen_llvm[3e0bcdafb62c313]::ModuleLlvm>> 27: 0x7f8ec0b224b9 - rustc_codegen_llvm[3e0bcdafb62c313]::base::compile_codegen_unit 28: 0x7f8ec0b20ace - <rustc_codegen_llvm[3e0bcdafb62c313]::LlvmCodegenBackend as rustc_codegen_ssa[5936c3af92679481]::traits::backend::CodegenBackend>::codegen_crate 29: 0x7f8ec0dc5bac - <rustc_session[98f7faf1d37bb5fb]::session::Session>::time::<alloc[6d6f83537459af52]::boxed::Box<dyn core[6fcc70bcc91a5bf5]::any::Any>, rustc_interface[f934826ba4c12dd9]::passes::start_codegen::{closure#0}> 30: 0x7f8ec0dc53b3 - <rustc_interface[f934826ba4c12dd9]::passes::QueryContext>::enter::<<rustc_interface[f934826ba4c12dd9]::queries::Queries>::ongoing_codegen::{closure#0}::{closure#0}, core[6fcc70bcc91a5bf5]::result::Result<alloc[6d6f83537459af52]::boxed::Box<dyn core[6fcc70bcc91a5bf5]::any::Any>, rustc_errors[5fcb1a1f56a762e6]::ErrorGuaranteed>> 31: 0x7f8ec0dbda0f - <rustc_interface[f934826ba4c12dd9]::queries::Queries>::ongoing_codegen 32: 0x7f8ec0dbc9b2 - <rustc_interface[f934826ba4c12dd9]::interface::Compiler>::enter::<rustc_driver[4568cc0a685fd94d]::run_compiler::{closure#1}::{closure#2}, core[6fcc70bcc91a5bf5]::result::Result<core[6fcc70bcc91a5bf5]::option::Option<rustc_interface[f934826ba4c12dd9]::queries::Linker>, rustc_errors[5fcb1a1f56a762e6]::ErrorGuaranteed>> 33: 0x7f8ec0db186a - rustc_span[721a57c036170ce]::with_source_map::<core[6fcc70bcc91a5bf5]::result::Result<(), rustc_errors[5fcb1a1f56a762e6]::ErrorGuaranteed>, rustc_interface[f934826ba4c12dd9]::interface::create_compiler_and_run<core[6fcc70bcc91a5bf5]::result::Result<(), rustc_errors[5fcb1a1f56a762e6]::ErrorGuaranteed>, rustc_driver[4568cc0a685fd94d]::run_compiler::{closure#1}>::{closure#1}> 34: 0x7f8ec0db11a2 - <scoped_tls[80743de900a7f844]::ScopedKey<rustc_span[721a57c036170ce]::SessionGlobals>>::set::<rustc_interface[f934826ba4c12dd9]::interface::run_compiler<core[6fcc70bcc91a5bf5]::result::Result<(), rustc_errors[5fcb1a1f56a762e6]::ErrorGuaranteed>, rustc_driver[4568cc0a685fd94d]::run_compiler::{closure#1}>::{closure#0}, core[6fcc70bcc91a5bf5]::result::Result<(), rustc_errors[5fcb1a1f56a762e6]::ErrorGuaranteed>> 35: 0x7f8ec0daf5cf - std[306a94a967d8f5ee]::sys_common::backtrace::rust_begin_short_backtrace::<rustc_interface[f934826ba4c12dd9]::util::run_in_thread_pool_with_globals<rustc_interface[f934826ba4c12dd9]::interface::run_compiler<core[6fcc70bcc91a5bf5]::result::Result<(), rustc_errors[5fcb1a1f56a762e6]::ErrorGuaranteed>, rustc_driver[4568cc0a685fd94d]::run_compiler::{closure#1}>::{closure#0}, core[6fcc70bcc91a5bf5]::result::Result<(), rustc_errors[5fcb1a1f56a762e6]::ErrorGuaranteed>>::{closure#0}, core[6fcc70bcc91a5bf5]::result::Result<(), rustc_errors[5fcb1a1f56a762e6]::ErrorGuaranteed>> 36: 0x7f8ec14690b9 - <<std[306a94a967d8f5ee]::thread::Builder>::spawnunchecked<rustc_interface[f934826ba4c12dd9]::util::run_in_thread_pool_with_globals<rustc_interface[f934826ba4c12dd9]::interface::run_compiler<core[6fcc70bcc91a5bf5]::result::Result<(), rustc_errors[5fcb1a1f56a762e6]::ErrorGuaranteed>, rustc_driver[4568cc0a685fd94d]::run_compiler::{closure#1}>::{closure#0}, core[6fcc70bcc91a5bf5]::result::Result<(), rustc_errors[5fcb1a1f56a762e6]::ErrorGuaranteed>>::{closure#0}, core[6fcc70bcc91a5bf5]::result::Result<(), rustc_errors[5fcb1a1f56a762e6]::ErrorGuaranteed>>::{closure#1} as core[6fcc70bcc91a5bf5]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 37: 0x7f8ec2bc6723 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce>::call_once::h56d5fc072706762b at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/alloc/src/boxed.rs:1935:9 38: 0x7f8ec2bc6723 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce>::call_once::h41deef8e33b824bb at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/alloc/src/boxed.rs:1935:9 39: 0x7f8ec2bc6723 - std::sys::unix::thread::Thread::new::thread_start::ha6436304a1170bba at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/sys/unix/thread.rs:108:17 40: 0x7f8ebea9f822 - start_thread 41: 0x7f8ebea3f450 - clone3 42: 0x0 -

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 (a55dd71d5 2022-09-19) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C codegen-units=1 -C embed-bitcode=no

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

Couldn't compile the test.

failures: src/lib.rs - (line 1)

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.05s

error: test failed, to rerun pass '--doc'



</p>
</details>
Noratrieb commented 1 year ago

This might not fix the underlying issue but I'll at least make the ICE look less cursed

Noratrieb commented 1 year ago

Btw, I can reproduce this on the latest nightly

rustc 1.66.0-nightly (8b705839c 2022-09-26)
binary: rustc
commit-hash: 8b705839cd656d202e920efa8769cbe43a5ee269
commit-date: 2022-09-26
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.0
Noratrieb commented 1 year ago

With #102373 I now get this backtrace:

Backtrace ``` error: internal compiler error: no errors encountered even though `delay_span_bug` issued error: internal compiler error: `InferCtxt` incorrectly tainted by errors | = note: delayed at compiler/rustc_infer/src/infer/mod.rs:1282:27 error: internal compiler error: TyKind::Error constructed but no error reported | = note: delayed at compiler/rustc_hir_analysis/src/check/expr.rs:526:21 error: internal compiler error: TyKind::Error constructed but no error reported | = note: delayed at compiler/rustc_trait_selection/src/traits/project.rs:1238:30 error: internal compiler error: TyKind::Error constructed but no error reported | = note: delayed at compiler/rustc_hir_analysis/src/check/fn_ctxt/_impl.rs:724:23 error: internal compiler error: TyKind::Error constructed but no error reported | = note: delayed at compiler/rustc_hir_analysis/src/check/coercion.rs:176:49 error: internal compiler error: TyKind::Error constructed but no error reported | = note: delayed at compiler/rustc_hir_analysis/src/check/fn_ctxt/checks.rs:109:29 error: internal compiler error: TyKind::Error constructed but no error reported | = note: delayed at compiler/rustc_hir_analysis/src/check/coercion.rs:963:53 error: internal compiler error: TyKind::Error constructed but no error reported | = note: delayed at compiler/rustc_hir_analysis/src/check/coercion.rs:1404:42 error: internal compiler error: TyKind::Error constructed but no error reported | = note: delayed at compiler/rustc_infer/src/infer/sub.rs:123:31 error: internal compiler error: TyKind::Error constructed but no error reported | = note: delayed at compiler/rustc_hir_analysis/src/check/fn_ctxt/checks.rs:1536:27 error: internal compiler error: TyKind::Error constructed but no error reported | = note: delayed at compiler/rustc_hir_analysis/src/check/fallback.rs:109:58 error: internal compiler error: TyKind::Error constructed but no error reported | = note: delayed at /home/nilsh/projects/rust/compiler/rustc_middle/src/ty/relate.rs:419:59 error: internal compiler error: expected fullfillment errors | = note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:210:23 error: internal compiler error: TyKind::Error constructed but no error reported | = note: delayed at compiler/rustc_mir_build/src/build/mod.rs:627:18 error: internal compiler error: PromoteTemps: MIR had errors --> src/lib.rs:1:38 | 2 | fn main() { #[allow(non_snake_case)] fn _doctest_main_src_lib_rs_1_0() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: delayed at compiler/rustc_const_eval/src/transform/promote_consts.rs:53:22 error: internal compiler error: broken MIR in DefId(0:4 ~ rust_out[b9b2]::main::_doctest_main_src_lib_rs_1_0) ("return type"): bad type [type error] --> src/lib.rs:1:38 | 2 | fn main() { #[allow(non_snake_case)] fn _doctest_main_src_lib_rs_1_0() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:523:13 error: internal compiler error: TyKind::Error constructed but no error reported | = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:791:20 error: internal compiler error: broken MIR in DefId(0:4 ~ rust_out[b9b2]::main::_doctest_main_src_lib_rs_1_0) (LocalDecl { mutability: Mut, local_info: None, internal: false, is_block_tail: None, ty: [type error], user_ty: None, source_info: SourceInfo { span: src/lib.rs:2:38: 2:71 (#0), scope: scope[0] } }): bad type [type error] --> src/lib.rs:1:38 | 2 | fn main() { #[allow(non_snake_case)] fn _doctest_main_src_lib_rs_1_0() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: delayed at compiler/rustc_borrowck/src/type_check/mod.rs:523:13 thread 'rustc' panicked at 'Box', compiler/rustc_errors/src/lib.rs:1535:13 stack backtrace: 0: 0x7fee569b5ada - std::backtrace_rs::backtrace::libunwind::trace::h8f2eb234454895b5 at /home/nilsh/projects/rust/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5 1: 0x7fee569b5ada - std::backtrace_rs::backtrace::trace_unsynchronized::h92c29b31ac06fd9e at /home/nilsh/projects/rust/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x7fee569b5ada - std::sys_common::backtrace::_print_fmt::h18c573bdedef2902 at /home/nilsh/projects/rust/library/std/src/sys_common/backtrace.rs:66:5 3: 0x7fee569b5ada - ::fmt::h2cc87b43d8a562b6 at /home/nilsh/projects/rust/library/std/src/sys_common/backtrace.rs:45:22 4: 0x7fee56a117f8 - core::fmt::write::hf898e0a9cc3c89a4 at /home/nilsh/projects/rust/library/core/src/fmt/mod.rs:1209:17 5: 0x7fee56980da1 - std::io::Write::write_fmt::h2ad619589edaa38f at /home/nilsh/projects/rust/library/std/src/io/mod.rs:1679:15 6: 0x7fee569b592f - std::sys_common::backtrace::_print::h96ff3c099826a10a at /home/nilsh/projects/rust/library/std/src/sys_common/backtrace.rs:48:5 7: 0x7fee569b592f - std::sys_common::backtrace::print::hee5b5a20ab57e326 at /home/nilsh/projects/rust/library/std/src/sys_common/backtrace.rs:35:9 8: 0x7fee5699e6e4 - std::panicking::default_hook::{{closure}}::hdb24a3f35c559c6e 9: 0x7fee5699e49a - std::panicking::default_hook::ha3e88625b127343c at /home/nilsh/projects/rust/library/std/src/panicking.rs:286:9 10: 0x7fee57329c04 - core[73fa0f4e5d90a029]::ops::function::Fn<(&'a core[73fa0f4e5d90a029]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[73fa0f4e5d90a029]::marker::Send + core[73fa0f4e5d90a029]::marker::Sync> as core[73fa0f4e5d90a029]::ops::function::Fn<(&core[73fa0f4e5d90a029]::panic::panic_info::PanicInfo,)>>::call at /home/nilsh/projects/rust/library/alloc/src/boxed.rs:1952:9 11: 0x7fee57329c04 - rustc_driver[371a0ea167db5f7f]::DEFAULT_HOOK::{closure#0}::{closure#0} at /home/nilsh/projects/rust/compiler/rustc_driver/src/lib.rs:1195:13 12: 0x7fee5699eb0d - as core::ops::function::Fn>::call::hafc548451be5b4cf at /home/nilsh/projects/rust/library/alloc/src/boxed.rs:1952:9 13: 0x7fee5699eb0d - std::panicking::rust_panic_with_hook::hbd6e17eb7e759fb0 at /home/nilsh/projects/rust/library/std/src/panicking.rs:673:13 14: 0x7fee59cdf713 - std[d559eab05d6b0603]::panicking::begin_panic::::{closure#0} at /home/nilsh/projects/rust/library/std/src/panicking.rs:589:9 15: 0x7fee59cdf6c6 - std[d559eab05d6b0603]::sys_common::backtrace::__rust_end_short_backtrace::::{closure#0}, !> at /home/nilsh/projects/rust/library/std/src/sys_common/backtrace.rs:138:18 16: 0x7fee572e74c6 - std[d559eab05d6b0603]::panicking::begin_panic:: at /home/nilsh/projects/rust/library/std/src/panicking.rs:588:12 17: 0x7fee59c89906 - std[d559eab05d6b0603]::panic::panic_any:: at /home/nilsh/projects/rust/library/std/src/panic.rs:61:5 18: 0x7fee59c8c61c - ::flush_delayed::, &str> at /home/nilsh/projects/rust/compiler/rustc_errors/src/lib.rs:1535:13 19: 0x7fee59ca7743 - ::flush_delayed at /home/nilsh/projects/rust/compiler/rustc_errors/src/lib.rs:1140:9 20: 0x7fee57468eb9 - ::ongoing_codegen::{closure#0}::{closure#0} at /home/nilsh/projects/rust/compiler/rustc_interface/src/queries.rs:249:17 21: 0x7fee57468eb9 - ::enter::<::ongoing_codegen::{closure#0}::{closure#0}, core[73fa0f4e5d90a029]::result::Result, rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#0} at /home/nilsh/projects/rust/compiler/rustc_interface/src/passes.rs:769:42 22: 0x7fee57468eb9 - rustc_middle[3b85d9020c912d92]::ty::context::tls::enter_context::<::enter<::ongoing_codegen::{closure#0}::{closure#0}, core[73fa0f4e5d90a029]::result::Result, rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result, rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#0} at /home/nilsh/projects/rust/compiler/rustc_middle/src/ty/context.rs:1928:50 23: 0x7fee57468eb9 - rustc_middle[3b85d9020c912d92]::ty::context::tls::set_tlv::::enter<::ongoing_codegen::{closure#0}::{closure#0}, core[73fa0f4e5d90a029]::result::Result, rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result, rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result, rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>> at /home/nilsh/projects/rust/compiler/rustc_middle/src/ty/context.rs:1912:9 24: 0x7fee57468eb9 - rustc_middle[3b85d9020c912d92]::ty::context::tls::enter_context::<::enter<::ongoing_codegen::{closure#0}::{closure#0}, core[73fa0f4e5d90a029]::result::Result, rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result, rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>> at /home/nilsh/projects/rust/compiler/rustc_middle/src/ty/context.rs:1928:9 25: 0x7fee57468eb9 - ::enter::<::ongoing_codegen::{closure#0}::{closure#0}, core[73fa0f4e5d90a029]::result::Result, rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>> at /home/nilsh/projects/rust/compiler/rustc_interface/src/passes.rs:769:9 26: 0x7fee57469bed - ::ongoing_codegen::{closure#0} at /home/nilsh/projects/rust/compiler/rustc_interface/src/queries.rs:243:13 27: 0x7fee57469bed - >>::compute::<::ongoing_codegen::{closure#0}> at /home/nilsh/projects/rust/compiler/rustc_interface/src/queries.rs:38:28 28: 0x7fee57330c4e - rustc_driver[371a0ea167db5f7f]::run_compiler::{closure#1}::{closure#2} at /home/nilsh/projects/rust/compiler/rustc_driver/src/lib.rs:408:13 29: 0x7fee57330c4e - ::enter::, rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>> at /home/nilsh/projects/rust/compiler/rustc_interface/src/queries.rs:379:19 30: 0x7fee57316ff2 - rustc_driver[371a0ea167db5f7f]::run_compiler::{closure#1} at /home/nilsh/projects/rust/compiler/rustc_driver/src/lib.rs:316:22 31: 0x7fee57316ff2 - rustc_interface[7313dbe8dd443abf]::interface::create_compiler_and_run::, rustc_driver[371a0ea167db5f7f]::run_compiler::{closure#1}>::{closure#1} at /home/nilsh/projects/rust/compiler/rustc_interface/src/interface.rs:323:13 32: 0x7fee57316ff2 - rustc_span[84dbe569a712e516]::with_source_map::, rustc_interface[7313dbe8dd443abf]::interface::create_compiler_and_run, rustc_driver[371a0ea167db5f7f]::run_compiler::{closure#1}>::{closure#1}> at /home/nilsh/projects/rust/compiler/rustc_span/src/lib.rs:999:5 33: 0x7fee57331759 - rustc_interface[7313dbe8dd443abf]::interface::create_compiler_and_run::, rustc_driver[371a0ea167db5f7f]::run_compiler::{closure#1}> at /home/nilsh/projects/rust/compiler/rustc_interface/src/interface.rs:317:5 34: 0x7fee57337e82 - rustc_interface[7313dbe8dd443abf]::interface::run_compiler::, rustc_driver[371a0ea167db5f7f]::run_compiler::{closure#1}>::{closure#0} at /home/nilsh/projects/rust/compiler/rustc_interface/src/interface.rs:339:12 35: 0x7fee57337e82 - >::set::, rustc_driver[371a0ea167db5f7f]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>> at /home/nilsh/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9 36: 0x7fee57303aea - rustc_span[84dbe569a712e516]::create_session_globals_then::, rustc_interface[7313dbe8dd443abf]::interface::run_compiler, rustc_driver[371a0ea167db5f7f]::run_compiler::{closure#1}>::{closure#0}> at /home/nilsh/projects/rust/compiler/rustc_span/src/lib.rs:111:5 37: 0x7fee57303aea - rustc_interface[7313dbe8dd443abf]::util::run_in_thread_pool_with_globals::, rustc_driver[371a0ea167db5f7f]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#0} at /home/nilsh/projects/rust/compiler/rustc_interface/src/util.rs:159:32 38: 0x7fee57303aea - std[d559eab05d6b0603]::sys_common::backtrace::__rust_begin_short_backtrace::, rustc_driver[371a0ea167db5f7f]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>> at /home/nilsh/projects/rust/library/std/src/sys_common/backtrace.rs:122:18 39: 0x7fee5730560e - ::spawn_unchecked_::, rustc_driver[371a0ea167db5f7f]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#1}::{closure#0} at /home/nilsh/projects/rust/library/std/src/thread/mod.rs:514:17 40: 0x7fee5730560e - ::spawn_unchecked_, rustc_driver[371a0ea167db5f7f]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#1}::{closure#0}> as core[73fa0f4e5d90a029]::ops::function::FnOnce<()>>::call_once at /home/nilsh/projects/rust/library/core/src/panic/unwind_safe.rs:271:9 41: 0x7fee5730560e - std[d559eab05d6b0603]::panicking::try::do_call::::spawn_unchecked_, rustc_driver[371a0ea167db5f7f]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#1}::{closure#0}>, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>> at /home/nilsh/projects/rust/library/std/src/panicking.rs:464:40 42: 0x7fee5730560e - std[d559eab05d6b0603]::panicking::try::, core[73fa0f4e5d90a029]::panic::unwind_safe::AssertUnwindSafe<::spawn_unchecked_, rustc_driver[371a0ea167db5f7f]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#1}::{closure#0}>> at /home/nilsh/projects/rust/library/std/src/panicking.rs:428:19 43: 0x7fee5731cf04 - std[d559eab05d6b0603]::panic::catch_unwind::::spawn_unchecked_, rustc_driver[371a0ea167db5f7f]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#1}::{closure#0}>, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>> at /home/nilsh/projects/rust/library/std/src/panic.rs:137:14 44: 0x7fee5731cf04 - ::spawn_unchecked_::, rustc_driver[371a0ea167db5f7f]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#1} at /home/nilsh/projects/rust/library/std/src/thread/mod.rs:513:30 45: 0x7fee5731cf04 - <::spawn_unchecked_, rustc_driver[371a0ea167db5f7f]::run_compiler::{closure#1}>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#0}, core[73fa0f4e5d90a029]::result::Result<(), rustc_errors[7f5df6e7b9fd1751]::ErrorGuaranteed>>::{closure#1} as core[73fa0f4e5d90a029]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} at /home/nilsh/projects/rust/library/core/src/ops/function.rs:251:5 46: 0x7fee5697a818 - as core::ops::function::FnOnce>::call_once::h73d336d1c9e65b4a at /home/nilsh/projects/rust/library/alloc/src/boxed.rs:1938:9 47: 0x7fee5697a818 - as core::ops::function::FnOnce>::call_once::ha38990988e6c8e8b at /home/nilsh/projects/rust/library/alloc/src/boxed.rs:1938:9 48: 0x7fee56995f97 - std::sys::unix::thread::Thread::new::thread_start::h0e8d69c155def017 at /home/nilsh/projects/rust/library/std/src/sys/unix/thread.rs:108:17 49: 0x7fee56750b43 - start_thread at ./nptl/./nptl/pthread_create.c:442:8 50: 0x7fee567e2a00 - clone3 at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81 51: 0x0 - 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.66.0-dev running on x86_64-unknown-linux-gnu note: compiler flags: --crate-type bin -C codegen-units=1 -C embed-bitcode=no query stack during panic: end of query stack error: aborting due to 19 previous errors ```

The error was originally emitted in check_expr_path in hir-analysis when it failed to resolve a path

https://github.com/rust-lang/rust/blob/57ee5cf5a93923dae9c98bffb11545fc3a31368d/compiler/rustc_hir_analysis/src/check/expr.rs#L518-L527

FedericoStra commented 1 year ago

This might not fix the underlying issue but I'll at least make the ICE look less cursed

I guess "less cursed" is subjective then :smile:

Anyway, the PR seems a good step forward: I didn't know there was a bug in the bug that made it difficult to track down the actual bug. :+1:

Noratrieb commented 1 year ago

I have actually experienced the same ICE yesterday in my own code when I was working on AST lowering and lowered things in the wrong order. It seems like this kind of late path resolution failure happens when path resolution initially succeeds, but then something (like a broken AST lowering) happens which causes the path to suddenly stop resolving in typeck. Typeck then doesn't know any better than to create a type error type (which causes the mass of delayed ICEs) and continue, which doesmakes sense, as this path is hit as well when the code has a real path resolution error that is correctly detected and emitted earlier.