Skip to content

Nightly Compiler Bug - Failed to recover key for type_of #79932

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

Closed
jmg-duarte opened this issue Dec 11, 2020 · 6 comments
Closed

Nightly Compiler Bug - Failed to recover key for type_of #79932

jmg-duarte opened this issue Dec 11, 2020 · 6 comments
Labels
C-bug Category: This is a bug. 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.

Comments

@jmg-duarte
Copy link

jmg-duarte commented Dec 11, 2020

The error occurs when running cargo expand for https://github.com/rustype/proc-macro-workshop/blob/18f33a2bf2037f5b020dc508dfc9204467cb2ad5/main.rs

Code

Repository: https://github.com/rustype/proc-macro-workshop/tree/18f33a2bf2037f5b020dc508dfc9204467cb2ad5

extern crate proc_macro;

use proc_macro2::TokenStream;
use quote::quote;
use syn::parse_macro_input;

#[proc_macro_attribute]
pub fn sorted(
    args: proc_macro::TokenStream,
    input: proc_macro::TokenStream,
) -> proc_macro::TokenStream {
    let _ = args;
    let item = parse_macro_input!(input as syn::Item);

    match parse_sorted(item) {
        Ok(tt) => tt,
        Err(err) => err.to_compile_error(),
    }
    .into()
}

fn parse_sorted(item: syn::Item) -> syn::Result<TokenStream> {
    println!("{:#?}", item);
    if let syn::Item::Enum(_) = item {
        syn::Result::Ok(quote!(#item))
    } else {
        syn::Result::Err(syn::Error::new(
            proc_macro2::Span::call_site(),
            "expected enum or match expression",
        ))
    }
}

Meta

rustc --version --verbose:

rustc 1.50.0-nightly (f0f68778f 2020-12-09) running on x86_64-unknown-linux-gnu

Error output

thread 'rustc' panicked at 'Failed to recover key for type_of(44bb8dfde12fe5f2-84c94631772ec105) with hash 44bb8dfde12fe5f2-84c94631772ec105', compiler/rustc_middle/src/ty/query/mod.rs:235:5
note: run with `RUST_BACKTRACE=1` environment variable to display a 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.50.0-nightly (f0f68778f 2020-12-09) running on x86_64-unknown-linux-gnu
note: compiler flags: -C prefer-dynamic -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type proc-macro
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
  left: `LLVMing`,
 right: `Codegenning`', /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/compiler/rustc_codegen_ssa/src/back/write.rs:1425:21
error: internal compiler error: unexpected panic
Backtrace

stack backtrace:
   0: rust_begin_unwind
             at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/f0f68778f798d6d34649745b41770829b17ba5b8/library/std/src/panicking.rs:435:5
   2: rustc_middle::ty::query::try_load_from_on_disk_cache::{{closure}}
   3: rustc_middle::ty::query::try_load_from_on_disk_cache
   4: rustc_query_system::dep_graph::graph::DepGraph<K>::exec_cache_promotions
   5: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
   6: rustc_incremental::persist::save::save_in
   7: rustc_data_structures::sync::join
   8: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
   9: rustc_incremental::persist::save::save_dep_graph
  10: rustc_codegen_ssa::base::finalize_tcx
  11: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  12: rustc_session::utils::<impl rustc_session::session::Session>::time
  13: rustc_interface::passes::QueryContext::enter
  14: rustc_interface::queries::Queries::ongoing_codegen
  15: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  16: rustc_span::with_source_map
  17: rustc_interface::interface::create_compiler_and_run
  18: scoped_tls::ScopedKey<T>::set

@jmg-duarte jmg-duarte added C-bug Category: This is a bug. 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. labels Dec 11, 2020
@jmg-duarte
Copy link
Author

jmg-duarte commented Dec 11, 2020

In version rustc 1.50.0-nightly (d32c320d7 2020-12-10) (from rustc 1.50.0-nightly (f0f68778f 2020-12-09)) the command works does not work.

@jmg-duarte
Copy link
Author

jmg-duarte commented Dec 11, 2020

This is probably a duplicate of #79890
However I don't know for sure so I'm leaving the issue open for someone with experience to comment on it

@jmg-duarte
Copy link
Author

After all, the panic persists in rustc 1.50.0-nightly (d32c320d7 2020-12-10) (from rustc 1.50.0-nightly (f0f68778f 2020-12-09))

thread 'rustc' panicked at 'Failed to recover key for type_of(44bb8dfde12fe5f2-84c94631772ec105) with hash 44bb8dfde12fe5f2-84c94631772ec105', compiler/rustc_middle/src/ty/query/mod.rs:235:5
stack backtrace:
   0: rust_begin_unwind
             at /rustc/d32c320d7eee56706486fef6be778495303afe9e/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/d32c320d7eee56706486fef6be778495303afe9e/library/std/src/panicking.rs:435:5
   2: rustc_middle::ty::query::try_load_from_on_disk_cache::{{closure}}
   3: rustc_middle::ty::query::try_load_from_on_disk_cache
   4: rustc_query_system::dep_graph::graph::DepGraph<K>::exec_cache_promotions
   5: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
   6: rustc_incremental::persist::save::save_in
   7: rustc_data_structures::sync::join
   8: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
   9: rustc_incremental::persist::save::save_dep_graph
  10: rustc_codegen_ssa::base::finalize_tcx
  11: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  12: rustc_session::utils::<impl rustc_session::session::Session>::time
  13: rustc_interface::passes::QueryContext::enter
  14: rustc_interface::queries::Queries::ongoing_codegen
  15: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  16: rustc_span::with_source_map
  17: rustc_interface::interface::create_compiler_and_run
  18: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

@timothybrink
Copy link

I'm getting this error as well, on rustc 1.50.0-nightly (d32c320d7 2020-12-10). I removed a dependency that I was no longer using, and then when I do cargo check I get the same error. cargo run and cargo build work. Adding the dependency back into Cargo.toml causes cargo check to work again.

Backtrace is pretty much the same as above, here it is in case it's helpful:

thread 'rustc' panicked at 'Failed to recover key for type_of(b26e64bb1a032ad3-31c4fc9a3197493a) with hash b26e64bb1a032ad3-31c4fc9a3197493a', compiler/rustc_middle/src/ty/query/mod.rs:235:5
stack backtrace:
   0: rust_begin_unwind
             at /rustc/d32c320d7eee56706486fef6be778495303afe9e/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /rustc/d32c320d7eee56706486fef6be778495303afe9e/library/std/src/panicking.rs:435:5
   2: rustc_middle::ty::query::try_load_from_on_disk_cache::{{closure}}
   3: rustc_middle::ty::query::try_load_from_on_disk_cache
   4: rustc_query_system::dep_graph::graph::DepGraph<K>::exec_cache_promotions
   5: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
   6: rustc_incremental::persist::save::save_in
   7: rustc_data_structures::sync::join
   8: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
   9: rustc_incremental::persist::save::save_dep_graph
  10: rustc_codegen_ssa::base::finalize_tcx
  11: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  12: rustc_session::utils::<impl rustc_session::session::Session>::time
  13: rustc_interface::passes::QueryContext::enter
  14: rustc_interface::queries::Queries::ongoing_codegen
  15: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  16: rustc_span::with_source_map
  17: rustc_interface::interface::create_compiler_and_run
  18: scoped_tls::ScopedKey<T>::set

@Aaron1011
Copy link
Member

This should be fixed by #79915, which will be in tomorrow's nightly

@jyn514
Copy link
Member

jyn514 commented Dec 11, 2020

Closing as duplicate of #79890

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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants